From fdf2ccc75b6c0d00478074d0fc6caf1470c8d37a Mon Sep 17 00:00:00 2001 From: RalphRad <121930519+RalphRad@users.noreply.github.com> Date: Tue, 11 Jul 2023 21:15:38 +0800 Subject: [PATCH] standard fix (#221) --- packages/maneuvering/init.lua | 8 +- packages/standard/init.lua | 207 ++++++++++--------------- packages/standard_cards/i18n/en_US.lua | 5 +- packages/standard_cards/i18n/zh_CN.lua | 8 +- packages/standard_cards/init.lua | 166 ++++++++++---------- packages/test/init.lua | 2 +- 6 files changed, 186 insertions(+), 210 deletions(-) diff --git a/packages/maneuvering/init.lua b/packages/maneuvering/init.lua index f137a0b0..03599d6f 100644 --- a/packages/maneuvering/init.lua +++ b/packages/maneuvering/init.lua @@ -310,10 +310,10 @@ local fanSkill = fk.CreateTriggerSkill{ return target == player and player:hasSkill(self.name) and data.card.name == "slash" end, on_use = function(_, _, _, _, data) - local fireSlash = Fk:cloneCard("fire__slash") - fireSlash.skillName = "fan" - fireSlash:addSubcard(data.card) - data.card = fireSlash + local card = Fk:cloneCard("fire__slash") + card.skillName = "fan" + card:addSubcard(data.card) + data.card = card end, } Fk:addSkill(fanSkill) diff --git a/packages/standard/init.lua b/packages/standard/init.lua index f81ee459..f3f3b66c 100644 --- a/packages/standard/init.lua +++ b/packages/standard/init.lua @@ -11,16 +11,14 @@ local jianxiong = fk.CreateTriggerSkill{ events = {fk.Damaged}, can_trigger = function(self, event, target, player, data) local room = target.room - return data.card ~= nil and - target == player and - target:hasSkill(self.name) and not target.dead and + return target == player and player:hasSkill(self.name) and data.card and table.find(data.card:isVirtual() and data.card.subcards or {data.card.id}, function(id) return room:getCardArea(id) == Card.Processing end) end, on_use = function(self, event, target, player, data) local room = player.room local dummy = Fk:cloneCard("jueying") dummy:addSubcards(table.filter(data.card:isVirtual() and data.card.subcards or {data.card.id}, function(id) return room:getCardArea(id) == Card.Processing end)) - room:obtainCard(player.id, dummy, false) + room:obtainCard(player.id, dummy, false, fk.ReasonJustMove) end, } @@ -123,21 +121,24 @@ local fankui = fk.CreateTriggerSkill{ name = "fankui", anim_type = "masochism", events = {fk.Damaged}, - frequency = Skill.NotFrequent, can_trigger = function(self, event, target, player, data) - local room = target.room - local from = data.from - return from ~= nil and - target == player and - target:hasSkill(self.name) and - (not from:isNude()) and - not target.dead + if target == player and player:hasSkill(self.name) and data.from and not data.from.dead then + if data.from == player then + return #player.player_cards[Player.Equip] > 0 + else + return not data.from:isNude() + end + end end, on_use = function(self, event, target, player, data) local room = player.room local from = data.from - local card = room:askForCardChosen(player, from, "he", self.name) - room:obtainCard(player.id, card, false) + local flag = "he" + if from == player then + flag = "e" + end + local card = room:askForCardChosen(player, from, flag, self.name) + room:obtainCard(player.id, card, false, fk.ReasonPrey) end } local simayi = General:new(extension, "simayi", "wei", 3) @@ -149,21 +150,19 @@ local ganglie = fk.CreateTriggerSkill{ anim_type = "masochism", events = {fk.Damaged}, can_trigger = function(self, event, target, player, data) - return target == player and - target:hasSkill(self.name) and - not target.dead + return target == player and player:hasSkill(self.name) end, on_use = function(self, event, target, player, data) local room = player.room local from = data.from - if from then room:doIndicate(player.id, {from.id}) end + if from and not from.dead then room:doIndicate(player.id, {from.id}) end local judge = { who = player, reason = self.name, pattern = ".|.|^heart", } room:judge(judge) - if judge.card.suit ~= Card.Heart and from then + if judge.card.suit ~= Card.Heart and from and not from.dead then local discards = room:askForDiscard(from, 2, 2, false, self.name, true) if #discards == 0 then room:damage{ @@ -184,25 +183,13 @@ local tuxi = fk.CreateTriggerSkill{ anim_type = "control", events = {fk.EventPhaseStart}, can_trigger = function(self, event, target, player, data) - local ret = (target == player and player:hasSkill(self.name) and player.phase == Player.Draw) - if ret then - local room = player.room - for _, p in ipairs(room:getOtherPlayers(player)) do - if not p:isKongcheng() then - return true - end - end - end + return target == player and player:hasSkill(self.name) and player.phase == Player.Draw and + table.find(player.room:getOtherPlayers(player), function(p) return not p:isKongcheng() end) end, on_cost = function(self, event, target, player, data) local room = player.room - local other = room:getOtherPlayers(player) - local targets = {} - for _, p in ipairs(other) do - if not p:isKongcheng() then - table.insert(targets, p.id) - end - end + local targets = table.map(table.filter(room:getOtherPlayers(player), function(p) + return not p:isKongcheng() end), function (p) return p.id end) local result = room:askForChoosePlayers(player, targets, 1, 2, "#tuxi-ask", self.name) if #result > 0 then @@ -213,9 +200,12 @@ local tuxi = fk.CreateTriggerSkill{ on_use = function(self, event, target, player, data) local room = player.room for _, id in ipairs(self.cost_data) do + if player.dead then return end local p = room:getPlayerById(id) - local c = room:askForCardChosen(player, p, "h", self.name) - room:obtainCard(player.id, c, false) + if not p.dead then + local c = room:askForCardChosen(player, p, "h", self.name) + room:obtainCard(player.id, c, false, fk.ReasonPrey) + end end return true end, @@ -233,34 +223,38 @@ local luoyi = fk.CreateTriggerSkill{ on_use = function(self, event, target, player, data) data.n = data.n - 1 end, - - refresh_events = {fk.DamageCaused}, - can_refresh = function(self, event, target, player, data) - if target ~= player or player:usedSkillTimes(self.name) == 0 then - return - end - - if data.chain then return end - - local c = data.card - return c and c.trueName == "slash" or c.name == "duel" +} +local luoyi_trigger = fk.CreateTriggerSkill{ + name = "#luoyi_trigger", + mute = true, + events = {fk.DamageCaused}, + can_trigger = function(self, event, target, player, data) + return target == player and player:usedSkillTimes("luoyi", Player.HistoryTurn) > 0 and + not data.chain and data.card and (data.card.trueName == "slash" or data.card.name == "duel") end, - on_refresh = function(self, event, target, player, data) + on_cost = function(self, event, target, player, data) + return true + end, + on_use = function(self, event, target, player, data) local room = player.room - room:broadcastSkillInvoke(self.name) - room:notifySkillInvoked(player, self.name) + room:broadcastSkillInvoke("luoyi") + room:notifySkillInvoked(player, "luoyi") data.damage = data.damage + 1 end, } local xuchu = General:new(extension, "xuchu", "wei", 4) +luoyi:addRelatedSkill(luoyi_trigger) xuchu:addSkill(luoyi) local tiandu = fk.CreateTriggerSkill{ name = "tiandu", + anim_type = "drawcard", events = {fk.FinishJudge}, + can_trigger = function(self, event, target, player, data) + return target == player and player:hasSkill(self.name) and player.room:getCardArea(data.card) == Card.Processing + end, on_use = function(self, event, target, player, data) - local room = player.room - room:obtainCard(player.id, data.card) + player.room:obtainCard(player.id, data.card, true, fk.ReasonJustMove) end, } local yiji = fk.CreateTriggerSkill{ @@ -295,8 +289,7 @@ local luoshen = fk.CreateTriggerSkill{ anim_type = "drawcard", events = {fk.EventPhaseStart}, can_trigger = function(self, event, target, player, data) - return target == player and player:hasSkill(self.name) and - player.phase == Player.Start + return target == player and player:hasSkill(self.name) and player.phase == Player.Start end, on_use = function(self, event, target, player, data) local room = player.room @@ -304,28 +297,18 @@ local luoshen = fk.CreateTriggerSkill{ local judge = { who = player, reason = self.name, - pattern = ".|A~K|spade,club", + pattern = ".|.|spade,club", } room:judge(judge) if judge.card.color ~= Card.Black then break end - - if not room:askForSkillInvoke(player, self.name) then + room:obtainCard(player.id, judge.card, true, fk.ReasonJustMove) + if player.dead or not room:askForSkillInvoke(player, self.name) then break end end end, - - refresh_events = {fk.FinishJudge}, - can_refresh = function(self, event, target, player, data) - return target == player and player:hasSkill(self.name) and - data.reason == self.name and data.card.color == Card.Black - end, - on_refresh = function(self, event, target, player, data) - local room = player.room - room:obtainCard(player.id, data.card) - end, } local qingguo = fk.CreateViewAsSkill{ name = "qingguo", @@ -350,18 +333,6 @@ local zhenji = General:new(extension, "zhenji", "wei", 3, 3, General.Female) zhenji:addSkill(luoshen) zhenji:addSkill(qingguo) -local rendetrig = fk.CreateTriggerSkill{ - name = "#rendetrig", - mute = true, - refresh_events = {fk.EventPhaseStart}, - can_refresh = function(self, event, target, player, data) - return target == player and player:hasSkill(self.name) and player.phase == Player.NotActive - end, - on_refresh = function(self, event, target, player, data) - local room = player.room - room:setPlayerMark(player, "_rende_cards", 0) - end, -} local rende = fk.CreateActiveSkill{ name = "rende", anim_type = "support", @@ -377,21 +348,21 @@ local rende = fk.CreateActiveSkill{ local target = room:getPlayerById(effect.tos[1]) local player = room:getPlayerById(effect.from) local cards = effect.cards - local marks = player:getMark("_rende_cards") + local marks = player:getMark("_rende_cards-phase") local dummy = Fk:cloneCard'slash' dummy:addSubcards(cards) room:obtainCard(target.id, dummy, false, fk.ReasonGive) - room:addPlayerMark(player, "_rende_cards", #cards) + room:addPlayerMark(player, "_rende_cards-phase", #cards) if marks < 2 and marks + #cards >= 2 and player:isWounded() then room:recover{ who = player, num = 1, + recoverBy = player, skillName = self.name } end end, } -rende:addRelatedSkill(rendetrig) local jijiang = fk.CreateViewAsSkill{ name = "jijiang$", @@ -551,11 +522,7 @@ local kongchengAudio = fk.CreateTriggerSkill{ end, on_refresh = function(self, event, target, player, data) player.room:broadcastSkillInvoke("kongcheng") - player.room:doAnimate("InvokeSkill", { - name = "kongcheng", - player = player.id, - skill_type = "defensive", - }) + player.room:notifySkillInvoked(player, "kongcheng", "defensive") end, } local kongcheng = fk.CreateProhibitSkill{ @@ -563,7 +530,7 @@ local kongcheng = fk.CreateProhibitSkill{ frequency = Skill.Compulsory, is_prohibited = function(self, from, to, card) if to:hasSkill(self.name) and to:isKongcheng() then - return card.trueName == "slash" or card.name == "duel" + return card.trueName == "slash" or card.trueName == "duel" end end, } @@ -646,9 +613,7 @@ local jizhi = fk.CreateTriggerSkill{ anim_type = "drawcard", events = {fk.CardUsing}, can_trigger = function(self, event, target, player, data) - return target == player and player:hasSkill(self.name) and - data.card.type == Card.TypeTrick and - data.card.sub_type ~= Card.SubtypeDelayedTrick + return target == player and player:hasSkill(self.name) and data.card:isCommonTrick() end, on_use = function(self, event, target, player, data) player:drawCards(1, self.name) @@ -657,12 +622,8 @@ local jizhi = fk.CreateTriggerSkill{ local qicai = fk.CreateTargetModSkill{ name = "qicai", frequency = Skill.Compulsory, - bypass_distances = function(self, player, skill) - local card_name = string.sub(skill.name, 1, -7) -- assuming all card skill is named with name_skill - local card = Fk:cloneCard(card_name) - if player:hasSkill(self.name) and card.type == Card.TypeTrick then - return true - end + bypass_distances = function(self, player, skill, card) + return player:hasSkill(self.name) and card and card.type == Card.TypeTrick end, } local huangyueying = General:new(extension, "huangyueying", "shu", 3, 3, General.Female) @@ -673,14 +634,14 @@ local zhiheng = fk.CreateActiveSkill{ name = "zhiheng", anim_type = "drawcard", can_use = function(self, player) - return player:usedSkillTimes(self.name) == 0 + return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 end, target_num = 0, min_card_num = 1, on_use = function(self, room, effect) local from = room:getPlayerById(effect.from) - room:throwCard(effect.cards, self.name, from) - room:drawCards(from, #effect.cards, self.name) + room:throwCard(effect.cards, self.name, from, from) + from:drawCards(#effect.cards, self.name) end } @@ -776,7 +737,7 @@ local kurou = fk.CreateActiveSkill{ local from = room:getPlayerById(effect.from) room:loseHp(from, 1, self.name) if from:isAlive() then - room:drawCards(from, 2, self.name) + from:drawCards(2, self.name) end end } @@ -794,7 +755,7 @@ local yingzi = fk.CreateTriggerSkill{ local fanjian = fk.CreateActiveSkill{ name = "fanjian", can_use = function(self, player) - return player:usedSkillTimes(self.name) < 1 and not player:isKongcheng() + return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 and not player:isKongcheng() end, card_filter = function() return false end, target_filter = function(self, to_select, selected) @@ -806,7 +767,7 @@ local fanjian = fk.CreateActiveSkill{ local target = room:getPlayerById(effect.tos[1]) local choice = room:askForChoice(target, {"spade", "heart", "club", "diamond"}, self.name) local card = room:askForCardChosen(target, player, 'h', self.name) - room:obtainCard(target.id, card, true) + room:obtainCard(target.id, card, true, fk.ReasonPrey) if Fk:getCardById(card):getSuitString() ~= choice then room:damage{ from = player, @@ -860,8 +821,7 @@ local liuli = fk.CreateTriggerSkill{ on_cost = function(self, event, target, player, data) local room = player.room local prompt = "#liuli-target" - local plist, cid = room:askForChooseCardAndPlayers(player, - self.target_list, 1, 1, nil, prompt, self.name, true) + local plist, cid = room:askForChooseCardAndPlayers(player, self.target_list, 1, 1, nil, prompt, self.name, true) if #plist > 0 then self.cost_data = {plist[1], cid} return true @@ -947,14 +907,13 @@ local jieyin = fk.CreateActiveSkill{ name = "jieyin", anim_type = "support", can_use = function(self, player) - return player:usedSkillTimes(self.name) == 0 + return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 end, card_filter = function(self, to_select, selected) return #selected < 2 and Fk:currentRoom():getCardArea(to_select) ~= Player.Equip end, target_filter = function(self, to_select, selected) local target = Fk:currentRoom():getPlayerById(to_select) - local name = target.general return target:isWounded() and target.gender == General.Male and #selected < 1 @@ -963,18 +922,18 @@ local jieyin = fk.CreateActiveSkill{ card_num = 2, on_use = function(self, room, effect) local from = room:getPlayerById(effect.from) - room:throwCard(effect.cards, self.name, from) + room:throwCard(effect.cards, self.name, from, from) room:recover({ who = room:getPlayerById(effect.tos[1]), num = 1, - recoverBy = effect.from, + recoverBy = room:getPlayerById(effect.from), skillName = self.name }) if from:isWounded() then room:recover({ who = room:getPlayerById(effect.from), num = 1, - recoverBy = effect.from, + recoverBy = room:getPlayerById(effect.from), skillName = self.name }) end @@ -988,7 +947,7 @@ local qingnang = fk.CreateActiveSkill{ name = "qingnang", anim_type = "support", can_use = function(self, player) - return player:usedSkillTimes(self.name) == 0 + return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 end, card_filter = function(self, to_select, selected, targets) return #selected == 0 and Fk:currentRoom():getCardArea(to_select) ~= Player.Equip @@ -1000,11 +959,11 @@ local qingnang = fk.CreateActiveSkill{ card_num = 1, on_use = function(self, room, effect) local from = room:getPlayerById(effect.from) - room:throwCard(effect.cards, self.name, from) + room:throwCard(effect.cards, self.name, from, from) room:recover({ who = room:getPlayerById(effect.tos[1]), num = 1, - recoverBy = effect.from, + recoverBy = room:getPlayerById(effect.from), skillName = self.name }) end, @@ -1050,7 +1009,7 @@ local wushuang = fk.CreateTriggerSkill{ if event == fk.TargetSpecified then return target == player and table.contains({ "slash", "duel" }, data.card.trueName) else - return data.to == player.id and data.card.name == "duel" + return data.to == player.id and data.card.trueName == "duel" end end, on_use = function(self, event, target, player, data) @@ -1071,7 +1030,7 @@ local lijian = fk.CreateActiveSkill{ name = "lijian", anim_type = "offensive", can_use = function(self, player) - return player:usedSkillTimes(self.name) == 0 + return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 end, card_filter = function(self, to_select, selected) return #selected == 0 @@ -1083,14 +1042,16 @@ local lijian = fk.CreateActiveSkill{ target_num = 2, min_card_num = 1, on_use = function(self, room, use) - room:throwCard(use.cards, self.name, room:getPlayerById(use.from)) + local player = room:getPlayerById(use.from) + room:throwCard(use.cards, self.name, player, player) local duel = Fk:cloneCard("duel") duel.skillName = self.name - local new_use = {} ---@type CardUseStruct - new_use.from = use.tos[2] - new_use.tos = { { use.tos[1] } } - new_use.card = duel - new_use.prohibitedCardNames = { "nullification" } + local new_use = { ---@type CardUseStruct + from = use.tos[2], + tos = { { use.tos[1] } }, + card = duel, + prohibitedCardNames = { "nullification" }, + } room:useCard(new_use) end, } @@ -1103,7 +1064,7 @@ local biyue = fk.CreateTriggerSkill{ and player.phase == Player.Finish end, on_use = function(self, event, target, player, data) - player:drawCards(1) + player:drawCards(1, self.name) end, } local diaochan = General:new(extension, "diaochan", "qun", 3, 3, General.Female) diff --git a/packages/standard_cards/i18n/en_US.lua b/packages/standard_cards/i18n/en_US.lua index 150717ed..0b77c756 100644 --- a/packages/standard_cards/i18n/en_US.lua +++ b/packages/standard_cards/i18n/en_US.lua @@ -31,6 +31,7 @@ Fk:loadTranslationTable({ ["duel"] = "Duel", ["collateral"] = "Collateral", + ["#collateral-slash"] = "Collateral:You shall play Slash to %dest , or %src obtain your weapon", ["ex_nihilo"] = "Ex Nihilo", @@ -57,16 +58,18 @@ Fk:loadTranslationTable({ ["double_swords"] = "Double Sword", ["#double_swords_skill"] = "Double Sword", + ["#double_swords-invoke"] = "Double Sword:You shall discard 1 handcard,or %src draw 1", ["blade"] = "Blade", ["#blade_skill"] = "Blade", - ["#blade_slash"] = "You can use Blade to use Slash to %src again", + ["#blade_slash"] = "Blade: You may use Slash to %src again", ["spear"] = "Spear", ["spear_skill"] = "Spear", ["axe"] = "Axe", ["#axe_skill"] = "Axe", + ["#axe-invoke"] = "Axe:You may discard 2 cards to ensure your Slash effective to %dest", ["halberd"] = "Halberd", diff --git a/packages/standard_cards/i18n/zh_CN.lua b/packages/standard_cards/i18n/zh_CN.lua index 04f8aa2e..8d3e946d 100644 --- a/packages/standard_cards/i18n/zh_CN.lua +++ b/packages/standard_cards/i18n/zh_CN.lua @@ -68,6 +68,7 @@ Fk:loadTranslationTable{ ["collateral"] = "借刀杀人", [":collateral"] = "锦囊牌
时机:出牌阶段
目标:装备区内有武器牌且攻击范围内有【杀】的合法目标的一名其他角色A(你需要选择一名A攻击范围内的【杀】的合法目标B)
效果:A须对B使用一张【杀】,否则你获得A装备区内的武器牌。", + ["#collateral-slash"] = "借刀杀人:你需对 %dest 使用【杀】,否则 %src 获得你的武器", ["ex_nihilo"] = "无中生有", [":ex_nihilo"] = "锦囊牌
时机:出牌阶段
目标:你
效果:目标角色摸两张牌。", @@ -87,6 +88,7 @@ Fk:loadTranslationTable{ ["amazing_grace"] = "五谷丰登", [":amazing_grace"] = "锦囊牌
时机:出牌阶段
目标:所有角色
效果:你亮出牌堆顶等于角色数的牌,每名目标角色获得其中一张牌,然后将其余的牌置入弃牌堆。", ["amazing_grace_skill"] = "五谷选牌", + ["Please choose cards"] = "请选择一张卡牌", ["lightning"] = "闪电", [":lightning"] = "延时锦囊牌
时机:出牌阶段
目标:你
效果:将此牌置于目标角色判定区内。其判定阶段进行判定:若结果为黑桃2-9,其受到3点雷电伤害并将【闪电】置入弃牌堆,否则将【闪电】移动至其下家判定区内。", @@ -107,11 +109,12 @@ Fk:loadTranslationTable{ ["double_swords"] = "雌雄双股剑", [":double_swords"] = "装备牌·武器
攻击范围:2
武器技能:每当你指定异性角色为【杀】的目标后,你可以令其选择一项:弃置一张手牌,或令你摸一张牌。", ["#double_swords_skill"] = "雌雄双股剑", + ["#double_swords-invoke"] = "雌雄双股剑:你需弃置一张手牌,否则 %src 摸一张牌", ["blade"] = "青龙偃月刀", [":blade"] = "装备牌·武器
攻击范围:3
武器技能:每当你使用的【杀】被【闪】抵消后,你可以对该角色再使用一张【杀】(无距离限制且不能选择额外目标)。", ["#blade_skill"] = "青龙偃月刀", - ["#blade_slash"] = "你可以发动“青龙偃月刀”对 %src 再使用一张杀", + ["#blade_slash"] = "青龙偃月刀:你可以对 %src 再使用一张【杀】", ["spear"] = "丈八蛇矛", [":spear"] = "装备牌·武器
攻击范围:3
武器技能:你可以将两张手牌当【杀】使用或打出。", @@ -121,6 +124,7 @@ Fk:loadTranslationTable{ ["axe"] = "贯石斧", [":axe"] = "装备牌·武器
攻击范围:3
武器技能:每当你使用的【杀】被【闪】抵消后,你可以弃置两张牌,则此【杀】继续造成伤害。", ["#axe_skill"] = "贯石斧", + ["#axe-invoke"] = "贯石斧:你可以弃置两张牌,令你对 %dest 使用的【杀】依然生效", ["halberd"] = "方天画戟", [":halberd"] = "装备牌·武器
攻击范围:4
武器技能:锁定技。你使用最后的手牌【杀】可以额外选择至多两名目标。", @@ -134,7 +138,7 @@ Fk:loadTranslationTable{ ["#eight_diagram_skill"] = "八卦阵", ["nioh_shield"] = "仁王盾", - [":nioh_shield"] = "装备牌·防具
防具技能:锁定技。黑色【杀】对你无效。", + [":nioh_shield"] = "装备牌·防具
防具技能:锁定技,黑色【杀】对你无效。", ["dilu"] = "的卢", [":dilu"] = "装备牌·坐骑
坐骑技能:其他角色与你的距离+1。", diff --git a/packages/standard_cards/init.lua b/packages/standard_cards/init.lua index 8898e806..1a6a47e1 100644 --- a/packages/standard_cards/init.lua +++ b/packages/standard_cards/init.lua @@ -61,17 +61,18 @@ local slashSkill = fk.CreateActiveSkill{ end end, on_effect = function(self, room, effect) - local to = effect.to - local from = effect.from - - room:damage({ - from = room:getPlayerById(from), - to = room:getPlayerById(to), - card = effect.card, - damage = 1, - damageType = fk.NormalDamage, - skillName = self.name - }) + local from = room:getPlayerById(effect.from) + local to = room:getPlayerById(effect.to) + if not to.dead then + room:damage({ + from = from, + to = to, + card = effect.card, + damage = 1, + damageType = fk.NormalDamage, + skillName = self.name + }) + end end } local slash = fk.CreateBasicCard{ @@ -166,16 +167,17 @@ local peachSkill = fk.CreateActiveSkill{ end end, on_effect = function(self, room, effect) - local to = effect.to - local from = effect.from - - room:recover({ - who = room:getPlayerById(to), - num = 1, - card = effect.card, - recoverBy = room:getPlayerById(from), - skillName = self.name - }) + local player = room:getPlayerById(effect.from) + local target = room:getPlayerById(effect.to) + if target:isWounded() and not target.dead then + room:recover({ + who = target, + num = 1, + card = effect.card, + recoverBy = player, + skillName = self.name + }) + end end } local peach = fk.CreateBasicCard{ @@ -206,17 +208,11 @@ local dismantlementSkill = fk.CreateActiveSkill{ end end, on_effect = function(self, room, effect) - local to = room:getPlayerById(effect.to) - if to:isAllNude() then return end local from = room:getPlayerById(effect.from) - local cid = room:askForCardChosen( - from, - to, - "hej", - self.name - ) - - room:throwCard(cid, self.name, to, from) + local to = room:getPlayerById(effect.to) + if to.dead or to:isAllNude() then return end + local cid = room:askForCardChosen(from, to, "hej", self.name) + room:throwCard({cid}, self.name, to, from) end } local dismantlement = fk.CreateTrickCard{ @@ -251,17 +247,11 @@ local snatchSkill = fk.CreateActiveSkill{ end, target_num = 1, on_effect = function(self, room, effect) + local from = room:getPlayerById(effect.from) local to = room:getPlayerById(effect.to) - local from = effect.from - if to:isAllNude() then return end - local cid = room:askForCardChosen( - room:getPlayerById(from), - to, - "hej", - self.name - ) - - room:obtainCard(from, cid) + if to.dead or to:isAllNude() then return end + local cid = room:askForCardChosen(from, to, "hej", self.name) + room:obtainCard(from, cid, false, fk.ReasonPrey) end } local snatch = fk.CreateTrickCard{ @@ -379,11 +369,14 @@ local collateralSkill = fk.CreateActiveSkill{ end, on_effect = function(self, room, effect) local to = room:getPlayerById(effect.to) - if not to:getEquipment(Card.SubtypeWeapon) then return end - local use = room:askForUseCard(to, "slash", nil, nil, nil, - { must_targets = effect.subTargets }, effect) - + if to.dead or not to:getEquipment(Card.SubtypeWeapon) then return end + local prompt = "#collateral-slash:"..effect.from..":"..effect.subTargets[1] + if #effect.subTargets > 1 then + prompt = nil + end + local use = room:askForUseCard(to, "slash", nil, prompt, nil, { must_targets = effect.subTargets }, effect) if use then + use.extraUse = true room:useCard(use) else room:obtainCard(effect.from, @@ -411,8 +404,10 @@ local exNihiloSkill = fk.CreateActiveSkill{ cardUseEvent.tos = { { cardUseEvent.from } } end end, - on_effect = function(self, room, cardEffectEvent) - room:drawCards(room:getPlayerById(cardEffectEvent.to), 2, "ex_nihilo") + on_effect = function(self, room, effect) + local target = room:getPlayerById(effect.to) + if target.dead then return end + target:drawCards(2, "ex_nihilo") end } local exNihilo = fk.CreateTrickCard{ @@ -542,12 +537,17 @@ local godSalvationSkill = fk.CreateActiveSkill{ end end, on_effect = function(self, room, effect) - room:recover({ - who = room:getPlayerById(effect.to), - num = 1, - recoverBy = room:getPlayerById(effect.from), - skillName = self.name, - }) + local player = room:getPlayerById(effect.from) + local target = room:getPlayerById(effect.to) + if target:isWounded() and not target.dead then + room:recover({ + who = target, + num = 1, + recoverBy = player, + card = effect.card, + skillName = self.name, + }) + end end } local godSalvation = fk.CreateTrickCard{ @@ -765,9 +765,8 @@ local crossbowAudio = fk.CreateTriggerSkill{ name = "#crossbowAudio", refresh_events = {fk.CardUsing}, can_refresh = function(self, event, target, player, data) - return target == player and player:hasSkill(self.name) and - data.card.trueName == "slash" and - player:usedCardTimes("slash") > 1 + return target == player and player:hasSkill(self.name) and player.phase == Player.Play and + data.card.trueName == "slash" and player:usedCardTimes("slash", Player.HistoryPhase) > 1 end, on_refresh = function(self, event, target, player, data) local room = player.room @@ -807,10 +806,13 @@ local armorInvalidity = fk.CreateInvaliditySkill { name = "armor_invalidity", global = true, invalidity_func = function(self, from, skill) - return - from:getMark(fk.MarkArmorNullified) > 0 and - from:getEquipment(Card.SubtypeArmor) ~= nil and - skill.attached_equip == Fk:getCardById(from:getEquipment(Card.SubtypeArmor)).name + if from:getMark(fk.MarkArmorNullified) > 0 and skill.attached_equip then + for _, card in ipairs(Fk.cards) do + if card.sub_type == Card.SubtypeArmor and skill.attached_equip == card.name then + return true + end + end + end end } Fk:addSkill(armorInvalidity) @@ -875,9 +877,9 @@ local iceSwordSkill = fk.CreateTriggerSkill{ local room = player.room local to = data.to for i = 1, 2 do - if to:isNude() then break end + if player.dead or to.dead or to:isNude() then break end local card = room:askForCardChosen(player, to, "he", self.name) - room:throwCard(card, self.name, to, player) + room:throwCard({card}, self.name, to, player) end return true end @@ -908,9 +910,13 @@ local doubleSwordsSkill = fk.CreateTriggerSkill{ on_use = function(self, event, target, player, data) local room = player.room local to = player.room:getPlayerById(data.to) - local result = room:askForDiscard(to, 1, 1, false, self.name, true) - if #result == 0 then + if to:isKongcheng() then player:drawCards(1, self.name) + else + local result = room:askForDiscard(to, 1, 1, false, self.name, true, ".", "#double_swords-invoke:"..player.id) + if #result == 0 then + player:drawCards(1, self.name) + end end end, } @@ -997,31 +1003,33 @@ extension:addCards({ spear, }) -local axeProhibit = fk.CreateProhibitSkill{ - name = "#axe_prohibit", - prohibit_discard = function(self, player, card) - return player:hasSkill(self.name) and card and card.name == "axe" and - Fk.currentResponseReason == "#axe_skill" and - Fk:currentRoom():getCardArea(card.id) == Player.Equip - end, -} local axeSkill = fk.CreateTriggerSkill{ name = "#axe_skill", attached_equip = "axe", events = {fk.CardEffectCancelledOut}, can_trigger = function(self, event, target, player, data) - if not player:hasSkill(self.name) then return end - local effect = data ---@type CardEffectEvent - return effect.card.trueName == "slash" and effect.from == player.id + return player:hasSkill(self.name) and data.from == player.id and data.card.trueName == "slash" end, on_cost = function(self, event, target, player, data) local room = player.room - local ret = room:askForDiscard(player, 2, 2, true, self.name, true) - if #ret > 0 then return true end + local pattern + if player:getEquipment(Card.SubtypeWeapon) then + pattern = ".|.|.|.|.|.|^"..tostring(player:getEquipment(Card.SubtypeWeapon)) + else + pattern = "." + end + local cards = room:askForDiscard(player, 2, 2, true, self.name, true, pattern, "#axe-invoke::"..data.to, true) + if #cards > 0 then + self.cost_data = cards + return true + end + end, + on_use = function(self, event, target, player, data) + local room = player.room + room:throwCard(self.cost_data, "axe", player, player) + return true end, - on_use = function() return true end, } -axeSkill:addRelatedSkill(axeProhibit) Fk:addSkill(axeSkill) local axe = fk.CreateWeapon{ name = "axe", diff --git a/packages/test/init.lua b/packages/test/init.lua index e96c47ec..21b69ba2 100644 --- a/packages/test/init.lua +++ b/packages/test/init.lua @@ -262,7 +262,7 @@ test2.shield = 5 test2:addSkill("rende") test2:addSkill(cheat) test2:addSkill(control) -test2:addSkill(test_vs) +--test2:addSkill(test_vs) --test2:addSkill(test_trig) test2:addSkill(damage_maker) test2:addSkill(change_hero)