diff --git a/lua/client/client.lua b/lua/client/client.lua index 9d811b7c..a8d9cb92 100644 --- a/lua/client/client.lua +++ b/lua/client/client.lua @@ -15,6 +15,14 @@ ClientPlayer = require "client.clientplayer" fk.client_callback = {} +-- 总而言之就是会让roomScene.state变为responding或者playing的状态 +local pattern_refresh_commands = { + "PlayCard", + "AskForUseActiveSkill", + "AskForUseCard", + "AskForResponseCard", +} + function Client:initialize() self.client = fk.ClientInstance self.notifyUI = function(self, command, jsonData) @@ -23,7 +31,7 @@ function Client:initialize() self.client.callback = function(_self, command, jsonData) local cb = fk.client_callback[command] - if command ~= "Heartbeat" and command ~= "StartChangeSelf" and command ~= "ChangeSelf" then + if table.contains(pattern_refresh_commands, command) then Fk.currentResponsePattern = nil Fk.currentResponseReason = nil end diff --git a/lua/client/client_util.lua b/lua/client/client_util.lua index 7c45b2a1..b8608ba5 100644 --- a/lua/client/client_util.lua +++ b/lua/client/client_util.lua @@ -590,6 +590,7 @@ end function GetPlayerGameData(pid) local c = ClientInstance local p = c:getPlayerById(pid) + if not p then return "[0, 0, 0]" end local raw = p.player:getGameData() local ret = {} for _, i in fk.qlist(raw) do diff --git a/lua/core/skill_type/target_mod.lua b/lua/core/skill_type/target_mod.lua index 5e762afa..2c7a628b 100644 --- a/lua/core/skill_type/target_mod.lua +++ b/lua/core/skill_type/target_mod.lua @@ -7,7 +7,7 @@ local TargetModSkill = StatusSkill:subclass("TargetModSkill") ---@param card_skill ActiveSkill ---@param scope integer ---@param card Card -function TargetModSkill:isUnlimited(player, card_skill, scope, card, to) +function TargetModSkill:bypassTimesCheck(player, card_skill, scope, card, to) return false end @@ -19,6 +19,13 @@ function TargetModSkill:getResidueNum(player, card_skill, scope, card, to) return 0 end +---@param player Player +---@param card_skill ActiveSkill +---@param card Card +function TargetModSkill:bypassDistancesCheck(player, card_skill, card, to) + return false +end + ---@param player Player ---@param card_skill ActiveSkill ---@param card Card diff --git a/lua/core/skill_type/usable_skill.lua b/lua/core/skill_type/usable_skill.lua index 3a8f0cec..02122102 100644 --- a/lua/core/skill_type/usable_skill.lua +++ b/lua/core/skill_type/usable_skill.lua @@ -28,16 +28,16 @@ function UsableSkill:withinTimesLimit(player, scope, card, card_name, to) scope = scope or Player.HistoryTurn local status_skills = Fk:currentRoom().status_skills[TargetModSkill] or Util.DummyTable for _, skill in ipairs(status_skills) do - if skill:isUnlimited(player, self, scope, card, to) then return true end + if skill:bypassTimesCheck(player, self, scope, card, to) then return true end end card_name = card_name or card.trueName return player:usedCardTimes(card_name, scope) < self:getMaxUseTime(player, scope, card, to) end function UsableSkill:withinDistanceLimit(player, isattack, card, to) - local status_skills = Fk:currentRoom().status_skills[AttackRangeSkill] or Util.DummyTable + local status_skills = Fk:currentRoom().status_skills[TargetModSkill] or Util.DummyTable for _, skill in ipairs(status_skills) do - if skill:withinAttackRange(player, to) then return true end + if skill:bypassDistancesCheck(player, self, card, to) then return true end end return isattack and player:inMyAttackRange(to, self:getDistanceLimit(player, card, to)) or player:distanceTo(to) <= self:getDistanceLimit(player, card, to) end diff --git a/lua/fk_ex.lua b/lua/fk_ex.lua index 8b8250d9..978b3bfa 100644 --- a/lua/fk_ex.lua +++ b/lua/fk_ex.lua @@ -350,8 +350,9 @@ function fk.CreateMaxCardsSkill(spec) end ---@class TargetModSpec: StatusSkillSpec ----@field public unlimited fun(self: TargetModSkill, player: Player, skill: ActiveSkill, scope: integer, card: Card, to: Player) +---@field public bypass_times fun(self: TargetModSkill, player: Player, skill: ActiveSkill, scope: integer, card: Card, to: Player) ---@field public residue_func fun(self: TargetModSkill, player: Player, skill: ActiveSkill, scope: integer, card: Card, to: Player) +---@field public bypass_distances fun(self: TargetModSkill, player: Player, skill: ActiveSkill, card: Card, to: Player) ---@field public distance_limit_func fun(self: TargetModSkill, player: Player, skill: ActiveSkill, card: Card, to: Player) ---@field public extra_target_func fun(self: TargetModSkill, player: Player, skill: ActiveSkill, card: Card) @@ -362,12 +363,15 @@ function fk.CreateTargetModSkill(spec) local skill = TargetModSkill:new(spec.name) readStatusSpecToSkill(skill, spec) - if spec.unlimited then - skill.isUnlimited = spec.unlimited + if spec.bypass_times then + skill.bypassTimesCheck = spec.bypass_times end if spec.residue_func then skill.getResidueNum = spec.residue_func end + if spec.bypass_distances then + skill.bypassDistancesCheck = spec.bypass_distances + end if spec.distance_limit_func then skill.getDistanceLimit = spec.distance_limit_func end diff --git a/lua/ui-util.lua b/lua/ui-util.lua index 053f5caf..9f4ad59b 100644 --- a/lua/ui-util.lua +++ b/lua/ui-util.lua @@ -18,7 +18,7 @@ UI.ComboBox = function(spec) -- assert(#spec.choices > 0, "Choices is empty") spec.choices = type(spec.choices) == "table" and spec.choices or Util.DummyTable spec.default = spec.default or spec.choices[1] - spec.detailed = spec.detailed + spec.detailed = spec.detailed or false spec.type = "combo" return spec end diff --git a/packages/standard/aux_skills.lua b/packages/standard/aux_skills.lua index ac724048..2d07ccd0 100644 --- a/packages/standard/aux_skills.lua +++ b/packages/standard/aux_skills.lua @@ -125,7 +125,7 @@ local uncompulsoryInvalidity = fk.CreateInvaliditySkill { local noTimesLimit = fk.CreateTargetModSkill{ name = "noTimesLimit", global = true, - unlimited = function(self, player, skill, scope, card, to) + bypass_times = function(self, player, skill, scope, card, to) return to:getMark(MarkEnum.BypassTimesLimit) ~= 0 or table.find(MarkEnum.TempMarkSuffix, function(s) return to:getMark(MarkEnum.BypassTimesLimit .. s) ~= 0 diff --git a/packages/standard/init.lua b/packages/standard/init.lua index 4b568106..c57e97af 100644 --- a/packages/standard/init.lua +++ b/packages/standard/init.lua @@ -509,7 +509,7 @@ local paoxiaoAudio = fk.CreateTriggerSkill{ } local paoxiao = fk.CreateTargetModSkill{ name = "paoxiao", - unlimited = function(self, player, skill, scope) + bypass_times = function(self, player, skill, scope) if player:hasSkill(self.name) and skill.trueName == "slash_skill" and scope == Player.HistoryPhase then return true @@ -657,11 +657,11 @@ local jizhi = fk.CreateTriggerSkill{ local qicai = fk.CreateTargetModSkill{ name = "qicai", frequency = Skill.Compulsory, - distance_limit_func = function(self, player, skill) + 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 999 + return true end end, } diff --git a/packages/standard_cards/init.lua b/packages/standard_cards/init.lua index 94b0a7e5..57583ccc 100644 --- a/packages/standard_cards/init.lua +++ b/packages/standard_cards/init.lua @@ -778,7 +778,7 @@ local crossbowAudio = fk.CreateTriggerSkill{ local crossbowSkill = fk.CreateTargetModSkill{ name = "#crossbow_skill", attached_equip = "crossbow", - unlimited = function(self, player, skill, scope) + bypass_times = function(self, player, skill, scope) if player:hasSkill(self.name) and skill.trueName == "slash_skill" and scope == Player.HistoryPhase then return true