diff --git a/Fk/PhotoElement/EquipArea.qml b/Fk/PhotoElement/EquipArea.qml index 53359e9a..01dd735f 100644 --- a/Fk/PhotoElement/EquipArea.qml +++ b/Fk/PhotoElement/EquipArea.qml @@ -12,7 +12,7 @@ import Fk.RoomElement +---------------+ */ -Column { +Item { id: root height: 70 @@ -22,6 +22,9 @@ Column { property var subtypes: ["treasure", "weapon", "armor", "defensive_horse", "offensive_horse"] property int length: area.length + // FIXME: Qt 6.6 +Column { + anchors.fill: parent InvisibleCardArea { id: area anchors.centerIn: parent @@ -56,7 +59,7 @@ Column { } Row { - width: parent.width + width: root.width height: itemHeight Item { @@ -87,6 +90,7 @@ Column { } } } +} function add(inputs) { diff --git a/Fk/RoomElement/TablePile.qml b/Fk/RoomElement/TablePile.qml index cd5a7a23..e9393a47 100644 --- a/Fk/RoomElement/TablePile.qml +++ b/Fk/RoomElement/TablePile.qml @@ -75,14 +75,17 @@ Item { let i, j; let result = area.remove(outputs); - for (let i = 0; i < result.length; i++) { - const c = result[i]; + result.forEach(c => { + const idx = discardedCards.indexOf(c); + if (idx !== -1) { + discardedCards.splice(idx, 1); + } c.footnoteVisible = false; c.selectable = false; c.height = c.height / 0.8; c.width = c.width / 0.8; // c.rotation = 0; - } + }); const vanished = []; if (result.length < outputs.length) { for (i = 0; i < outputs.length; i++) { diff --git a/lua/core/engine.lua b/lua/core/engine.lua index 90a9ec57..c9d33f53 100644 --- a/lua/core/engine.lua +++ b/lua/core/engine.lua @@ -16,6 +16,7 @@ ---@field public generals table @ 所有武将 ---@field public same_generals table @ 所有同名武将组合 ---@field public lords string[] @ 所有主公武将,用于常备主公 +---@field public all_card_types table @ 所有的卡牌类型以及一张样板牌 ---@field public cards Card[] @ 所有卡牌 ---@field public translations table> @ 翻译表 ---@field public game_modes table @ 所有游戏模式 @@ -50,6 +51,7 @@ function Engine:initialize() self.generals = {} -- name --> General self.same_generals = {} self.lords = {} -- lordName[] + self.all_card_types = {} self.cards = {} -- Card[] self.translations = {} -- srcText --> translated self.game_modes = {} @@ -277,7 +279,6 @@ function Engine:getSameGenerals(name) end local cardId = 1 -local _card_name_table = {} --- 向Engine中加载一张卡牌。 --- @@ -288,8 +289,8 @@ function Engine:addCard(card) card.id = cardId cardId = cardId + 1 table.insert(self.cards, card) - if _card_name_table[card.name] == nil then - _card_name_table[card.name] = card + if self.all_card_types[card.name] == nil then + self.all_card_types[card.name] = card end end @@ -309,7 +310,7 @@ end ---@param number integer|nil @ 点数 ---@return Card function Engine:cloneCard(name, suit, number) - local cd = _card_name_table[name] + local cd = self.all_card_types[name] assert(cd, "Attempt to clone a card that not added to engine") local ret = cd:clone(suit, number) ret.package = cd.package diff --git a/lua/server/events/gameflow.lua b/lua/server/events/gameflow.lua index 835ba459..22559c7a 100644 --- a/lua/server/events/gameflow.lua +++ b/lua/server/events/gameflow.lua @@ -141,8 +141,15 @@ GameEvent.functions[GameEvent.Round] = function(self) if isFirstRound then room:setTag("FirstRound", false) end - room:setTag("RoundCount", room:getTag("RoundCount") + 1) - room:doBroadcastNotify("UpdateRoundNum", room:getTag("RoundCount")) + + local roundCount = room:getTag("RoundCount") + roundCount = roundCount + 1 + room:setTag("RoundCount", roundCount) + room:doBroadcastNotify("UpdateRoundNum", roundCount) + -- 强行平局 防止can_trigger报错导致瞬间几十万轮卡炸服务器 + if roundCount >= 9999 then + room:gameOver("") + end if isFirstRound then logic:trigger(fk.GameStart, room.current) diff --git a/lua/server/events/usecard.lua b/lua/server/events/usecard.lua index c411f9a5..29caf8d7 100644 --- a/lua/server/events/usecard.lua +++ b/lua/server/events/usecard.lua @@ -185,6 +185,8 @@ GameEvent.functions[GameEvent.UseCard] = function(self) local room = self.room local logic = room.logic + sendCardEmotionAndLog(room, cardUseEvent) + room:moveCardTo(cardUseEvent.card, Card.Processing, nil, fk.ReasonUse) if cardUseEvent.card.skill then @@ -195,8 +197,6 @@ GameEvent.functions[GameEvent.UseCard] = function(self) logic:breakEvent() end - sendCardEmotionAndLog(room, cardUseEvent) - if not cardUseEvent.extraUse then room:getPlayerById(cardUseEvent.from):addCardUseHistory(cardUseEvent.card.trueName, 1) end @@ -264,6 +264,9 @@ GameEvent.functions[GameEvent.RespondCard] = function(self) card = cardIds, } end + + playCardEmotionAndSound(room, room:getPlayerById(from), card) + room:moveCardTo(card, Card.Processing, nil, fk.ReasonResonpse) if #cardIds > 0 then room:sendFootnote(cardIds, { @@ -279,8 +282,6 @@ GameEvent.functions[GameEvent.RespondCard] = function(self) logic:breakEvent() end - playCardEmotionAndSound(room, room:getPlayerById(from), card) - logic:trigger(fk.CardResponding, room:getPlayerById(cardResponseEvent.from), cardResponseEvent) end diff --git a/lua/server/request.lua b/lua/server/request.lua index eaa6c270..8469fe95 100644 --- a/lua/server/request.lua +++ b/lua/server/request.lua @@ -155,11 +155,19 @@ request_handlers["surrender"] = function(room, id, reqlist) local logic = room.logic local curEvent = logic:getCurrentEvent() if curEvent then - curEvent:addExitFunc( + curEvent:addCleaner( function() player.surrendered = true room:broadcastProperty(player, "surrendered") - room:gameOver(Fk.game_modes[room.settings.gameMode]:getWinner(player)) + local mode = Fk.game_modes[room.settings.gameMode] + local winner = Pcall(mode.getWinner, mode, player) + if winner ~= nil then + room:gameOver(winner) + end + + -- 以防万一 + player.surrendered = false + room.hasSurrendered = false end ) room.hasSurrendered = true diff --git a/lua/server/serverplayer.lua b/lua/server/serverplayer.lua index 0fcbfce9..ee7fcafe 100644 --- a/lua/server/serverplayer.lua +++ b/lua/server/serverplayer.lua @@ -180,6 +180,7 @@ function ServerPlayer:waitForReply(timeout) self.serverplayer:setThinking(false) end + -- FIXME: 一控多求无懈 local queue = self.room.request_queue[self.serverplayer] if queue and #queue > 0 and not self.serverplayer:busy() then local i, c, j, t = table.unpack(table.remove(queue, 1))