From 3a207442f4205f495dbfa0939ea210283d074b01 Mon Sep 17 00:00:00 2001 From: YoumuKon <38815081+YoumuKon@users.noreply.github.com> Date: Sun, 13 Aug 2023 15:05:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E4=BF=AE=E5=B0=8F=E8=A1=A5=20(#250)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 初步添加武将牌堆 - 为长度为2的表做了特判 - 修复了火攻后木马回不来的bug --- Fk/Pages/Room.qml | 3 +++ lua/core/util.lua | 12 +++++++++--- lua/server/room.lua | 4 +++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Fk/Pages/Room.qml b/Fk/Pages/Room.qml index abec251f..74d68abd 100644 --- a/Fk/Pages/Room.qml +++ b/Fk/Pages/Room.qml @@ -330,6 +330,7 @@ Item { dashboard.disableSkills(); dashboard.retractAllPiles(); selected_targets = []; + autoPending = false; if (popupBox.item != null) { popupBox.item.finished(); @@ -348,6 +349,7 @@ Item { dashboard.enableSkills(); progress.visible = true; okCancel.visible = true; + autoPending = false; endPhaseButton.visible = true; respond_play = false; } @@ -379,6 +381,7 @@ Item { dashboard.disableSkills(); progress.visible = true; respond_play = false; + autoPending = false; roomScene.okCancel.visible = false; roomScene.okButton.enabled = false; roomScene.cancelButton.enabled = false; diff --git a/lua/core/util.lua b/lua/core/util.lua index 85658b73..d994b1cc 100644 --- a/lua/core/util.lua +++ b/lua/core/util.lua @@ -187,9 +187,15 @@ function table:contains(element) end function table:shuffle() - for i = #self, 2, -1 do - local j = math.random(i) - self[i], self[j] = self[j], self[i] + if #self == 2 then + if math.random() < 0.5 then + self[1], self[2] = self[2], self[1] + end + else + for i = #self, 2, -1 do + local j = math.random(i) + self[i], self[j] = self[j], self[i] + end end end diff --git a/lua/server/room.lua b/lua/server/room.lua index 5604a5ff..cac56746 100644 --- a/lua/server/room.lua +++ b/lua/server/room.lua @@ -19,6 +19,7 @@ ---@field public discard_pile integer[] @ 弃牌堆,也是卡牌id的数组 ---@field public processing_area integer[] @ 处理区,依然是卡牌id数组 ---@field public void integer[] @ 从游戏中除外区,一样的是卡牌id数组 +---@field public general_pile string[] @ 武将牌堆,这是武将名的数组 ---@field public card_place table @ 每个卡牌的id对应的区域,一张表 ---@field public owner_map table @ 每个卡牌id对应的主人,表的值是那个玩家的id,可能是nil ---@field public status_skills Skill[] @ 这个房间中含有的状态技列表 @@ -80,6 +81,7 @@ function Room:initialize(_room) self.discard_pile = {} self.processing_area = {} self.void = {} + self.general_pile = {} self.card_place = {} self.owner_map = {} self.status_skills = {} @@ -803,7 +805,7 @@ function Room:notifyMoveCards(players, card_moves, forceVisible) -- if move is relevant to player's hands or equips, it should be open -- cards move from/to equip/judge/discard/processing should be open - if not (move.moveVisible or forceVisible or containArea(move.toArea, move.to and p:isBuddy(move.to))) then + if not (move.moveVisible or forceVisible or containArea(move.toArea, move.to and p.isBuddy and p:isBuddy(move.to))) then for _, info in ipairs(move.moveInfo) do if not containArea(info.fromArea, move.from == p.id) then info.cardId = -1