- CardItem一律可长按,除了卡牌一览
- Qml Mark在QML中可获得主人的id
- Qml Mark可实现某某视角完全不可见
- 隐藏#开头的pile
- 可自定义interaction了
- LogMessage新增toast成员
- 修复投降杀人bug
This commit is contained in:
notify 2024-02-27 02:28:13 +08:00 committed by GitHub
parent 380ca120e9
commit d0eb3ba2e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 86 additions and 55 deletions

View File

@ -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 {

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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 });
}

View File

@ -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 = "";
}

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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<integer, PindianResult>
---@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<integer, PindianResult>
---@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"