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 = {}
|
fk.client_callback = {}
|
||||||
|
|
||||||
|
-- 总而言之就是会让roomScene.state变为responding或者playing的状态
|
||||||
|
local pattern_refresh_commands = {
|
||||||
|
"PlayCard",
|
||||||
|
"AskForUseActiveSkill",
|
||||||
|
"AskForUseCard",
|
||||||
|
"AskForResponseCard",
|
||||||
|
}
|
||||||
|
|
||||||
function Client:initialize()
|
function Client:initialize()
|
||||||
self.client = fk.ClientInstance
|
self.client = fk.ClientInstance
|
||||||
self.notifyUI = function(self, command, jsonData)
|
self.notifyUI = function(self, command, jsonData)
|
||||||
|
@ -23,7 +31,7 @@ function Client:initialize()
|
||||||
self.client.callback = function(_self, command, jsonData)
|
self.client.callback = function(_self, command, jsonData)
|
||||||
local cb = fk.client_callback[command]
|
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.currentResponsePattern = nil
|
||||||
Fk.currentResponseReason = nil
|
Fk.currentResponseReason = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -590,6 +590,7 @@ end
|
||||||
function GetPlayerGameData(pid)
|
function GetPlayerGameData(pid)
|
||||||
local c = ClientInstance
|
local c = ClientInstance
|
||||||
local p = c:getPlayerById(pid)
|
local p = c:getPlayerById(pid)
|
||||||
|
if not p then return "[0, 0, 0]" end
|
||||||
local raw = p.player:getGameData()
|
local raw = p.player:getGameData()
|
||||||
local ret = {}
|
local ret = {}
|
||||||
for _, i in fk.qlist(raw) do
|
for _, i in fk.qlist(raw) do
|
||||||
|
|
|
@ -7,7 +7,7 @@ local TargetModSkill = StatusSkill:subclass("TargetModSkill")
|
||||||
---@param card_skill ActiveSkill
|
---@param card_skill ActiveSkill
|
||||||
---@param scope integer
|
---@param scope integer
|
||||||
---@param card Card
|
---@param card Card
|
||||||
function TargetModSkill:isUnlimited(player, card_skill, scope, card, to)
|
function TargetModSkill:bypassTimesCheck(player, card_skill, scope, card, to)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -19,6 +19,13 @@ function TargetModSkill:getResidueNum(player, card_skill, scope, card, to)
|
||||||
return 0
|
return 0
|
||||||
end
|
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 player Player
|
||||||
---@param card_skill ActiveSkill
|
---@param card_skill ActiveSkill
|
||||||
---@param card Card
|
---@param card Card
|
||||||
|
|
|
@ -28,16 +28,16 @@ function UsableSkill:withinTimesLimit(player, scope, card, card_name, to)
|
||||||
scope = scope or Player.HistoryTurn
|
scope = scope or Player.HistoryTurn
|
||||||
local status_skills = Fk:currentRoom().status_skills[TargetModSkill] or Util.DummyTable
|
local status_skills = Fk:currentRoom().status_skills[TargetModSkill] or Util.DummyTable
|
||||||
for _, skill in ipairs(status_skills) do
|
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
|
end
|
||||||
card_name = card_name or card.trueName
|
card_name = card_name or card.trueName
|
||||||
return player:usedCardTimes(card_name, scope) < self:getMaxUseTime(player, scope, card, to)
|
return player:usedCardTimes(card_name, scope) < self:getMaxUseTime(player, scope, card, to)
|
||||||
end
|
end
|
||||||
|
|
||||||
function UsableSkill:withinDistanceLimit(player, isattack, card, to)
|
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
|
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
|
end
|
||||||
return isattack and player:inMyAttackRange(to, self:getDistanceLimit(player, card, to)) or player:distanceTo(to) <= self:getDistanceLimit(player, card, to)
|
return isattack and player:inMyAttackRange(to, self:getDistanceLimit(player, card, to)) or player:distanceTo(to) <= self:getDistanceLimit(player, card, to)
|
||||||
end
|
end
|
||||||
|
|
|
@ -350,8 +350,9 @@ function fk.CreateMaxCardsSkill(spec)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@class TargetModSpec: StatusSkillSpec
|
---@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 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 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)
|
---@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)
|
local skill = TargetModSkill:new(spec.name)
|
||||||
readStatusSpecToSkill(skill, spec)
|
readStatusSpecToSkill(skill, spec)
|
||||||
if spec.unlimited then
|
if spec.bypass_times then
|
||||||
skill.isUnlimited = spec.unlimited
|
skill.bypassTimesCheck = spec.bypass_times
|
||||||
end
|
end
|
||||||
if spec.residue_func then
|
if spec.residue_func then
|
||||||
skill.getResidueNum = spec.residue_func
|
skill.getResidueNum = spec.residue_func
|
||||||
end
|
end
|
||||||
|
if spec.bypass_distances then
|
||||||
|
skill.bypassDistancesCheck = spec.bypass_distances
|
||||||
|
end
|
||||||
if spec.distance_limit_func then
|
if spec.distance_limit_func then
|
||||||
skill.getDistanceLimit = spec.distance_limit_func
|
skill.getDistanceLimit = spec.distance_limit_func
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@ UI.ComboBox = function(spec)
|
||||||
-- assert(#spec.choices > 0, "Choices is empty")
|
-- assert(#spec.choices > 0, "Choices is empty")
|
||||||
spec.choices = type(spec.choices) == "table" and spec.choices or Util.DummyTable
|
spec.choices = type(spec.choices) == "table" and spec.choices or Util.DummyTable
|
||||||
spec.default = spec.default or spec.choices[1]
|
spec.default = spec.default or spec.choices[1]
|
||||||
spec.detailed = spec.detailed
|
spec.detailed = spec.detailed or false
|
||||||
spec.type = "combo"
|
spec.type = "combo"
|
||||||
return spec
|
return spec
|
||||||
end
|
end
|
||||||
|
|
|
@ -125,7 +125,7 @@ local uncompulsoryInvalidity = fk.CreateInvaliditySkill {
|
||||||
local noTimesLimit = fk.CreateTargetModSkill{
|
local noTimesLimit = fk.CreateTargetModSkill{
|
||||||
name = "noTimesLimit",
|
name = "noTimesLimit",
|
||||||
global = true,
|
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
|
return to:getMark(MarkEnum.BypassTimesLimit) ~= 0 or
|
||||||
table.find(MarkEnum.TempMarkSuffix, function(s)
|
table.find(MarkEnum.TempMarkSuffix, function(s)
|
||||||
return to:getMark(MarkEnum.BypassTimesLimit .. s) ~= 0
|
return to:getMark(MarkEnum.BypassTimesLimit .. s) ~= 0
|
||||||
|
|
|
@ -509,7 +509,7 @@ local paoxiaoAudio = fk.CreateTriggerSkill{
|
||||||
}
|
}
|
||||||
local paoxiao = fk.CreateTargetModSkill{
|
local paoxiao = fk.CreateTargetModSkill{
|
||||||
name = "paoxiao",
|
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"
|
if player:hasSkill(self.name) and skill.trueName == "slash_skill"
|
||||||
and scope == Player.HistoryPhase then
|
and scope == Player.HistoryPhase then
|
||||||
return true
|
return true
|
||||||
|
@ -657,11 +657,11 @@ local jizhi = fk.CreateTriggerSkill{
|
||||||
local qicai = fk.CreateTargetModSkill{
|
local qicai = fk.CreateTargetModSkill{
|
||||||
name = "qicai",
|
name = "qicai",
|
||||||
frequency = Skill.Compulsory,
|
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_name = string.sub(skill.name, 1, -7) -- assuming all card skill is named with name_skill
|
||||||
local card = Fk:cloneCard(card_name)
|
local card = Fk:cloneCard(card_name)
|
||||||
if player:hasSkill(self.name) and card.type == Card.TypeTrick then
|
if player:hasSkill(self.name) and card.type == Card.TypeTrick then
|
||||||
return 999
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
@ -778,7 +778,7 @@ local crossbowAudio = fk.CreateTriggerSkill{
|
||||||
local crossbowSkill = fk.CreateTargetModSkill{
|
local crossbowSkill = fk.CreateTargetModSkill{
|
||||||
name = "#crossbow_skill",
|
name = "#crossbow_skill",
|
||||||
attached_equip = "crossbow",
|
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"
|
if player:hasSkill(self.name) and skill.trueName == "slash_skill"
|
||||||
and scope == Player.HistoryPhase then
|
and scope == Player.HistoryPhase then
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue