堆参数和bugfix (#299)

- askForChooseCardsAndPlayers又写崩了,故修之
- 修复了Within系列没有检查to的错误
- 彻底修复了连环起点属性的bug
This commit is contained in:
YoumuKon 2023-12-28 12:15:01 +08:00 committed by GitHub
parent 278e7ce4c6
commit 268996a103
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 13 deletions

View File

@ -43,10 +43,10 @@ function UsableSkill:withinTimesLimit(player, scope, card, card_name, to)
table.find(temp_suf, function(s)
return player:getMark(MarkEnum.BypassTimesLimit .. s) ~= 0
end)) or
(to:getMark(MarkEnum.BypassTimesLimitTo) ~= 0 or
(to and (to:getMark(MarkEnum.BypassTimesLimitTo) ~= 0 or
table.find(temp_suf, function(s)
return to:getMark(MarkEnum.BypassTimesLimitTo .. s) ~= 0
end))
end)))
end
function UsableSkill:withinDistanceLimit(player, isattack, card, to)
@ -66,10 +66,10 @@ function UsableSkill:withinDistanceLimit(player, isattack, card, to)
table.find(temp_suf, function(s)
return player:getMark(MarkEnum.BypassDistancesLimit .. s) ~= 0
end)) or
(to:getMark(MarkEnum.BypassDistancesLimitTo) ~= 0 or
(to and (to:getMark(MarkEnum.BypassDistancesLimitTo) ~= 0 or
table.find(temp_suf, function(s)
return to:getMark(MarkEnum.BypassDistancesLimitTo .. s) ~= 0
end))
end)))
end
return UsableSkill

View File

@ -169,7 +169,7 @@ GameEvent.functions[GameEvent.Damage] = function(self)
end
if damageStruct.damageType ~= fk.NormalDamage and damageStruct.to.chained then
damageStruct.beginnerOfTheDamage = true
if not damageStruct.chain then damageStruct.beginnerOfTheDamage = true end
damageStruct.to:setChainState(false)
end

View File

@ -1095,12 +1095,14 @@ function Room:askForUseActiveSkill(player, skill_name, prompt, cancelable, extra
local targets = data.targets
local card_data = json.decode(card)
local selected_cards = card_data.subcards
local interaction
if not no_indicate then
self:doIndicate(player.id, targets)
end
if skill.interaction then
skill.interaction.data = data.interaction_data
interaction = data.interaction_data
skill.interaction.data = interaction
end
if skill:isInstanceOf(ActiveSkill) then
@ -1113,7 +1115,8 @@ function Room:askForUseActiveSkill(player, skill_name, prompt, cancelable, extra
return true, {
cards = selected_cards,
targets = targets
targets = targets,
interaction = interaction
}
end
@ -1331,7 +1334,7 @@ end
--- 询问玩家选择X张牌和Y名角色。
---
--- 返回两个值,第一个是选择的目标列表,第二个是选择的那张id
--- 返回两个值,第一个是选择的目标列表,第二个是选择的牌id列表
---@param player ServerPlayer @ 要询问的玩家
---@param minCardNum integer @ 选卡牌最小值
---@param maxCardNum integer @ 选卡牌最大值
@ -1355,7 +1358,7 @@ function Room:askForChooseCardsAndPlayers(player, minCardNum, maxCardNum, target
local c = Fk:getCardById(id)
return c:matchPattern(pattern)
end)
if #pcards < minCardNum and not cancelable then return table.unpack({}, {}) end
if #pcards < minCardNum and not cancelable then return {}, {} end
local data = {
targets = targets,
@ -1365,6 +1368,8 @@ function Room:askForChooseCardsAndPlayers(player, minCardNum, maxCardNum, target
min_card_num = minCardNum,
pattern = pattern,
skillName = skillName,
-- include_equip = includeEquip, -- FIXME: 预定一个破坏性更新
-- expand_pile = expandPile,
}
local _, ret = self:askForUseActiveSkill(player, "ex__choose_skill", prompt or "", cancelable, data, no_indicate)
if ret then
@ -1682,7 +1687,7 @@ end
---@return string[] @ 选择的选项
function Room:askForChoices(player, choices, minNum, maxNum, skill_name, prompt, cancelable, detailed, all_choices)
cancelable = (cancelable == nil) and true or cancelable
if #choices <= minNum and not all_choices then return choices end
if #choices <= minNum and not all_choices and not cancelable then return choices end
assert(minNum <= maxNum)
assert(not all_choices or table.every(choices, function(c) return table.contains(all_choices, c) end))
local command = "AskForChoices"
@ -1694,7 +1699,13 @@ function Room:askForChoices(player, choices, minNum, maxNum, skill_name, prompt,
local result = self:doRequest(player, command, json.encode{
choices, all_choices, {minNum, maxNum}, cancelable, skill_name, prompt, detailed
})
if result == "" then return {} end
if result == "" then
if cancelable then
return {}
else
return table.random(choices, math.min(minNum, #choices))
end
end
return json.decode(result)
end
@ -2032,7 +2043,8 @@ function Room:askForUseCard(player, card_name, pattern, prompt, cancelable, extr
end
end
until type(useResult) ~= "string"
player.room:setPlayerMark(player, MarkEnum.BypassDistancesLimit .. "-tmp", 0) -- FIXME: 缺少直接传入无限制的手段
player.room:setPlayerMark(player, MarkEnum.BypassTimesLimit .. "-tmp", 0) -- FIXME: 缺少直接传入无限制的手段
return useResult
end
player.room:setPlayerMark(player, MarkEnum.BypassDistancesLimit .. "-tmp", 0) -- FIXME: 缺少直接传入无限制的手段
@ -2609,6 +2621,13 @@ function Room:doCardUseEffect(cardUseEvent)
-- If using card to other card (like jink or nullification), simply effect and return
if cardUseEvent.toCard ~= nil then
self:doCardEffect(cardEffectEvent)
if cardEffectEvent.cardsResponded then
cardUseEvent.cardsResponded = cardUseEvent.cardsResponded or {}
for _, card in ipairs(cardEffectEvent.cardsResponded) do
table.insertIfNeed(cardUseEvent.cardsResponded, card)
end
end
return
end

View File

@ -95,7 +95,7 @@ local choosePlayersSkill = fk.CreateActiveSkill{
local exChooseSkill = fk.CreateActiveSkill{
name = "ex__choose_skill",
card_filter = function(self, to_select, selected)
if #selected < self.max_card_num then return false end
if #selected >= self.max_card_num then return false end
if Fk:currentRoom():getCardArea(to_select) == Card.PlayerSpecial then
if not string.find(self.pattern or "", self.expand_pile or "") then return false end

View File

@ -96,6 +96,9 @@ local control = fk.CreateActiveSkill{
to:control(to)
end
end
-- local targets, cards = room:askForChooseCardsAndPlayers(from, 1, 3, effect.tos, 1, 3, nil, "选一下吧", self.name, true)
-- p(targets)
-- p(cards)
--local success, dat = room:askForUseViewAsSkill(from, "test_vs", nil, true)
--if success then
--local card = Fk.skills["test_vs"]:viewAs(dat.cards)