diff --git a/lua/core/player.lua b/lua/core/player.lua index 26f55d49..38e8fe71 100644 --- a/lua/core/player.lua +++ b/lua/core/player.lua @@ -834,7 +834,8 @@ function Player:isProhibited(to, card) return true end - if card.sub_type == Card.SubtypeDelayedTrick and table.contains(to.sealedSlots, Player.JudgeSlot) then + if card.sub_type == Card.SubtypeDelayedTrick and + (table.contains(to.sealedSlots, Player.JudgeSlot) or to:hasDelayedTrick(card.name)) then return true end diff --git a/lua/fk_ex.lua b/lua/fk_ex.lua index 006ce852..360b4c71 100644 --- a/lua/fk_ex.lua +++ b/lua/fk_ex.lua @@ -440,8 +440,11 @@ local defaultCardSkill = fk.CreateActiveSkill{ local defaultEquipSkill = fk.CreateActiveSkill{ name = "default_equip_skill", + mod_target_filter = function(self, to_select, selected, user, card, distance_limited) + return #Fk:currentRoom():getPlayerById(to_select):getAvailableEquipSlots(card.sub_type) > 0 + end, can_use = function(self, player, card) - return #player:getAvailableEquipSlots(card.sub_type) > 0 + return self:modTargetFilter(player.id, {}, player.id, card, true) and not player:isProhibited(player, card) end, on_use = function(self, room, use) if not use.tos or #TargetGroup:getRealTargets(use.tos) == 0 then diff --git a/packages/maneuvering/init.lua b/packages/maneuvering/init.lua index 5a1e9ebe..1792f34f 100644 --- a/packages/maneuvering/init.lua +++ b/packages/maneuvering/init.lua @@ -250,15 +250,13 @@ extension:addCards{ local supplyShortageSkill = fk.CreateActiveSkill{ name = "supply_shortage_skill", distance_limit = 1, + mod_target_filter = function(self, to_select, selected, user, card, distance_limited) + local player = Fk:currentRoom():getPlayerById(to_select) + local from = Fk:currentRoom():getPlayerById(user) + return from ~= player and not (distance_limited and not self:withinDistanceLimit(from, false, card, player)) + end, target_filter = function(self, to_select, selected, _, card) - if #selected == 0 then - local player = Fk:currentRoom():getPlayerById(to_select) - if Self ~= player then - return not player:hasDelayedTrick("supply_shortage") and - self:withinDistanceLimit(Self, false, card, player) - end - end - return false + return #selected == 0 and self:modTargetFilter(to_select, selected, Self.id, card, true) end, target_num = 1, on_effect = function(self, room, effect) diff --git a/packages/standard/game_rule.lua b/packages/standard/game_rule.lua index 4510af08..ca4a826a 100644 --- a/packages/standard/game_rule.lua +++ b/packages/standard/game_rule.lua @@ -40,22 +40,20 @@ GameRule = fk.CreateTriggerSkill{ [fk.AskForPeaches] = function() local dyingPlayer = room:getPlayerById(data.who) while dyingPlayer.hp < 1 do - local pattern = "peach" + local cardNames = {"peach"} local prompt = "#AskForPeaches:" .. dyingPlayer.id .. "::" .. tostring(1 - dyingPlayer.hp) if player == dyingPlayer then - pattern = pattern .. ",analeptic" + table.insert(cardNames, "analeptic") prompt = "#AskForPeachesSelf:::" .. tostring(1 - dyingPlayer.hp) end - local cardNames = pattern:split(",") - for _, cardName in ipairs(cardNames) do + cardNames = table.filter(cardNames, function (cardName) local cardCloned = Fk:cloneCard(cardName) - if player:prohibitUse(cardCloned) or player:isProhibited(dyingPlayer, cardCloned) then - return - end - end + return not (player:prohibitUse(cardCloned) or player:isProhibited(dyingPlayer, cardCloned)) + end) + if #cardNames == 0 then return end - local peach_use = room:askForUseCard(player, "peach", pattern, prompt) + local peach_use = room:askForUseCard(player, "peach", table.concat(cardNames, ",") , prompt) if not peach_use then break end peach_use.tos = { {dyingPlayer.id} } if peach_use.card.trueName == "analeptic" then diff --git a/packages/standard_cards/init.lua b/packages/standard_cards/init.lua index 842a3750..76a2f836 100644 --- a/packages/standard_cards/init.lua +++ b/packages/standard_cards/init.lua @@ -129,8 +129,8 @@ local peachSkill = fk.CreateActiveSkill{ return p.dying end) end, - can_use = function(self, player) - return player:isWounded() + can_use = function(self, player, card) + return player:isWounded() and not player:isProhibited(player, card) end, on_use = function(self, room, use) if not use.tos or #TargetGroup:getRealTargets(use.tos) == 0 then @@ -383,6 +383,9 @@ local exNihiloSkill = fk.CreateActiveSkill{ mod_target_filter = function(self, to_select, selected, user, card, distance_limited) return true end, + can_use = function(self, player, card) + return not player:isProhibited(player, card) + end, on_use = function(self, room, cardUseEvent) if not cardUseEvent.tos or #TargetGroup:getRealTargets(cardUseEvent.tos) == 0 then cardUseEvent.tos = { { cardUseEvent.from } } @@ -647,8 +650,11 @@ extension:addCards({ local lightningSkill = fk.CreateActiveSkill{ name = "lightning_skill", - can_use = function(self, player) - return not (Self:hasDelayedTrick("lightning") or table.contains(player.sealedSlots, Player.JudgeSlot)) + mod_target_filter = function(self, to_select, selected, user, card, distance_limited) + return true + end, + can_use = function(self, player, card) + return not player:isProhibited(player, card) end, on_use = function(self, room, use) if not use.tos or #TargetGroup:getRealTargets(use.tos) == 0 then @@ -717,14 +723,11 @@ extension:addCards({ local indulgenceSkill = fk.CreateActiveSkill{ name = "indulgence_skill", - target_filter = function(self, to_select, selected) - if #selected == 0 then - local player = Fk:currentRoom():getPlayerById(to_select) - if Self ~= player then - return not player:hasDelayedTrick("indulgence") - end - end - return false + mod_target_filter = function(self, to_select, selected, user, card, distance_limited) + return user ~= to_select + end, + target_filter = function(self, to_select, selected, _, card) + return #selected == 0 and self:modTargetFilter(to_select, selected, Self.id, card, true) end, target_num = 1, on_effect = function(self, room, effect)