FreeKill/packages/standard/game_rule.lua
YoumuKon 21e4c65204
终结标记与界bugfix (#307)
-
正式移除了作为临时手段的-tmp标记,现在can_use和target_filter支持读取extra_data(card_filter暂时搁置)
-
规范了askForUseCard中card_name和pattern的关系,现在的格式将以pattern为主,若无pattern才会将card_name视为pattern
- 将withinDistanceLimit迁移至ActiveSkill内
- 添加了令卡牌无距离/次数限制的标记判断
- 添加放大了⑨倍的冰伤音效
- 优化了同将判断的逻辑,使其能够准确读取trueName
- 身份场主公选将后其他角色能看见主公技能(只是看见,无实际功能)
- 开局添加不存在的技能时会放出警报
- 修复了findParent在当前事件无parent时报错的bug
- 修复了人工洗牌后不刷新摸牌堆的bug
- 修复了getPile返回牌堆实例的bug
- 修复了getSkillNameList无法过滤主公技的bug
- 修复了死亡后武将牌没有圆角效果的bug
2024-01-25 03:13:57 +08:00

108 lines
3.2 KiB
Lua

-- SPDX-License-Identifier: GPL-3.0-or-later
---@param killer ServerPlayer
local function rewardAndPunish(killer, victim)
if killer.dead then return end
if victim.role == "rebel" then
killer:drawCards(3, "kill")
elseif victim.role == "loyalist" and killer.role == "lord" then
killer:throwAllCards("he")
end
end
GameRule = fk.CreateTriggerSkill{
name = "game_rule",
events = {
fk.GamePrepared,
fk.AskForPeaches, fk.AskForPeachesDone,
fk.GameOverJudge, fk.BuryVictim,
},
priority = 0,
can_trigger = function(self, event, target, player, data)
return (target == player) or (target == nil)
end,
on_trigger = function(self, event, target, player, data)
local room = player.room
if room:getTag("SkipGameRule") then
room:setTag("SkipGameRule", false)
return false
end
if event == fk.GamePrepared then
room:setTag("FirstRound", true)
room:setTag("RoundCount", 0)
return false
end
switch(event, {
[fk.AskForPeaches] = function()
local dyingPlayer = room:getPlayerById(data.who)
while dyingPlayer.hp < 1 do
local cardNames = {"peach"}
local prompt = "#AskForPeaches:" .. dyingPlayer.id .. "::" .. tostring(1 - dyingPlayer.hp)
if player == dyingPlayer then
table.insert(cardNames, "analeptic")
prompt = "#AskForPeachesSelf:::" .. tostring(1 - dyingPlayer.hp)
end
cardNames = table.filter(cardNames, function (cardName)
local cardCloned = Fk:cloneCard(cardName)
return not (player:prohibitUse(cardCloned) or player:isProhibited(dyingPlayer, cardCloned))
end)
if #cardNames == 0 then return end
local peach_use = room:askForUseCard(player, "peach", table.concat(cardNames, ",") , prompt, true, {analepticRecover = true})
if not peach_use then break end
peach_use.tos = { {dyingPlayer.id} }
if peach_use.card.trueName == "analeptic" then
peach_use.extra_data = peach_use.extra_data or {}
peach_use.extra_data.analepticRecover = true
end
room:useCard(peach_use)
end
end,
[fk.AskForPeachesDone] = function()
if player.hp < 1 and not data.ignoreDeath then
---@type DeathStruct
local deathData = {
who = player.id,
damage = data.damage,
}
room:killPlayer(deathData)
end
end,
[fk.GameOverJudge] = function()
local winner = Fk.game_modes[room.settings.gameMode]:getWinner(player)
if winner ~= "" then
room:gameOver(winner)
return true
end
end,
[fk.BuryVictim] = function()
player:bury()
if room.tag["SkipNormalDeathProcess"] or player.rest > 0 then
return false
end
local damage = data.damage
if damage and damage.from then
local killer = damage.from
rewardAndPunish(killer, player);
end
end,
default = function()
print("game_rule: Event=" .. event)
room:askForSkillInvoke(player, "rule")
end,
})
return false
end,
}
local fastchat_m = fk.CreateActiveSkill{ name = "fastchat_m" }
local fastchat_f = fk.CreateActiveSkill{ name = "fastchat_f" }
Fk:addSkill(fastchat_m)
Fk:addSkill(fastchat_f)