1、修正标准版武将、卡牌结算
This commit is contained in:
xxyheaven 2023-12-03 00:21:52 +08:00 committed by GitHub
parent 2ecaefb642
commit 041d5835ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 126 additions and 146 deletions

View File

@ -21,48 +21,23 @@ local jianxiong = fk.CreateTriggerSkill{
end, end,
} }
local hujia = fk.CreateViewAsSkill{ local hujia = fk.CreateTriggerSkill{
name = "hujia$", name = "hujia$",
anim_type = "defensive", anim_type = "defensive",
pattern = "jink", events = {fk.AskForCardUse, fk.AskForCardResponse},
card_filter = function(self, to_select, selected)
return false
end,
view_as = function(self, cards)
if #cards ~= 0 then
return nil
end
local c = Fk:cloneCard("jink")
c.skillName = self.name
return c
end,
enabled_at_play = function(self, player)
return false
end,
enabled_at_response = function(self, player)
return not table.every(Fk:currentRoom().alive_players, function(p)
return p == player or p.kingdom ~= "wei"
end)
end,
}
local hujiaResponse = fk.CreateTriggerSkill{
name = "#hujiaResponse",
events = {fk.PreCardUse, fk.PreCardRespond},
mute = true,
priority = 10,
can_trigger = function(self, event, target, player, data) can_trigger = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name, true) and table.contains(data.card.skillNames, "hujia") return target == player and player:hasSkill(self) and
end, (data.cardName == "jink" or (data.pattern and Exppattern:Parse(data.pattern):matchExp("jink|0|nosuit|none"))) and
on_cost = function(self, event, target, player, data) (data.extraData == nil or data.extraData.hujia_ask == nil) and
local room = player.room not table.every(player.room.alive_players, function(p)
room:doIndicate(player.id, TargetGroup:getRealTargets(data.tos)) return p == player or p.kingdom ~= "wei"
return true end)
end, end,
on_use = function(self, event, target, player, data) on_use = function(self, event, target, player, data)
local room = player.room local room = player.room
for _, p in ipairs(room:getOtherPlayers(player)) do for _, p in ipairs(room:getOtherPlayers(player)) do
if p.kingdom == "wei" then if p:isAlive() and p.kingdom == "wei" then
local cardResponded = room:askForResponse(p, "jink", "jink", "#hujia-ask:" .. player.id, true) local cardResponded = room:askForResponse(p, "jink", "jink", "#hujia-ask:" .. player.id, true, {hujia_ask = true})
if cardResponded then if cardResponded then
room:responseCard({ room:responseCard({
from = p.id, from = p.id,
@ -70,26 +45,29 @@ local hujiaResponse = fk.CreateTriggerSkill{
skipDrop = true, skipDrop = true,
}) })
data.card = cardResponded if event == fk.AskForCardUse then
return false data.result = {
from = player.id,
card = Fk:cloneCard('jink'),
}
data.result.card:addSubcards(room:getSubcardsByRule(cardResponded, { Card.Processing }))
data.result.card.skillName = self.name
if data.eventData then
data.result.toCard = data.eventData.toCard
data.result.responseToEvent = data.eventData.responseToEvent
end
else
data.result = Fk:cloneCard('jink')
data.result:addSubcards(room:getSubcardsByRule(cardResponded, { Card.Processing }))
data.result.skillName = self.name
end
return true
end end
end end
end end
if event == fk.PreCardUse and player.phase == Player.Play then
room:setPlayerMark(player, "hujia-failed-phase", 1)
end
return true
end,
refresh_events = {fk.CardUsing},
can_refresh = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name, true) and player:getMark("hujia-failed-phase") > 0
end,
on_refresh = function(self, event, target, player, data)
player.room:setPlayerMark(player, "hujia-failed-phase", 0)
end, end,
} }
hujia:addRelatedSkill(hujiaResponse)
local caocao = General:new(extension, "caocao", "wei", 4) local caocao = General:new(extension, "caocao", "wei", 4)
caocao:addSkill(jianxiong) caocao:addSkill(jianxiong)
@ -112,8 +90,7 @@ local guicai = fk.CreateTriggerSkill{
end end
end, end,
on_use = function(self, event, target, player, data) on_use = function(self, event, target, player, data)
local room = player.room player.room:retrial(self.cost_data, player, data, self.name)
room:retrial(self.cost_data, player, data, self.name)
end, end,
} }
local fankui = fk.CreateTriggerSkill{ local fankui = fk.CreateTriggerSkill{
@ -259,8 +236,8 @@ local yiji = fk.CreateTriggerSkill{
events = {fk.Damaged}, events = {fk.Damaged},
on_trigger = function(self, event, target, player, data) on_trigger = function(self, event, target, player, data)
self.cancel_cost = false self.cancel_cost = false
for i = 1, data.damage do for _ = 1, data.damage do
if self.cancel_cost then break end if self.cancel_cost or not player:hasSkill(self) then break end
self:doCost(event, target, player, data) self:doCost(event, target, player, data)
end end
end, end,
@ -378,7 +355,9 @@ local luoshen_obtain = fk.CreateTriggerSkill{
frequency = Skill.Compulsory, frequency = Skill.Compulsory,
events = {fk.FinishJudge}, events = {fk.FinishJudge},
can_trigger = function(self, event, target, player, data) can_trigger = function(self, event, target, player, data)
return target == player and data.reason == "luoshen" and data.card.color == Card.Black end, return target == player and not player.dead and data.reason == "luoshen" and data.card.color == Card.Black and
player.room:getCardArea(data.card) == Card.Processing
end,
on_use = function(self, event, target, player, data) on_use = function(self, event, target, player, data)
player.room:obtainCard(player.id, data.card) player.room:obtainCard(player.id, data.card)
end, end,
@ -425,7 +404,7 @@ local rende = fk.CreateActiveSkill{
local marks = player:getMark("_rende_cards-phase") local marks = player:getMark("_rende_cards-phase")
room:moveCardTo(cards, Player.Hand, target, fk.ReasonGive, self.name, nil, false, player.id) room:moveCardTo(cards, Player.Hand, target, fk.ReasonGive, self.name, nil, false, player.id)
room:addPlayerMark(player, "_rende_cards-phase", #cards) room:addPlayerMark(player, "_rende_cards-phase", #cards)
if marks < 2 and marks + #cards >= 2 and player:isWounded() then if marks < 2 and marks + #cards >= 2 and not player.dead and player:isWounded() then
room:recover{ room:recover{
who = player, who = player,
num = 1, num = 1,
@ -711,13 +690,18 @@ local zhiheng = fk.CreateActiveSkill{
can_use = function(self, player) can_use = function(self, player)
return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
end, end,
card_filter = function(self, to_select, selected)
return not Self:prohibitDiscard(Fk:getCardById(to_select))
end,
target_num = 0, target_num = 0,
min_card_num = 1, min_card_num = 1,
on_use = function(self, room, effect) on_use = function(self, room, effect)
local from = room:getPlayerById(effect.from) local from = room:getPlayerById(effect.from)
room:throwCard(effect.cards, self.name, from, from) room:throwCard(effect.cards, self.name, from, from)
from:drawCards(#effect.cards, self.name) if from:isAlive() then
end from:drawCards(#effect.cards, self.name)
end
end,
} }
local jiuyuan = fk.CreateTriggerSkill{ local jiuyuan = fk.CreateTriggerSkill{
@ -770,33 +754,35 @@ local keji = fk.CreateTriggerSkill{
anim_type = "defensive", anim_type = "defensive",
events = {fk.EventPhaseChanging}, events = {fk.EventPhaseChanging},
can_trigger = function(self, event, target, player, data) can_trigger = function(self, event, target, player, data)
return target == player and player:hasSkill(self.name) and if target == player and player:hasSkill(self.name) and data.to == Player.Discard then
data.to == Player.Discard and local room = player.room
player:usedCardTimes("slash") < 1 and local logic = room.logic
player:getMark("_keji_played_slash") == 0 local e = logic:getCurrentEvent():findParent(GameEvent.Turn, true)
if e == nil then return false end
local end_id = e.id
local events = logic.event_recorder[GameEvent.UseCard] or Util.DummyTable
for i = #events, 1, -1 do
e = events[i]
if e.id <= end_id then break end
local use = e.data[1]
if use.from == player.id and use.card.trueName == "slash" then
return false
end
end
events = logic.event_recorder[GameEvent.RespondCard] or Util.DummyTable
for i = #events, 1, -1 do
e = events[i]
if e.id <= end_id then break end
local resp = e.data[1]
if resp.from == player.id and resp.card.trueName == "slash" then
return false
end
end
return true
end
end, end,
on_use = function(self, event, target, player, data) on_use = function(self, event, target, player, data)
return true return true
end,
refresh_events = {fk.CardResponding, fk.EventPhaseStart},
can_refresh = function(self, event, target, player, data)
if not (target == player and player:hasSkill(self.name)) then
return false
end
if event == fk.CardResponding then
return player.phase == Player.Play and data.card.trueName == "slash"
elseif event == fk.EventPhaseStart then
return player.phase == Player.NotActive
end
end,
on_refresh = function(self, event, target, player, data)
local room = player.room
if event == fk.CardResponding then
room:addPlayerMark(player, "_keji_played_slash", 1)
elseif event == fk.EventPhaseStart then
room:setPlayerMark(player, "_keji_played_slash", 0)
end
end end
} }
local lvmeng = General:new(extension, "lvmeng", "wu", 4) local lvmeng = General:new(extension, "lvmeng", "wu", 4)
@ -830,7 +816,7 @@ local yingzi = fk.CreateTriggerSkill{
local fanjian = fk.CreateActiveSkill{ local fanjian = fk.CreateActiveSkill{
name = "fanjian", name = "fanjian",
can_use = function(self, player) can_use = function(self, player)
return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 and not player:isKongcheng() return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
end, end,
card_filter = function() return false end, card_filter = function() return false end,
target_filter = function(self, to_select, selected) target_filter = function(self, to_select, selected)
@ -843,7 +829,7 @@ local fanjian = fk.CreateActiveSkill{
local choice = room:askForChoice(target, {"spade", "heart", "club", "diamond"}, self.name) local choice = room:askForChoice(target, {"spade", "heart", "club", "diamond"}, self.name)
local card = room:askForCardChosen(target, player, 'h', self.name) local card = room:askForCardChosen(target, player, 'h', self.name)
room:obtainCard(target.id, card, true, fk.ReasonPrey) room:obtainCard(target.id, card, true, fk.ReasonPrey)
if Fk:getCardById(card):getSuitString() ~= choice then if Fk:getCardById(card):getSuitString() ~= choice and target:isAlive() then
room:damage{ room:damage{
from = player, from = player,
to = target, to = target,
@ -914,8 +900,8 @@ local liuli = fk.CreateTriggerSkill{
local to = self.cost_data[1] local to = self.cost_data[1]
room:doIndicate(player.id, { to }) room:doIndicate(player.id, { to })
room:throwCard(self.cost_data[2], self.name, player, player) room:throwCard(self.cost_data[2], self.name, player, player)
TargetGroup:removeTarget(data.targetGroup, player.id) AimGroup:cancelTarget(data, player.id)
TargetGroup:pushTargets(data.targetGroup, to) AimGroup:addTargets(room, data, to)
end, end,
} }
local daqiao = General:new(extension, "daqiao", "wu", 3, 3, General.Female) local daqiao = General:new(extension, "daqiao", "wu", 3, 3, General.Female)
@ -984,8 +970,8 @@ local xiaoji = fk.CreateTriggerSkill{
end end
end end
self.cancel_cost = false self.cancel_cost = false
for i = 1, i do for _ = 1, i do
if self.cancel_cost or not player:hasSkill(self.name) then break end if self.cancel_cost or not player:hasSkill(self) then break end
self:doCost(event, target, player, data) self:doCost(event, target, player, data)
end end
end, end,
@ -1011,21 +997,24 @@ local jieyin = fk.CreateActiveSkill{
target_filter = function(self, to_select, selected) target_filter = function(self, to_select, selected)
local target = Fk:currentRoom():getPlayerById(to_select) local target = Fk:currentRoom():getPlayerById(to_select)
return target:isWounded() and return target:isWounded() and
target.gender == General.Male (target.gender == General.Male or target.gender == General.Bigender)
and #selected < 1 and to_select ~= Self.id and #selected < 1 and to_select ~= Self.id
end, end,
target_num = 1, target_num = 1,
card_num = 2, card_num = 2,
on_use = function(self, room, effect) on_use = function(self, room, effect)
local from = room:getPlayerById(effect.from) local from = room:getPlayerById(effect.from)
local target = room:getPlayerById(effect.tos[1])
room:throwCard(effect.cards, self.name, from, from) room:throwCard(effect.cards, self.name, from, from)
room:recover({ if target:isAlive() and target:isWounded() then
who = room:getPlayerById(effect.tos[1]), room:recover({
num = 1, who = room:getPlayerById(effect.tos[1]),
recoverBy = from, num = 1,
skillName = self.name recoverBy = from,
}) skillName = self.name
if from:isWounded() then })
end
if from:isAlive() and from:isWounded() then
room:recover({ room:recover({
who = from, who = from,
num = 1, num = 1,
@ -1046,7 +1035,8 @@ local qingnang = fk.CreateActiveSkill{
return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
end, end,
card_filter = function(self, to_select, selected, targets) card_filter = function(self, to_select, selected, targets)
return #selected == 0 and Fk:currentRoom():getCardArea(to_select) == Player.Hand return #selected == 0 and Fk:currentRoom():getCardArea(to_select) == Player.Hand and
not Self:prohibitDiscard(Fk:getCardById(to_select))
end, end,
target_filter = function(self, to_select, selected, cards) target_filter = function(self, to_select, selected, cards)
return #selected == 0 and Fk:currentRoom():getPlayerById(to_select):isWounded() return #selected == 0 and Fk:currentRoom():getPlayerById(to_select):isWounded()
@ -1056,12 +1046,14 @@ local qingnang = fk.CreateActiveSkill{
on_use = function(self, room, effect) on_use = function(self, room, effect)
local from = room:getPlayerById(effect.from) local from = room:getPlayerById(effect.from)
room:throwCard(effect.cards, self.name, from, from) room:throwCard(effect.cards, self.name, from, from)
room:recover({ if from:isAlive() and from:isWounded() then
who = room:getPlayerById(effect.tos[1]), room:recover({
num = 1, who = room:getPlayerById(effect.tos[1]),
recoverBy = from, num = 1,
skillName = self.name recoverBy = from,
}) skillName = self.name
})
end
end, end,
} }
local jijiu = fk.CreateViewAsSkill{ local jijiu = fk.CreateViewAsSkill{
@ -1129,11 +1121,13 @@ local lijian = fk.CreateActiveSkill{
return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0 return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
end, end,
card_filter = function(self, to_select, selected) card_filter = function(self, to_select, selected)
return #selected == 0 return #selected == 0 and not Self:prohibitDiscard(Fk:getCardById(to_select))
end, end,
target_filter = function(self, to_select, selected) target_filter = function(self, to_select, selected)
return #selected < 2 and to_select ~= Self.id and if #selected < 2 and to_select ~= Self.id then
Fk:currentRoom():getPlayerById(to_select).gender == General.Male local target = Fk:currentRoom():getPlayerById(to_select)
return target.gender == General.Male or target.gender == General.Bigender
end
end, end,
target_num = 2, target_num = 2,
min_card_num = 1, min_card_num = 1,

View File

@ -184,7 +184,7 @@ local dismantlementSkill = fk.CreateActiveSkill{
on_effect = function(self, room, effect) on_effect = function(self, room, effect)
local from = room:getPlayerById(effect.from) local from = room:getPlayerById(effect.from)
local to = room:getPlayerById(effect.to) local to = room:getPlayerById(effect.to)
if to.dead or to:isAllNude() then return end if from.dead or to.dead or to:isAllNude() then return end
local cid = room:askForCardChosen(from, to, "hej", self.name) local cid = room:askForCardChosen(from, to, "hej", self.name)
room:throwCard({cid}, self.name, to, from) room:throwCard({cid}, self.name, to, from)
end end
@ -224,7 +224,7 @@ local snatchSkill = fk.CreateActiveSkill{
on_effect = function(self, room, effect) on_effect = function(self, room, effect)
local from = room:getPlayerById(effect.from) local from = room:getPlayerById(effect.from)
local to = room:getPlayerById(effect.to) local to = room:getPlayerById(effect.to)
if to.dead or to:isAllNude() then return end if from.dead or to.dead or to:isAllNude() then return end
local cid = room:askForCardChosen(from, to, "hej", self.name) local cid = room:askForCardChosen(from, to, "hej", self.name)
room:obtainCard(from, cid, false, fk.ReasonPrey) room:obtainCard(from, cid, false, fk.ReasonPrey)
end end
@ -846,27 +846,13 @@ local qingGangSkill = fk.CreateTriggerSkill{
end, end,
on_use = function(self, event, target, player, data) on_use = function(self, event, target, player, data)
local room = player.room local room = player.room
room:addPlayerMark(room:getPlayerById(data.to), fk.MarkArmorNullified) local to = room:getPlayerById(data.to)
local use_event = room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true)
data.extra_data = data.extra_data or {} if use_event == nil then return end
data.extra_data.qinggangNullified = data.extra_data.qinggangNullified or {} room:addPlayerMark(to, fk.MarkArmorNullified)
data.extra_data.qinggangNullified[tostring(data.to)] = (data.extra_data.qinggangNullified[tostring(data.to)] or 0) + 1 use_event:addCleaner(function()
end, room:removePlayerMark(to, fk.MarkArmorNullified)
end)
refresh_events = { fk.CardUseFinished },
can_refresh = function(self, event, target, player, data)
return data.extra_data and data.extra_data.qinggangNullified
end,
on_refresh = function(self, event, target, player, data)
local room = player.room
for key, num in pairs(data.extra_data.qinggangNullified) do
local p = room:getPlayerById(tonumber(key))
if p:getMark(fk.MarkArmorNullified) > 0 then
room:removePlayerMark(p, fk.MarkArmorNullified, num)
end
end
data.qinggangNullified = nil
end, end,
} }
Fk:addSkill(qingGangSkill) Fk:addSkill(qingGangSkill)
@ -923,8 +909,9 @@ local doubleSwordsSkill = fk.CreateTriggerSkill{
can_trigger = function(self, event, target, player, data) can_trigger = function(self, event, target, player, data)
if target == player and player:hasSkill(self.name) and if target == player and player:hasSkill(self.name) and
data.card and data.card.trueName == "slash" then data.card and data.card.trueName == "slash" then
local target = player.room:getPlayerById(data.to) local to = player.room:getPlayerById(data.to)
return target.gender ~= player.gender and target.gender ~= General.Agender and player.gender ~= General.Agender if player.gender == General.Agender or to.gender == General.Agender then return false end
return to.gender ~= player.gender or player.gender == General.Bigender or to.gender == General.Bigender
end end
end, end,
on_use = function(self, event, target, player, data) on_use = function(self, event, target, player, data)
@ -1108,27 +1095,26 @@ local kylinBowSkill = fk.CreateTriggerSkill{
if ret then if ret then
---@type ServerPlayer ---@type ServerPlayer
local to = data.to local to = data.to
return to:getEquipment(Card.SubtypeDefensiveRide) or return table.find(to:getCardIds(Player.Equip), function (id)
to:getEquipment(Card.SubtypeOffensiveRide) local card = Fk:getCardById(id)
return card.sub_type == Card.SubtypeDefensiveRide or card.sub_type == Card.SubtypeOffensiveRide
end)
end end
end, end,
on_use = function(self, event, target, player, data) on_use = function(self, event, target, player, data)
local room = player.room local room = player.room
local to = data.to local to = data.to
local ride_tab = {} local ride_tab = table.filter(to:getCardIds(Player.Equip), function (id)
if to:getEquipment(Card.SubtypeDefensiveRide) then local card = Fk:getCardById(id)
table.insert(ride_tab, "+1") return card.sub_type == Card.SubtypeDefensiveRide or card.sub_type == Card.SubtypeOffensiveRide
end end)
if to:getEquipment(Card.SubtypeOffensiveRide) then
table.insert(ride_tab, "-1")
end
if #ride_tab == 0 then return end if #ride_tab == 0 then return end
local choice = room:askForChoice(player, ride_tab, self.name) local id = room:askForCardChosen(player, to, {
if choice == "+1" then card_data = {
room:throwCard(to:getEquipment(Card.SubtypeDefensiveRide), self.name, to, player) { "equip_horse", ride_tab }
else }
room:throwCard(to:getEquipment(Card.SubtypeOffensiveRide), self.name, to, player) }, self.name)
end room:throwCard({id}, self.name, to, player)
end end
} }
Fk:addSkill(kylinBowSkill) Fk:addSkill(kylinBowSkill)