mirror of
https://github.com/Qsgs-Fans/FreeKill.git
synced 2024-11-16 11:42:45 +08:00
fixup Amazing Grace and afterUse
This commit is contained in:
parent
bd723c02f1
commit
9815c6d9e2
|
@ -164,6 +164,20 @@ GameEvent.functions[GameEvent.UseCard] = function(self)
|
|||
local room = self.room
|
||||
local logic = room.logic
|
||||
|
||||
if type(cardUseEvent.attachedSkillAndUser) == "table" then
|
||||
local attachedSkillAndUser = table.simpleClone(cardUseEvent.attachedSkillAndUser)
|
||||
self:addExitFunc(function()
|
||||
if
|
||||
type(attachedSkillAndUser) == "table" and
|
||||
Fk.skills[attachedSkillAndUser.skillName] and
|
||||
Fk.skills[attachedSkillAndUser.skillName].afterUse
|
||||
then
|
||||
Fk.skills[attachedSkillAndUser.skillName]:afterUse(room:getPlayerById(attachedSkillAndUser.user), cardUseEvent)
|
||||
end
|
||||
end)
|
||||
cardUseEvent.attachedSkillAndUser = nil
|
||||
end
|
||||
|
||||
if cardUseEvent.card.skill then
|
||||
cardUseEvent.card.skill:onUse(room, cardUseEvent)
|
||||
end
|
||||
|
|
|
@ -2423,23 +2423,7 @@ end
|
|||
---@param cardUseEvent CardUseStruct @ 使用数据
|
||||
---@return boolean
|
||||
function Room:useCard(cardUseEvent)
|
||||
local attachedSkillAndUser
|
||||
if type(cardUseEvent.attachedSkillAndUser) == "table" then
|
||||
attachedSkillAndUser = table.simpleClone(cardUseEvent.attachedSkillAndUser)
|
||||
cardUseEvent.attachedSkillAndUser = nil
|
||||
end
|
||||
|
||||
local ret = execGameEvent(GameEvent.UseCard, cardUseEvent)
|
||||
|
||||
if
|
||||
type(attachedSkillAndUser) == "table" and
|
||||
Fk.skills[attachedSkillAndUser.skillName] and
|
||||
Fk.skills[attachedSkillAndUser.skillName].afterUse
|
||||
then
|
||||
Fk.skills[attachedSkillAndUser.skillName]:afterUse(self:getPlayerById(attachedSkillAndUser.user), cardUseEvent)
|
||||
end
|
||||
|
||||
return ret
|
||||
return execGameEvent(GameEvent.UseCard, cardUseEvent)
|
||||
end
|
||||
|
||||
---@param room Room
|
||||
|
@ -2686,6 +2670,7 @@ function Room:doCardUseEffect(cardUseEvent)
|
|||
for i = 1, (cardUseEvent.additionalEffect or 0) + 1 do
|
||||
if #TargetGroup:getRealTargets(cardUseEvent.tos) > 0 and cardUseEvent.card.skill.onAction then
|
||||
cardUseEvent.card.skill:onAction(self, cardUseEvent)
|
||||
cardEffectEvent.extra_data = cardUseEvent.extra_data
|
||||
end
|
||||
|
||||
-- Else: do effect to all targets
|
||||
|
|
|
@ -21,7 +21,7 @@ local slashSkill = fk.CreateActiveSkill{
|
|||
max_phase_use_time = 1,
|
||||
target_num = 1,
|
||||
can_use = function(self, player, card, extra_data)
|
||||
return (extra_data and extra_data.bypass_times) or
|
||||
return (extra_data and extra_data.bypass_times) or player.phase ~= Player.Play or
|
||||
table.find(Fk:currentRoom().alive_players, function(p)
|
||||
return self:withinTimesLimit(player, Player.HistoryPhase, card, "slash", p)
|
||||
end)
|
||||
|
@ -36,7 +36,12 @@ local slashSkill = fk.CreateActiveSkill{
|
|||
if #selected < self:getMaxTargetNum(Self, card) then
|
||||
local player = Fk:currentRoom():getPlayerById(to_select)
|
||||
return self:modTargetFilter(to_select, selected, Self.id, card, count_distances) and
|
||||
(#selected > 0 or (extra_data and extra_data.bypass_times) or self:withinTimesLimit(Self, Player.HistoryPhase, card, "slash", player))
|
||||
(
|
||||
#selected > 0 or
|
||||
Self.phase ~= Player.Play or
|
||||
(extra_data and extra_data.bypass_times) or
|
||||
self:withinTimesLimit(Self, Player.HistoryPhase, card, "slash", player)
|
||||
)
|
||||
end
|
||||
end,
|
||||
on_effect = function(self, room, effect)
|
||||
|
@ -660,60 +665,6 @@ local amazingGraceSkill = fk.CreateActiveSkill{
|
|||
end
|
||||
}
|
||||
|
||||
local amazingGraceAction = fk.CreateTriggerSkill{
|
||||
name = "amazing_grace_action",
|
||||
global = true,
|
||||
priority = { [fk.BeforeCardUseEffect] = 0, [fk.CardUseFinished] = 10 }, -- game rule
|
||||
events = { fk.BeforeCardUseEffect, fk.CardUseFinished },
|
||||
can_trigger = function(self, event, target, player, data)
|
||||
local frameFilled = data.extra_data and data.extra_data.AGFilled
|
||||
if event == fk.BeforeCardUseEffect then
|
||||
return data.card.trueName == 'amazing_grace' and not frameFilled
|
||||
else
|
||||
return frameFilled
|
||||
end
|
||||
end,
|
||||
on_trigger = function(self, event, target, player, data)
|
||||
local room = player.room
|
||||
if event == fk.BeforeCardUseEffect then
|
||||
local toDisplay = room:getNCards(#TargetGroup:getRealTargets(data.tos))
|
||||
room:moveCards({
|
||||
ids = toDisplay,
|
||||
toArea = Card.Processing,
|
||||
moveReason = fk.ReasonPut,
|
||||
})
|
||||
|
||||
table.forEach(room.players, function(p)
|
||||
room:fillAG(p, toDisplay)
|
||||
end)
|
||||
|
||||
data.extra_data = data.extra_data or {}
|
||||
data.extra_data.AGFilled = toDisplay
|
||||
else
|
||||
table.forEach(room.players, function(p)
|
||||
room:closeAG(p)
|
||||
end)
|
||||
|
||||
if data.extra_data and data.extra_data.AGFilled then
|
||||
local toDiscard = table.filter(data.extra_data.AGFilled, function(id)
|
||||
return room:getCardArea(id) == Card.Processing
|
||||
end)
|
||||
|
||||
if #toDiscard > 0 then
|
||||
room:moveCards({
|
||||
ids = toDiscard,
|
||||
toArea = Card.DiscardPile,
|
||||
moveReason = fk.ReasonPutIntoDiscardPile,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
data.extra_data.AGFilled = nil
|
||||
end
|
||||
end,
|
||||
}
|
||||
Fk:addSkill(amazingGraceAction)
|
||||
|
||||
local amazingGrace = fk.CreateTrickCard{
|
||||
name = "amazing_grace",
|
||||
suit = Card.Heart,
|
||||
|
|
Loading…
Reference in New Issue
Block a user