From 8d87fbbf09f53bd947d0e81823fc2018f23ec9de Mon Sep 17 00:00:00 2001 From: Nyutanislavsky Date: Sat, 13 May 2023 13:23:18 +0800 Subject: [PATCH] Fixbug (#144) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 视为技添加frequency(为了显示限定技) 修复主动技canUse (by @Ho-spair ) Exppattern增加子类别 增加体力上限相关的log 增加求桃prompt 修复许褚、夏侯惇(by @xxyheaven )和赵云 移除观星一张牌直接放在牌堆顶 添加获得牌的log(和摸牌区分开) 封装重铸(和以技能重铸)函数 --------- Signed-off-by: Mechanel --- lua/client/client.lua | 10 +++++++++- lua/client/i18n/zh_CN.lua | 11 +++++++++-- lua/core/skill_type/view_as.lua | 4 ++-- lua/fk_ex.lua | 6 +++--- lua/server/events/hp.lua | 13 +++++++++++++ lua/server/room.lua | 32 +++++++++++++++++++++++++++----- packages/maneuvering/init.lua | 15 +-------------- packages/standard/game_rule.lua | 4 +++- packages/standard/init.lua | 24 +++++++++++++++--------- 9 files changed, 82 insertions(+), 37 deletions(-) diff --git a/lua/client/client.lua b/lua/client/client.lua index c909f71a..614877fa 100644 --- a/lua/client/client.lua +++ b/lua/client/client.lua @@ -414,13 +414,21 @@ local function sendMoveCardLog(move) arg2 = #move.ids, card = move.ids, } - elseif move.fromArea == Card.DrawPile and move.toArea == Card.PlayerHand then + elseif move.moveReason == fk.ReasonDraw then ClientInstance:appendLog{ type = "$DrawCards", from = move.to, card = move.ids, arg = #move.ids, } + elseif (move.fromArea == Card.DrawPile or move.fromArea == Card.DiscardPile) + and move.moveReason == fk.ReasonPrey then + ClientInstance:appendLog{ + type = "$PreyCardsFromPile", + from = move.to, + card = move.ids, + arg = #move.ids, + } elseif (move.fromArea == Card.Processing or move.fromArea == Card.PlayerJudge) and move.toArea == Card.PlayerHand then ClientInstance:appendLog{ diff --git a/lua/client/i18n/zh_CN.lua b/lua/client/i18n/zh_CN.lua index 1ca448fc..c39f388f 100644 --- a/lua/client/i18n/zh_CN.lua +++ b/lua/client/i18n/zh_CN.lua @@ -155,6 +155,8 @@ FreeKill使用的是libgit2的C API,与此同时使用Git完成拓展包的下 ["#AskForResponseCard"] = "请打出卡牌 %1", ["#AskForNullification"] = "是否为目标为 %dest 的 %arg 使用无懈可击?", ["#AskForNullificationWithoutTo"] = "是否对 %src 使用的 %arg 使用无懈可击?", + ["#AskForPeaches"] = "%src 生命危急,需要 %arg 个桃", + ["#AskForPeachesSelf"] = "你生命危急,需要 %arg 个桃或酒", ["#AskForDiscard"] = "请弃置 %arg 张牌,最少 %arg2 张", ["#AskForCard"] = "请选择 %arg 张牌,最少 %arg2 张", @@ -206,10 +208,12 @@ Fk:loadTranslationTable{ ["thunder_damage"] = "雷属性", ["ice_damage"] = "冰属性", + ["phase_start"] = "准备阶段", ["phase_judge"] = "判定阶段", ["phase_draw"] = "摸牌阶段", ["phase_play"] = "出牌阶段", ["phase_discard"] = "弃牌阶段", + ["phase_finish"] = "结束阶段", ["chained"] = "横置", ["not-chained"] = "重置", @@ -223,8 +227,8 @@ Fk:loadTranslationTable{ ["$GameEnd"] = "== 游戏结束 ==", -- get/lose skill - ["#AcquireSkill"] = "%from 获得了技能“%arg”", - ["#LoseSkill"] = "%from 失去了技能“%arg”", + ["#AcquireSkill"] = "%from 获得了技能 “%arg”", + ["#LoseSkill"] = "%from 失去了技能 “%arg”", -- moveCards (they are sent by notifyMoveCards) ["$PutCard"] = "%from 的 %arg 张牌被置于牌堆顶", @@ -233,6 +237,7 @@ Fk:loadTranslationTable{ ["$AddToPile"] = "%card 被作为 %arg 移出游戏", ["$GetCardsFromPile"] = "%from 从 %arg 中获得了 %arg2 张牌 %card", ["$DrawCards"] = "%from 摸了 %arg 张牌 %card", + ["$PreyCardsFromPile"] = "%from 获得了 %arg 张牌 %card", ["$GotCardBack"] = "%from 收回了 %arg 张牌 %card", ["$RecycleCard"] = "%from 从弃牌堆回收了 %arg 张牌 %card", ["$MoveCards"] = "%to 从 %from 处获得了 %arg 张牌 %card", @@ -288,6 +293,8 @@ Fk:loadTranslationTable{ ["#LoseHP"] = "%from 失去了 %arg 点体力", ["#HealHP"] = "%from 回复了 %arg 点体力", ["#ShowHPAndMaxHP"] = "%from 现在的体力值为 %arg,体力上限为 %arg2", + ["#LoseMaxHP"] = "%from 减了 %arg 点体力上限", + ["#HealMaxHP"] = "%from 加了 %arg 点体力上限", -- dying and death ["#EnterDying"] = "%from 进入了濒死阶段", diff --git a/lua/core/skill_type/view_as.lua b/lua/core/skill_type/view_as.lua index 225ffade..082cdfc1 100644 --- a/lua/core/skill_type/view_as.lua +++ b/lua/core/skill_type/view_as.lua @@ -5,8 +5,8 @@ ---@field public interaction any local ViewAsSkill = UsableSkill:subclass("ViewAsSkill") -function ViewAsSkill:initialize(name) - UsableSkill.initialize(self, name, Skill.NotFrequent) +function ViewAsSkill:initialize(name, frequency) + UsableSkill.initialize(self, name, frequency) self.pattern = "" end diff --git a/lua/fk_ex.lua b/lua/fk_ex.lua index 49525426..6bb9818f 100644 --- a/lua/fk_ex.lua +++ b/lua/fk_ex.lua @@ -162,8 +162,8 @@ function fk.CreateActiveSkill(spec) readUsableSpecToSkill(skill, spec) if spec.can_use then - skill.canUse = function(curSkill, player) - return spec.can_use(curSkill, player) and curSkill:isEffectable(player) + skill.canUse = function(curSkill, player, card) + return spec.can_use(curSkill, player, card) and curSkill:isEffectable(player) end end if spec.card_filter then skill.cardFilter = spec.card_filter end @@ -205,7 +205,7 @@ function fk.CreateViewAsSkill(spec) assert(type(spec.name) == "string") assert(type(spec.view_as) == "function") - local skill = ViewAsSkill:new(spec.name) + local skill = ViewAsSkill:new(spec.name, spec.frequency or Skill.NotFrequent) readUsableSpecToSkill(skill, spec) skill.viewAs = spec.view_as diff --git a/lua/server/events/hp.lua b/lua/server/events/hp.lua index bf25f2a7..df031549 100644 --- a/lua/server/events/hp.lua +++ b/lua/server/events/hp.lua @@ -228,6 +228,19 @@ GameEvent.functions[GameEvent.ChangeMaxHp] = function(self) end end + self:sendLog{ + type = num > 0 and "#HealMaxHP" or "#LoseMaxHP", + from = player.id, + arg = num > 0 and num or - num, + } + + self:sendLog{ + type = "#ShowHPAndMaxHP", + from = player.id, + arg = player.hp, + arg2 = player.maxHp, + } + self.logic:trigger(fk.MaxHpChanged, player, { num = num }) return true end diff --git a/lua/server/room.lua b/lua/server/room.lua index 35b07cd6..f1bd9b6b 100644 --- a/lua/server/room.lua +++ b/lua/server/room.lua @@ -1235,10 +1235,6 @@ function Room:askForGuanxing(player, cards, top_limit, bottom_limit) if #top_limit > 0 and #bottom_limit > 0 then assert(#cards >= top_limit[1] + bottom_limit[1] and #cards <= top_limit[2] + bottom_limit[2], "限定区间设置错误:可用空间不能容纳所有牌。") end - if #cards == 1 then - table.insert(self.draw_pile, 1, cards[1]) - return - end local command = "AskForGuanxing" self:notifyMoveFocus(player, command) local data = { @@ -2290,7 +2286,7 @@ function Room:retrial(card, player, judge, skillName, exchange) end end ---- 弃置一名玩家的牌。 +--- 弃置一名角色的牌。 ---@param card_ids integer[] @ 被弃掉的牌 ---@param skillName string @ 技能名 ---@param who ServerPlayer @ 被弃牌的人 @@ -2311,6 +2307,32 @@ function Room:throwCard(card_ids, skillName, who, thrower) }) end +--- 重铸一名角色的牌。 +---@param card_ids integer[] @ 被重铸的牌 +---@param who ServerPlayer @ 重铸的角色 +---@param skillName string @ 技能名,默认为“重铸” +function Room:recastCard(card_ids, who, skillName) + if type(card_ids) == "number" then + card_ids = {card_ids} + end + skillName = skillName or "recast" + self:moveCards({ + ids = card_ids, + from = who.id, + toArea = Card.DiscardPile, + skillName = skillName, + moveReason = fk.ReasonPutIntoDiscardPile, + proposer = who.id + }) + self:sendLog{ + type = skillName == "recast" and "#Recast" or "#RecastBySkill", + from = who.id, + card = card_ids, + arg = skillName, + } + self:drawCards(who, #card_ids, skillName) +end + --- 根据拼点信息开始拼点。 ---@param pindianData PindianStruct function Room:pindian(pindianData) diff --git a/packages/maneuvering/init.lua b/packages/maneuvering/init.lua index 54521005..a4b8957b 100644 --- a/packages/maneuvering/init.lua +++ b/packages/maneuvering/init.lua @@ -197,20 +197,7 @@ local recast = fk.CreateActiveSkill{ name = "recast", target_num = 0, on_use = function(self, room, effect) - local from = room:getPlayerById(effect.from) - room:moveCards({ - ids = effect.cards, - from = effect.from, - toArea = Card.DiscardPile, - skillName = "recast", - moveReason = fk.ReasonPutIntoDiscardPile, - }) - room:sendLog{ - type = "#Recast", - from = effect.from, - card = effect.cards, - } - room:drawCards(from, #effect.cards, self.name) + room:recastCard(effect.cards, room:getPlayerById(effect.from)) end } Fk:addSkill(recast) diff --git a/packages/standard/game_rule.lua b/packages/standard/game_rule.lua index d0b3c931..e6ce5978 100644 --- a/packages/standard/game_rule.lua +++ b/packages/standard/game_rule.lua @@ -69,11 +69,13 @@ GameRule = fk.CreateTriggerSkill{ local dyingPlayer = room:getPlayerById(data.who) while dyingPlayer.hp < 1 do local pattern = "peach" + local prompt = "#AskForPeaches:" .. dyingPlayer.id .. "::" .. tostring(1 - dyingPlayer.hp) if player == dyingPlayer then pattern = pattern .. ",analeptic" + prompt = "#AskForPeachesSelf:::" .. tostring(1 - dyingPlayer.hp) end - local peach_use = room:askForUseCard(player, "peach", pattern) + local peach_use = room:askForUseCard(player, "peach", pattern, prompt) if not peach_use then break end peach_use.tos = { {dyingPlayer.id} } if peach_use.card.trueName == "analeptic" then diff --git a/packages/standard/init.lua b/packages/standard/init.lua index 80488bd7..cb32619f 100644 --- a/packages/standard/init.lua +++ b/packages/standard/init.lua @@ -148,22 +148,21 @@ local ganglie = fk.CreateTriggerSkill{ anim_type = "masochism", events = {fk.Damaged}, can_trigger = function(self, event, target, player, data) - local room = target.room - return data.from ~= nil and - target == player and + return target == player and target:hasSkill(self.name) and not target.dead end, on_use = function(self, event, target, player, data) local room = player.room local from = data.from + if from then room:doIndicate(player.id, {from.id}) end local judge = { who = player, reason = self.name, - pattern = ".|.|spade,club,diamond", + pattern = ".|.|^heart", } room:judge(judge) - if judge.card.suit ~= Card.Heart then + if judge.card.suit ~= Card.Heart and from then local discards = room:askForDiscard(from, 2, 2, false, self.name, true) if #discards == 0 then room:damage{ @@ -236,8 +235,7 @@ local luoyi = fk.CreateTriggerSkill{ refresh_events = {fk.DamageCaused}, can_refresh = function(self, event, target, player, data) - if not (target == player and player:hasSkill(self.name) and - player:usedSkillTimes(self.name) > 0) then + if target ~= player or player:usedSkillTimes(self.name) == 0 then return end @@ -577,8 +575,16 @@ local longdan = fk.CreateViewAsSkill{ pattern = "slash,jink", card_filter = function(self, to_select, selected) if #selected == 1 then return false end - local c = Fk:getCardById(to_select) - return c.trueName == "slash" or c.name == "jink" + local _c = Fk:getCardById(to_select) + local c + if _c.trueName == "slash" then + c = Fk:cloneCard("jink") + elseif _c.name == "jink" then + c = Fk:cloneCard("slash") + else + return false + end + return (Fk.currentResponsePattern == nil and c.skill:canUse(Self)) or (Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(c)) end, view_as = function(self, cards) if #cards ~= 1 then