From 930826e66417656958ba37cea1480ff7f11e133e Mon Sep 17 00:00:00 2001 From: notify Date: Fri, 28 Apr 2023 10:27:56 +0800 Subject: [PATCH] Fixbug (#139) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了无法聊天 修复拼点没赢时双方都没赢 修复了被拼点的人无法选牌(或许吧 --- freekill.desktop | 1 + lua/client/i18n/zh_CN.lua | 4 +++ lua/server/events/pindian.lua | 56 ++++++++++++++++++++++------------- qml/Pages/Room.qml | 6 ++-- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/freekill.desktop b/freekill.desktop index 74c28f31..feb90e62 100755 --- a/freekill.desktop +++ b/freekill.desktop @@ -7,3 +7,4 @@ Icon=freekill_logo Exec=/usr/bin/FreeKill Type=Application Terminal=false +Categories=Game diff --git a/lua/client/i18n/zh_CN.lua b/lua/client/i18n/zh_CN.lua index d38d048e..0e4c64f7 100644 --- a/lua/client/i18n/zh_CN.lua +++ b/lua/client/i18n/zh_CN.lua @@ -151,6 +151,10 @@ FreeKill使用的是libgit2的C API,与此同时使用Git完成拓展包的下 ["#AskForCard"] = "请选择 %arg 张牌,最少 %arg2 张", ["#askForPindian"] = "请选择一张手牌作为拼点牌", ["#StartPindianReason"] = "%from 由于 %arg 而发起拼点", + ["#ShowPindianCard"] = "%from 的拼点牌是 %card", + ["#ShowPindianResult"] = "%from 在 %from 和 %to 之间的拼点中 %arg", + ["pindianwin"] = "赢", + ["pindiannotwin"] = "没赢", ["#RevealGeneral"] = "%from 亮出 %arg %arg2", ["mainGeneral"] = "主将", diff --git a/lua/server/events/pindian.lua b/lua/server/events/pindian.lua index b483c461..d71998f3 100644 --- a/lua/server/events/pindian.lua +++ b/lua/server/events/pindian.lua @@ -2,11 +2,12 @@ GameEvent.functions[GameEvent.Pindian] = function(self) local pindianData = table.unpack(self.data) - local self = self.room - self.logic:trigger(fk.StartPindian, pindianData.from, pindianData) + local room = self.room + local logic = room.logic + logic:trigger(fk.StartPindian, pindianData.from, pindianData) if pindianData.reason ~= "" then - self:sendLog{ + room:sendLog{ type = "#StartPindianReason", from = pindianData.from.id, arg = pindianData.reason, @@ -17,7 +18,8 @@ GameEvent.functions[GameEvent.Pindian] = function(self) num = 1, min_num = 1, include_equip = false, - reason = pindianData.reason + pattern = ".", + reason = pindianData.reason, } local prompt = "#askForPindian" local data = { "choose_cards_skill", prompt, true, json.encode(extraData) } @@ -34,8 +36,8 @@ GameEvent.functions[GameEvent.Pindian] = function(self) end end - self:notifyMoveFocus(targets, "AskForPindian") - self:doBroadcastRequest("AskForUseActiveSkill", targets) + room:notifyMoveFocus(targets, "AskForPindian") + room:doBroadcastRequest("AskForUseActiveSkill", targets) local moveInfos = {} for _, p in ipairs(targets) do @@ -62,53 +64,67 @@ GameEvent.functions[GameEvent.Pindian] = function(self) skillName = pindianData.reason, moveVisible = true, }) + + room:sendLog{ + type = "#ShowPindianCard", + from = p.id, + card = { pindianCard.id }, + } end - self:moveCards(table.unpack(moveInfos)) + room:moveCards(table.unpack(moveInfos)) - self.logic:trigger(fk.PindianCardsDisplayed, nil, pindianData) + logic:trigger(fk.PindianCardsDisplayed, nil, pindianData) for toId, result in pairs(pindianData.results) do + local to = room:getPlayerById(toId) if pindianData.fromCard.number > result.toCard.number then - pindianData.results[toId].winner = pindianData.from - elseif pindianData.fromCard.number > result.toCard.number then - pindianData.results[toId].winner = Fk:getCardById(toId) + result.winner = pindianData.from + elseif pindianData.fromCard.number < result.toCard.number then + result.winner = to end local singlePindianData = { from = pindianData.from, - to = self:getPlayerById(toId), + to = to, fromCard = pindianData.fromCard, toCard = result.toCard, - winner = pindianData.results[toId].winner, + winner = result.winner, } - self.logic:trigger(fk.PindianResultConfirmed, nil, singlePindianData) + + room:sendLog{ + type = "#ShowPindianResult", + from = pindianData.from.id, + to = { toId }, + arg = result.winner == pindianData.from and "pindianwin" or "pindiannotwin" + } + logic:trigger(fk.PindianResultConfirmed, nil, singlePindianData) end - if self.logic:trigger(fk.PindianFinished, pindianData.from, pindianData) then - self.logic:breakEvent() + if logic:trigger(fk.PindianFinished, pindianData.from, pindianData) then + logic:breakEvent() end end GameEvent.cleaners[GameEvent.Pindian] = function(self) local pindianData = table.unpack(self.data) - local self = self.room + local room = self.room local toProcessingArea = {} - local leftFromCardIds = self:getSubcardsByRule(pindianData.fromCard, { Card.Processing }) + local leftFromCardIds = room:getSubcardsByRule(pindianData.fromCard, { Card.Processing }) if #leftFromCardIds > 0 then table.insertTable(toProcessingArea, leftFromCardIds) end for _, result in pairs(pindianData.results) do - local leftToCardIds = self:getSubcardsByRule(result.toCard, { Card.Processing }) + local leftToCardIds = room:getSubcardsByRule(result.toCard, { Card.Processing }) if #leftToCardIds > 0 then table.insertTable(toProcessingArea, leftToCardIds) end end if #toProcessingArea > 0 then - self:moveCards({ + room:moveCards({ ids = toProcessingArea, toArea = Card.DiscardPile, moveReason = fk.ReasonPutIntoDiscardPile, diff --git a/qml/Pages/Room.qml b/qml/Pages/Room.qml index 83a2085e..9a9fa3d9 100644 --- a/qml/Pages/Room.qml +++ b/qml/Pages/Room.qml @@ -684,7 +684,7 @@ Item { if (specialChat(pid, raw, raw.msg.slice(1))) return; } chat.append(msg); - let photo = Logic.getPhotoOrSelf(pid); + let photo = Logic.getPhoto(pid); if (photo === undefined) { let user = raw.userName; let m = raw.msg; @@ -727,7 +727,7 @@ Item { else chat.append(`[${time}] ${userName}(${general}): ${m}`); - let photo = Logic.getPhotoOrSelf(pid); + let photo = Logic.getPhoto(pid); if (photo === undefined) { danmaku.sendLog(`${userName}: ${m}`); return true; @@ -752,7 +752,7 @@ Item { else chat.append(`[${time}] ${userName}(${general}): ${m}`); - let photo = Logic.getPhotoOrSelf(pid); + let photo = Logic.getPhoto(pid); if (photo === undefined) { danmaku.sendLog(`${userName}: ${m}`); return true;