bypassDistancesCheck + bugfix (#204)
- 重命名isUnlimited/unlimited,因为未正式上线所以无关紧要(?) - 新增bypassDistancesCheck/bypass_distances,实现真正的无距离限制 - 修复早退导致的报错bug --------- Co-authored-by: notify <notify-ctrl@qq.com>
This commit is contained in:
parent
1036159d38
commit
3aef53d16c
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue