diff --git a/Fk/Pages/CardsOverview.qml b/Fk/Pages/CardsOverview.qml index 70c95a11..8a2fb3ab 100644 --- a/Fk/Pages/CardsOverview.qml +++ b/Fk/Pages/CardsOverview.qml @@ -63,6 +63,7 @@ Item { delegate: CardItem { autoBack: false + showDetail: false property int dupCount: 0 Text { @@ -250,6 +251,7 @@ Item { Layout.alignment: Qt.AlignHCenter cid: 1 known: false + showDetail: false property int dupCount: 0 Text { diff --git a/Fk/Pages/Room.qml b/Fk/Pages/Room.qml index fc907544..0e02cd1f 100644 --- a/Fk/Pages/Room.qml +++ b/Fk/Pages/Room.qml @@ -819,6 +819,12 @@ Item { skillInteraction.item.from = data.from; skillInteraction.item.to = data.to; break; + case "custom": + skillInteraction.sourceComponent = + Qt.createComponent(AppPath + "/" + data.qml_path + ".qml"); + skillInteraction.item.skill = skill_name; + skillInteraction.item.extra_data = data; + break; default: skillInteraction.sourceComponent = undefined; break; diff --git a/Fk/PhotoElement/MarkArea.qml b/Fk/PhotoElement/MarkArea.qml index 4b7deaa3..ba36da59 100644 --- a/Fk/PhotoElement/MarkArea.qml +++ b/Fk/PhotoElement/MarkArea.qml @@ -81,6 +81,7 @@ Item { root.parent?.playerid); if (data && data.qml_path) { params.data = JSON.parse(_data); + params.owner = root.parent?.playerid; roomScene.startCheat("../../" + data.qml_path, params); } return; @@ -94,7 +95,7 @@ Item { params.ids = data; } - // Just for using room's right drawer + // Just for using right drawer of the room roomScene.startCheat("../RoomElement/ViewPile", params); } } diff --git a/Fk/RoomElement/CardItem.qml b/Fk/RoomElement/CardItem.qml index ea4f4d0c..e4cd9453 100644 --- a/Fk/RoomElement/CardItem.qml +++ b/Fk/RoomElement/CardItem.qml @@ -51,7 +51,7 @@ Item { property bool selected: false property bool draggable: false property bool autoBack: true - property bool showDetail: false + property bool showDetail: true property int origX: 0 property int origY: 0 property int initialZ: 0 @@ -76,7 +76,7 @@ Item { signal hoverChanged(bool enter) onRightClicked: { - if (!showDetail) return; + if (!showDetail || !known) return; roomScene.startCheat("CardDetail", { card: this }); } diff --git a/Fk/RoomElement/HandcardArea.qml b/Fk/RoomElement/HandcardArea.qml index 8541d7d9..3cd0b53f 100644 --- a/Fk/RoomElement/HandcardArea.qml +++ b/Fk/RoomElement/HandcardArea.qml @@ -34,7 +34,6 @@ Item { card.autoBack = true; card.draggable = true; card.selectable = false; - card.showDetail = true; card.clicked.connect(adjustCards); } @@ -46,7 +45,6 @@ Item { card = result[i]; card.draggable = false; card.selectable = false; - // card.showDetail = false; card.selectedChanged.disconnect(adjustCards); card.prohibitReason = ""; } diff --git a/Fk/RoomElement/InvisibleCardArea.qml b/Fk/RoomElement/InvisibleCardArea.qml index 25ba6ea4..4d533f77 100644 --- a/Fk/RoomElement/InvisibleCardArea.qml +++ b/Fk/RoomElement/InvisibleCardArea.qml @@ -64,7 +64,6 @@ Item { state.y = parentPos.y; state.opacity = 0; card = component.createObject(roomScene.dynamicCardArea, state); - card.showDetail = true card.x -= card.width / 2; card.x += (i - outputs.length / 2) * 15; card.y -= card.height / 2; diff --git a/Fk/RoomElement/Photo.qml b/Fk/RoomElement/Photo.qml index cb73de73..c77d0ed3 100644 --- a/Fk/RoomElement/Photo.qml +++ b/Fk/RoomElement/Photo.qml @@ -399,6 +399,7 @@ Item { } function updatePileInfo(areaName) { + if (areaName.startsWith('#')) return; const data = lcall("GetPile", root.playerid, areaName); if (data.length === 0) { root.markArea.removeMark(areaName); diff --git a/lua/client/client.lua b/lua/client/client.lua index 33304613..80bb17ec 100644 --- a/lua/client/client.lua +++ b/lua/client/client.lua @@ -211,7 +211,11 @@ end ---@param msg LogMessage function Client:appendLog(msg) - self:notifyUI("GameLog", parseMsg(msg)) + local text = parseMsg(msg) + self:notifyUI("GameLog", text) + if msg.toast then + self:notifyUI("ShowToast", text) + end end ---@param msg LogMessage @@ -790,9 +794,19 @@ fk.client_callback["SetPlayerMark"] = function(jsonData) -- jsonData: [ int id, string mark, int value ] local data = json.decode(jsonData) local player, mark, value = data[1], data[2], data[3] - ClientInstance:getPlayerById(player):setMark(mark, value) + local p = ClientInstance:getPlayerById(player) + p:setMark(mark, value) if string.sub(mark, 1, 1) == "@" then + if mark:startsWith("@[") and mark:find(']') then + local close = mark:find(']') + local mtype = mark:sub(3, close - 1) + local spec = Fk.qml_marks[mtype] + if spec then + local text = spec.how_to_show(mark, value, p) + if text == "#hidden" then return end + end + end ClientInstance:notifyUI("SetPlayerMark", jsonData) end end diff --git a/lua/server/request.lua b/lua/server/request.lua index 79a0a70e..2d36437d 100644 --- a/lua/server/request.lua +++ b/lua/server/request.lua @@ -159,27 +159,10 @@ end request_handlers["surrender"] = function(room, id, reqlist) local player = room:getPlayerById(id) if not player then return end - local logic = room.logic - local curEvent = logic:getCurrentEvent() - if curEvent then - curEvent:addCleaner( - function() - player.surrendered = true - room:broadcastProperty(player, "surrendered") - 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 - room:doBroadcastNotify("CancelRequest", "") - end + room.hasSurrendered = true + player.surrendered = true + room:doBroadcastNotify("CancelRequest", "") end request_handlers["updatemini"] = function(room, pid, reqlist) diff --git a/lua/server/room.lua b/lua/server/room.lua index 68491550..68b32a3d 100644 --- a/lua/server/room.lua +++ b/lua/server/room.lua @@ -687,6 +687,29 @@ function Room:doBroadcastNotify(command, jsonData, players) end end +---@param room Room +local function surrenderCheck(room) + if not room.hasSurrendered then return end + local player = table.find(room.players, function(p) + return p.surrendered + end) + if not player then + room.hasSurrendered = false + return + end + room:broadcastProperty(player, "surrendered") + local mode = Fk.game_modes[room.settings.gameMode] + local winner = Pcall(mode.getWinner, mode, player) + if winner ~= "" then + room:gameOver(winner) + end + + -- 以防万一 + player.surrendered = false + room:broadcastProperty(player, "surrendered") + room.hasSurrendered = false +end + --- 向某个玩家发起一次Request。 ---@param player ServerPlayer @ 发出这个请求的目标玩家 ---@param command string @ 请求的类型 @@ -703,6 +726,7 @@ function Room:doRequest(player, command, jsonData, wait) local ret = player:waitForReply(self.timeout) player.serverplayer:setBusy(false) player.serverplayer:setThinking(false) + surrenderCheck(self) return ret end end @@ -731,6 +755,8 @@ function Room:doBroadcastRequest(command, players, jsonData) p.serverplayer:setBusy(false) p.serverplayer:setThinking(false) end + + surrenderCheck(self) end --- 向多名玩家发出竞争请求。 @@ -798,6 +824,7 @@ function Room:doRaceRequest(command, players, jsonData) p.serverplayer:setThinking(false) end + surrenderCheck(self) return ret end diff --git a/lua/server/system_enum.lua b/lua/server/system_enum.lua index e75d679a..d77857ef 100644 --- a/lua/server/system_enum.lua +++ b/lua/server/system_enum.lua @@ -187,8 +187,34 @@ fk.IceDamage = 4 ---@field public pattern string ---@field public result Card ----@alias CardMoveReason integer +---@class PindianStruct +---@field public from ServerPlayer +---@field public tos ServerPlayer[] +---@field public fromCard Card +---@field public results table +---@field public reason string +---@class LogMessage +---@field public type string @ log主体 +---@field public from? integer @ 要替换%from的玩家的id +---@field public to? integer[] @ 要替换%to的玩家id列表 +---@field public card? integer[] @ 要替换%card的卡牌id列表 +---@field public arg? any @ 要替换%arg的内容 +---@field public arg2? any @ 要替换%arg2的内容 +---@field public arg3? any @ 要替换%arg3的内容 +---@field public toast? boolean @ 是否顺手把消息发送一条相同的toast + +---@class SkillUseStruct +---@field public skill Skill +---@field public willUse boolean + +---@class DrawCardStruct +---@field public who ServerPlayer +---@field public num number +---@field public skillName string +---@field public fromPlace "top"|"bottom" + +---@alias CardMoveReason integer fk.ReasonJustMove = 1 fk.ReasonDraw = 2 fk.ReasonDiscard = 3 @@ -201,29 +227,3 @@ fk.ReasonUse = 9 fk.ReasonResonpse = 10 fk.ReasonJudge = 11 fk.ReasonRecast = 12 - ----@class PindianStruct ----@field public from ServerPlayer ----@field public tos ServerPlayer[] ----@field public fromCard Card ----@field public results table ----@field public reason string - ----@class LogMessage ----@field public type string ----@field public from? integer ----@field public to? integer[] ----@field public card? integer[] ----@field public arg? any ----@field public arg2? any ----@field public arg3? any - ----@class SkillUseStruct ----@field public skill Skill ----@field public willUse boolean - ----@class DrawCardStruct ----@field public who ServerPlayer ----@field public num number ----@field public skillName string ----@field public fromPlace "top"|"bottom"