From 520120220dbb134f11d0d9b09cf24c4fca04fa98 Mon Sep 17 00:00:00 2001 From: xxyheaven <1433191064@qq.com> Date: Thu, 2 May 2024 13:27:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=8A=80=E8=A7=86?= =?UTF-8?q?=E4=B8=BA=E4=B8=8D=E5=9C=A8=E6=94=BB=E5=87=BB=E8=8C=83=E5=9B=B4?= =?UTF-8?q?=E5=86=85=EF=BC=9B=E4=BB=8E=E7=89=8C=E5=A0=86=E4=BA=AE=E5=87=BA?= =?UTF-8?q?=E7=89=8Clog=EF=BC=9B=E8=AF=B8=E8=91=9B=E8=BF=9E=E5=BC=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/client/client.lua | 43 ++++++++++++++++++++++------ lua/client/i18n/zh_CN.lua | 3 ++ lua/core/player.lua | 5 ++++ lua/core/skill_type/attack_range.lua | 10 +++++++ lua/fk_ex.lua | 7 ++++- lua/server/serverplayer.lua | 7 +---- standard_cards/init.lua | 15 +++++++--- 7 files changed, 70 insertions(+), 20 deletions(-) diff --git a/lua/client/client.lua b/lua/client/client.lua index 4942941..f6296ee 100644 --- a/lua/client/client.lua +++ b/lua/client/client.lua @@ -495,14 +495,20 @@ local function separateMoves(moves) for _, move in ipairs(moves) do local singleVisible = move.moveVisible - if move.visiblePlayers and not singleVisible then - local visiblePlayers = move.visiblePlayers - if type(visiblePlayers) == "number" then - if Self:isBuddy(visiblePlayers) then - singleVisible = true + if not singleVisible then + if move.visiblePlayers then + local visiblePlayers = move.visiblePlayers + if type(visiblePlayers) == "number" then + if Self:isBuddy(visiblePlayers) then + singleVisible = true + end + elseif type(visiblePlayers) == "table" then + if table.find(visiblePlayers, function(pid) return Self:isBuddy(pid) end) then + singleVisible = true + end end - elseif type(visiblePlayers) == "table" then - if table.find(visiblePlayers, function(pid) return Self:isBuddy(pid) end) then + else + if move.to and move.toArea == Card.PlayerSpecial and Self:isBuddy(move.to) then singleVisible = true end end @@ -646,8 +652,27 @@ local function sendMoveCardLog(move) from = move.from, card = move.ids, } - -- elseif move.toArea == Card.Processing then - -- nop + elseif move.toArea == Card.Processing then + if move.fromArea == Card.DrawPile and (move.moveReason == fk.ReasonPut or move.moveReason == fk.ReasonJustMove) then + if hidden then + client:appendLog{ + type = "$ViewCardFromDrawPile", + from = move.proposer, + arg = #move.ids, + } + else + client:appendLog{ + type = "$TurnOverCardFromDrawPile", + from = move.proposer, + card = move.ids, + arg = #move.ids, + } + client:setCardNote(move.ids, { + type = "$$TurnOverCard", + from = move.proposer, + }) + end + end elseif move.from and move.toArea == Card.DrawPile then msgtype = hidden and "$PutCard" or "$PutKnownCard" client:appendLog{ diff --git a/lua/client/i18n/zh_CN.lua b/lua/client/i18n/zh_CN.lua index 369c60b..3b90079 100644 --- a/lua/client/i18n/zh_CN.lua +++ b/lua/client/i18n/zh_CN.lua @@ -435,6 +435,8 @@ Fk:loadTranslationTable{ ["$DiscardCards"] = "%from 弃置了 %arg 张牌 %card", ["$DiscardOther"] = "%to 弃置了 %from 的 %arg 张牌 %card", ["$PutToDiscard"] = "%arg 张牌 %card 被置入弃牌堆", + ["$ViewCardFromDrawPile"] = "%from 观看了 %arg 张牌", + ["$TurnOverCardFromDrawPile"] = "%from 亮出了 %arg 张牌 %card", ["#AbortArea"] = "%from 的 %arg 被废除", ["#ResumeArea"] = "%from 的 %arg 被恢复", @@ -510,6 +512,7 @@ Fk:loadTranslationTable{ Fk:loadTranslationTable{ ["$$DiscardCards"] = "%from弃置", ["$$PutCard"] = "%from置于", + ["$$TurnOverCard"] = "%from亮出", ["##UseCard"] = "%from使用", ["##UseCardTo"] = "%from对%to", diff --git a/lua/core/player.lua b/lua/core/player.lua index 5db1ea3..4d231bc 100644 --- a/lua/core/player.lua +++ b/lua/core/player.lua @@ -590,6 +590,11 @@ function Player:inMyAttackRange(other, fixLimit) fixLimit = fixLimit or 0 local status_skills = Fk:currentRoom().status_skills[AttackRangeSkill] or Util.DummyTable + for _, skill in ipairs(status_skills) do + if skill:withoutAttackRange(self, other) then + return false + end + end for _, skill in ipairs(status_skills) do if skill:withinAttackRange(self, other) then return true diff --git a/lua/core/skill_type/attack_range.lua b/lua/core/skill_type/attack_range.lua index aa48de0..66fe792 100644 --- a/lua/core/skill_type/attack_range.lua +++ b/lua/core/skill_type/attack_range.lua @@ -15,8 +15,18 @@ function AttackRangeSkill:getFixed(from) return nil end +---@param from Player +---@param to Player +---@return boolean function AttackRangeSkill:withinAttackRange(from, to) return false end +---@param from Player +---@param to Player +---@return boolean +function AttackRangeSkill:withoutAttackRange(from, to) + return false +end + return AttackRangeSkill diff --git a/lua/fk_ex.lua b/lua/fk_ex.lua index 9c0f31c..074ef05 100644 --- a/lua/fk_ex.lua +++ b/lua/fk_ex.lua @@ -335,12 +335,14 @@ end ---@field public correct_func? fun(self: AttackRangeSkill, from: Player, to: Player): number? ---@field public fixed_func? fun(self: AttackRangeSkill, player: Player): number? ---@field public within_func? fun(self: AttackRangeSkill, from: Player, to: Player): boolean? +---@field public without_func? fun(self: AttackRangeSkill, from: Player, to: Player): boolean? ---@param spec AttackRangeSpec ---@return AttackRangeSkill function fk.CreateAttackRangeSkill(spec) assert(type(spec.name) == "string") - assert(type(spec.correct_func) == "function" or type(spec.fixed_func) == "function" or type(spec.within_func) == "function") + assert(type(spec.correct_func) == "function" or type(spec.fixed_func) == "function" or + type(spec.within_func) == "function" or type(spec.without_func) == "function") local skill = AttackRangeSkill:new(spec.name) readStatusSpecToSkill(skill, spec) @@ -353,6 +355,9 @@ function fk.CreateAttackRangeSkill(spec) if spec.within_func then skill.withinAttackRange = spec.within_func end + if spec.without_func then + skill.withoutAttackRange = spec.without_func + end return skill end diff --git a/lua/server/serverplayer.lua b/lua/server/serverplayer.lua index b6d1e44..519936c 100644 --- a/lua/server/serverplayer.lua +++ b/lua/server/serverplayer.lua @@ -602,13 +602,8 @@ end ---@param visible? boolean ---@param skillName? string ---@param proposer? integer ----@param visiblePlayers? integer | integer[] +---@param visiblePlayers? integer | integer[] @ 为nil时默认对自己可见 function ServerPlayer:addToPile(pile_name, card, visible, skillName, proposer, visiblePlayers) - if type(visiblePlayers) == "table" and #visiblePlayers == 0 then - visiblePlayers = nil - elseif visiblePlayers == nil then - visiblePlayers = self.id - end self.room:moveCardTo(card, Card.PlayerSpecial, self, fk.ReasonJustMove, skillName, pile_name, visible, proposer or self.id, nil, visiblePlayers) end diff --git a/standard_cards/init.lua b/standard_cards/init.lua index 962e3d1..e2879c3 100644 --- a/standard_cards/init.lua +++ b/standard_cards/init.lua @@ -622,6 +622,7 @@ local amazingGraceSkill = fk.CreateActiveSkill{ ids = toDisplay, toArea = Card.Processing, moveReason = fk.ReasonPut, + proposer = use.from, }) table.forEach(room.players, function(p) @@ -816,10 +817,16 @@ local crossbowAudio = fk.CreateTriggerSkill{ local crossbowSkill = fk.CreateTargetModSkill{ name = "#crossbow_skill", attached_equip = "crossbow", - bypass_times = function(self, player, skill, scope) - if player:hasSkill(self) and skill.trueName == "slash_skill" - and scope == Player.HistoryPhase then - return true + bypass_times = function(self, player, skill, scope, card) + if player:hasSkill(self) and skill.trueName == "slash_skill" and scope == Player.HistoryPhase then + --FIXME: 无法检测到非转化的cost选牌的情况,如活墨等 + local cardIds = Card:getIdList(card) + local crossbows = table.filter(player:getEquipments(Card.SubtypeWeapon), function(id) + return Fk:getCardById(id).equip_skill == self + end) + return #crossbows == 0 or not table.every(crossbows, function(id) + return table.contains(cardIds, id) + end) end end, } -- Gitee From dc96ae1ab8644d3fd299ff22d7a480d41f4facc8 Mon Sep 17 00:00:00 2001 From: xxyheaven <1433191064@qq.com> Date: Thu, 2 May 2024 13:52:15 +0800 Subject: [PATCH 2/2] fix --- standard/init.lua | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/standard/init.lua b/standard/init.lua index 44aed8d..9409209 100644 --- a/standard/init.lua +++ b/standard/init.lua @@ -13,11 +13,7 @@ local jianxiong = fk.CreateTriggerSkill{ anim_type = "masochism", events = {fk.Damaged}, can_trigger = function(self, event, target, player, data) - if target == player and player:hasSkill(self) and data.card then - local room = player.room - local subcards = data.card:isVirtual() and data.card.subcards or {data.card.id} - return #subcards>0 and table.every(subcards, function(id) return room:getCardArea(id) == Card.Processing end) - end + return target == player and player:hasSkill(self) and data.card and player.room:getCardArea(data.card) == Card.Processing end, on_use = function(self, event, target, player, data) player.room:obtainCard(player.id, data.card, true, fk.ReasonJustMove) @@ -157,11 +153,11 @@ local tuxi = fk.CreateTriggerSkill{ events = {fk.EventPhaseStart}, can_trigger = function(self, event, target, player, data) return target == player and player:hasSkill(self) and player.phase == Player.Draw and - table.find(player.room:getOtherPlayers(player), function(p) return not p:isKongcheng() end) + table.find(player.room:getOtherPlayers(player, false), function(p) return not p:isKongcheng() end) end, on_cost = function(self, event, target, player, data) local room = player.room - local targets = table.map(table.filter(room:getOtherPlayers(player), function(p) + local targets = table.map(table.filter(room:getOtherPlayers(player, false), function(p) return not p:isKongcheng() end), Util.IdMapper) local result = room:askForChoosePlayers(player, targets, 1, 2, "#tuxi-ask", self.name) @@ -994,8 +990,8 @@ local qingnang = fk.CreateActiveSkill{ card_num = 1, on_use = function(self, room, effect) local from = room:getPlayerById(effect.from) - room:throwCard(effect.cards, self.name, from, from) local to = room:getPlayerById(effect.tos[1]) + room:throwCard(effect.cards, self.name, from, from) if to:isAlive() and to:isWounded() then room:recover({ who = to, @@ -1073,7 +1069,9 @@ local lijian = fk.CreateActiveSkill{ end, target_filter = function(self, to_select, selected) if #selected < 2 and to_select ~= Self.id then - return Fk:currentRoom():getPlayerById(to_select):isMale() + local target = Fk:currentRoom():getPlayerById(to_select) + return target:isMale() and (#selected == 0 or + target:canUseTo(Fk:cloneCard("duel"), Fk:currentRoom():getPlayerById(selected[1]))) end end, target_num = 2, -- Gitee