修复一些小Bug (#279)

This commit is contained in:
notify 2023-10-18 21:46:11 +08:00 committed by GitHub
parent 6cc6dc93ef
commit 4d7359d834
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 17 deletions

View File

@ -12,7 +12,7 @@ import Fk.RoomElement
+---------------+ +---------------+
*/ */
Column { Item {
id: root id: root
height: 70 height: 70
@ -22,6 +22,9 @@ Column {
property var subtypes: ["treasure", "weapon", "armor", "defensive_horse", "offensive_horse"] property var subtypes: ["treasure", "weapon", "armor", "defensive_horse", "offensive_horse"]
property int length: area.length property int length: area.length
// FIXME: Qt 6.6
Column {
anchors.fill: parent
InvisibleCardArea { InvisibleCardArea {
id: area id: area
anchors.centerIn: parent anchors.centerIn: parent
@ -56,7 +59,7 @@ Column {
} }
Row { Row {
width: parent.width width: root.width
height: itemHeight height: itemHeight
Item { Item {
@ -87,6 +90,7 @@ Column {
} }
} }
} }
}
function add(inputs) function add(inputs)
{ {

View File

@ -75,14 +75,17 @@ Item {
let i, j; let i, j;
let result = area.remove(outputs); let result = area.remove(outputs);
for (let i = 0; i < result.length; i++) { result.forEach(c => {
const c = result[i]; const idx = discardedCards.indexOf(c);
if (idx !== -1) {
discardedCards.splice(idx, 1);
}
c.footnoteVisible = false; c.footnoteVisible = false;
c.selectable = false; c.selectable = false;
c.height = c.height / 0.8; c.height = c.height / 0.8;
c.width = c.width / 0.8; c.width = c.width / 0.8;
// c.rotation = 0; // c.rotation = 0;
} });
const vanished = []; const vanished = [];
if (result.length < outputs.length) { if (result.length < outputs.length) {
for (i = 0; i < outputs.length; i++) { for (i = 0; i < outputs.length; i++) {

View File

@ -16,6 +16,7 @@
---@field public generals table<string, General> @ 所有武将 ---@field public generals table<string, General> @ 所有武将
---@field public same_generals table<string, string[]> @ 所有同名武将组合 ---@field public same_generals table<string, string[]> @ 所有同名武将组合
---@field public lords string[] @ 所有主公武将,用于常备主公 ---@field public lords string[] @ 所有主公武将,用于常备主公
---@field public all_card_types table<string, Card> @ 所有的卡牌类型以及一张样板牌
---@field public cards Card[] @ 所有卡牌 ---@field public cards Card[] @ 所有卡牌
---@field public translations table<string, table<string, string>> @ 翻译表 ---@field public translations table<string, table<string, string>> @ 翻译表
---@field public game_modes table<string, GameMode> @ 所有游戏模式 ---@field public game_modes table<string, GameMode> @ 所有游戏模式
@ -50,6 +51,7 @@ function Engine:initialize()
self.generals = {} -- name --> General self.generals = {} -- name --> General
self.same_generals = {} self.same_generals = {}
self.lords = {} -- lordName[] self.lords = {} -- lordName[]
self.all_card_types = {}
self.cards = {} -- Card[] self.cards = {} -- Card[]
self.translations = {} -- srcText --> translated self.translations = {} -- srcText --> translated
self.game_modes = {} self.game_modes = {}
@ -277,7 +279,6 @@ function Engine:getSameGenerals(name)
end end
local cardId = 1 local cardId = 1
local _card_name_table = {}
--- 向Engine中加载一张卡牌。 --- 向Engine中加载一张卡牌。
--- ---
@ -288,8 +289,8 @@ function Engine:addCard(card)
card.id = cardId card.id = cardId
cardId = cardId + 1 cardId = cardId + 1
table.insert(self.cards, card) table.insert(self.cards, card)
if _card_name_table[card.name] == nil then if self.all_card_types[card.name] == nil then
_card_name_table[card.name] = card self.all_card_types[card.name] = card
end end
end end
@ -309,7 +310,7 @@ end
---@param number integer|nil @ 点数 ---@param number integer|nil @ 点数
---@return Card ---@return Card
function Engine:cloneCard(name, suit, number) 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") assert(cd, "Attempt to clone a card that not added to engine")
local ret = cd:clone(suit, number) local ret = cd:clone(suit, number)
ret.package = cd.package ret.package = cd.package

View File

@ -141,8 +141,15 @@ GameEvent.functions[GameEvent.Round] = function(self)
if isFirstRound then if isFirstRound then
room:setTag("FirstRound", false) room:setTag("FirstRound", false)
end 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 if isFirstRound then
logic:trigger(fk.GameStart, room.current) logic:trigger(fk.GameStart, room.current)

View File

@ -185,6 +185,8 @@ GameEvent.functions[GameEvent.UseCard] = function(self)
local room = self.room local room = self.room
local logic = room.logic local logic = room.logic
sendCardEmotionAndLog(room, cardUseEvent)
room:moveCardTo(cardUseEvent.card, Card.Processing, nil, fk.ReasonUse) room:moveCardTo(cardUseEvent.card, Card.Processing, nil, fk.ReasonUse)
if cardUseEvent.card.skill then if cardUseEvent.card.skill then
@ -195,8 +197,6 @@ GameEvent.functions[GameEvent.UseCard] = function(self)
logic:breakEvent() logic:breakEvent()
end end
sendCardEmotionAndLog(room, cardUseEvent)
if not cardUseEvent.extraUse then if not cardUseEvent.extraUse then
room:getPlayerById(cardUseEvent.from):addCardUseHistory(cardUseEvent.card.trueName, 1) room:getPlayerById(cardUseEvent.from):addCardUseHistory(cardUseEvent.card.trueName, 1)
end end
@ -264,6 +264,9 @@ GameEvent.functions[GameEvent.RespondCard] = function(self)
card = cardIds, card = cardIds,
} }
end end
playCardEmotionAndSound(room, room:getPlayerById(from), card)
room:moveCardTo(card, Card.Processing, nil, fk.ReasonResonpse) room:moveCardTo(card, Card.Processing, nil, fk.ReasonResonpse)
if #cardIds > 0 then if #cardIds > 0 then
room:sendFootnote(cardIds, { room:sendFootnote(cardIds, {
@ -279,8 +282,6 @@ GameEvent.functions[GameEvent.RespondCard] = function(self)
logic:breakEvent() logic:breakEvent()
end end
playCardEmotionAndSound(room, room:getPlayerById(from), card)
logic:trigger(fk.CardResponding, room:getPlayerById(cardResponseEvent.from), cardResponseEvent) logic:trigger(fk.CardResponding, room:getPlayerById(cardResponseEvent.from), cardResponseEvent)
end end

View File

@ -155,11 +155,19 @@ request_handlers["surrender"] = function(room, id, reqlist)
local logic = room.logic local logic = room.logic
local curEvent = logic:getCurrentEvent() local curEvent = logic:getCurrentEvent()
if curEvent then if curEvent then
curEvent:addExitFunc( curEvent:addCleaner(
function() function()
player.surrendered = true player.surrendered = true
room:broadcastProperty(player, "surrendered") 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 end
) )
room.hasSurrendered = true room.hasSurrendered = true

View File

@ -180,6 +180,7 @@ function ServerPlayer:waitForReply(timeout)
self.serverplayer:setThinking(false) self.serverplayer:setThinking(false)
end end
-- FIXME: 一控多求无懈
local queue = self.room.request_queue[self.serverplayer] local queue = self.room.request_queue[self.serverplayer]
if queue and #queue > 0 and not self.serverplayer:busy() then if queue and #queue > 0 and not self.serverplayer:busy() then
local i, c, j, t = table.unpack(table.remove(queue, 1)) local i, c, j, t = table.unpack(table.remove(queue, 1))