From e75836ff8dc1fa70edfe580d3e3ed48a73930b39 Mon Sep 17 00:00:00 2001 From: YoumuKon <38815081+YoumuKon@users.noreply.github.com> Date: Sun, 7 Apr 2024 00:51:29 +0800 Subject: [PATCH] bugfix (#339) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 改造常备主逻辑,现在常备主会根据可用多余将数调整 - 改良了getCardArea - 重新启用将框不足提醒 - 修复了司马懿问打出牌的bug - 修复了白名单武将不存在时无法创房的bug --------- Co-authored-by: notify --- Fk/LobbyElement/RoomGeneralSettings.qml | 4 ++- Fk/Pages/GeneralsOverview.qml | 4 +-- lua/client/client.lua | 33 ++++++++++++++----------- lua/client/client_util.lua | 2 +- lua/server/room.lua | 7 ++---- lua/server/system_enum.lua | 1 + packages/standard/init.lua | 11 +++++---- 7 files changed, 33 insertions(+), 29 deletions(-) diff --git a/Fk/LobbyElement/RoomGeneralSettings.qml b/Fk/LobbyElement/RoomGeneralSettings.qml index 0da41eda..575b2423 100644 --- a/Fk/LobbyElement/RoomGeneralSettings.qml +++ b/Fk/LobbyElement/RoomGeneralSettings.qml @@ -172,7 +172,9 @@ Flickable { arr = config.curScheme.banPkg[k]; if (arr.length !== 0) { const generals = lcall("GetGenerals", k); - disabledGenerals.push(...generals.filter(g => !arr.includes(g))); + if (generals.length !== 0) { + disabledGenerals.push(...generals.filter(g => !arr.includes(g))); + } } } for (k in config.curScheme.normalPkg) { diff --git a/Fk/Pages/GeneralsOverview.qml b/Fk/Pages/GeneralsOverview.qml index 51daf516..abb850e5 100644 --- a/Fk/Pages/GeneralsOverview.qml +++ b/Fk/Pages/GeneralsOverview.qml @@ -634,8 +634,8 @@ Item { function loadPackages() { if (loaded) return; - const _mods = lcall("GetAllModNames") - const modData = lcall("GetAllMods") + const _mods = lcall("GetAllModNames"); + const modData = lcall("GetAllMods"); const packs = lcall("GetAllGeneralPack"); _mods.forEach(name => { const pkgs = modData[name].filter(p => packs.includes(p) diff --git a/lua/client/client.lua b/lua/client/client.lua index 71ae114a..31b9ad03 100644 --- a/lua/client/client.lua +++ b/lua/client/client.lua @@ -66,25 +66,28 @@ function Client:getPlayerById(id) return nil end ----@param cardId integer | card +---@param cardId integer | Card ---@return CardArea function Client:getCardArea(cardId) - if type(cardId) ~= "number" then - assert(cardId and cardId:isInstanceOf(Card)) - cardId = cardId:getEffectiveId() - end - if table.contains(Self.player_cards[Player.Hand], cardId) then - return Card.PlayerHand - end - if table.contains(Self.player_cards[Player.Equip], cardId) then - return Card.PlayerEquip - end - for _, t in pairs(Self.special_cards) do - if table.contains(t, cardId) then - return Card.PlayerSpecial + local cardIds = Card:getIdList(cardId) + local resultPos = {} + for _, cid in ipairs(cardIds) do + if not table.contains(resultPos, Card.PlayerHand) and table.contains(Self.player_cards[Player.Hand], cid) then + table.insert(resultPos, Card.PlayerHand) + end + if not table.contains(resultPos, Card.PlayerEquip) and table.contains(Self.player_cards[Player.Equip], cid) then + table.insert(resultPos, Card.PlayerEquip) + end + for _, t in pairs(Self.special_cards) do + if table.contains(t, cid) then + table.insertIfNeed(resultPos, Card.PlayerSpecial) + end end end - error("Client:getCardArea can only judge cards in your hand or equip area") + if #resultPos == 1 then + return resultPos[1] + end + return Card.Unknown end function Client:moveCards(moves) diff --git a/lua/client/client_util.lua b/lua/client/client_util.lua index 3ec77179..b68bfd1d 100644 --- a/lua/client/client_util.lua +++ b/lua/client/client_util.lua @@ -151,7 +151,7 @@ function GetAllGeneralPack() end function GetGenerals(pack_name) - if not Fk.packages[pack_name] then return "{}" end + if not Fk.packages[pack_name] then return "[]" end local ret = {} for _, g in ipairs(Fk.packages[pack_name].generals) do if not g.total_hidden then diff --git a/lua/server/room.lua b/lua/server/room.lua index 789b4bf4..5e0933cf 100644 --- a/lua/server/room.lua +++ b/lua/server/room.lua @@ -265,11 +265,8 @@ end ---@param cardId integer | Card @ 要获得区域的那张牌,可以是Card或者一个id ---@return CardArea @ 这张牌的区域 function Room:getCardArea(cardId) - if type(cardId) ~= "number" then - assert(cardId and cardId:isInstanceOf(Card)) - cardId = cardId:getEffectiveId() - end - return self.card_place[cardId] or Card.Unknown + local cardIds = table.map(Card:getIdList(cardId), function(cid) return self.card_place[cid] or Card.Unknown end) + return #cardIds == 1 and cardIds[1] or Card.Unknown end --- 获得拥有某一张牌的玩家。 diff --git a/lua/server/system_enum.lua b/lua/server/system_enum.lua index 55b244cd..381c9751 100644 --- a/lua/server/system_enum.lua +++ b/lua/server/system_enum.lua @@ -71,6 +71,7 @@ fk.IceDamage = 4 ---@field public damageType? DamageType @ 伤害的属性 ---@field public skillName? string @ 造成本次伤害的技能名 ---@field public beginnerOfTheDamage? boolean @ 是否是本次铁索传导的起点 +---@field public by_user? boolean @ 是否由卡牌直接生效造成的伤害 --- 用来描述和回复体力有关的数据。 ---@class RecoverStruct diff --git a/packages/standard/init.lua b/packages/standard/init.lua index d1bc5d2a..3f0327a8 100644 --- a/packages/standard/init.lua +++ b/packages/standard/init.lua @@ -84,14 +84,14 @@ local guicai = fk.CreateTriggerSkill{ on_cost = function(self, event, target, player, data) local room = player.room local prompt = "#guicai-ask::" .. target.id - local card = room:askForResponse(player, self.name, ".|.|.|hand", prompt, true) - if card ~= nil then - self.cost_data = card + local card = room:askForCard(player, 1, 1, false, self.name, true, ".|.|.|hand", prompt) + if #card > 0 then + self.cost_data = card[1] return true end end, on_use = function(self, event, target, player, data) - player.room:retrial(self.cost_data, player, data, self.name) + player.room:retrial(Fk:getCardById(self.cost_data), player, data, self.name) end, } local fankui = fk.CreateTriggerSkill{ @@ -1119,7 +1119,7 @@ local role_getlogic = function() if lord ~= nil then room.current = lord local a1 = #room.general_pile - local a2 = #room.players * generalNum + lord_num + local a2 = #room.players * generalNum if a1 < a2 then room:sendLog{ type = "#NoEnoughGeneralDraw", @@ -1129,6 +1129,7 @@ local role_getlogic = function() } room:gameOver("") end + lord_num = math.min(a1 - a2, lord_num) local generals = table.connect(room:findGenerals(function(g) return table.find(Fk.generals[g].skills, function(s) return s.lordSkill end) end, lord_num), room:getNGenerals(generalNum))