Dev2 (#323)
- CardItem一律可长按,除了卡牌一览 - Qml Mark在QML中可获得主人的id - Qml Mark可实现某某视角完全不可见 - 隐藏#开头的pile - 可自定义interaction了 - LogMessage新增toast成员 - 修复投降杀人bug
This commit is contained in:
parent
380ca120e9
commit
d0eb3ba2e3
|
@ -63,6 +63,7 @@ Item {
|
||||||
|
|
||||||
delegate: CardItem {
|
delegate: CardItem {
|
||||||
autoBack: false
|
autoBack: false
|
||||||
|
showDetail: false
|
||||||
property int dupCount: 0
|
property int dupCount: 0
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
@ -250,6 +251,7 @@ Item {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
cid: 1
|
cid: 1
|
||||||
known: false
|
known: false
|
||||||
|
showDetail: false
|
||||||
|
|
||||||
property int dupCount: 0
|
property int dupCount: 0
|
||||||
Text {
|
Text {
|
||||||
|
|
|
@ -819,6 +819,12 @@ Item {
|
||||||
skillInteraction.item.from = data.from;
|
skillInteraction.item.from = data.from;
|
||||||
skillInteraction.item.to = data.to;
|
skillInteraction.item.to = data.to;
|
||||||
break;
|
break;
|
||||||
|
case "custom":
|
||||||
|
skillInteraction.sourceComponent =
|
||||||
|
Qt.createComponent(AppPath + "/" + data.qml_path + ".qml");
|
||||||
|
skillInteraction.item.skill = skill_name;
|
||||||
|
skillInteraction.item.extra_data = data;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
skillInteraction.sourceComponent = undefined;
|
skillInteraction.sourceComponent = undefined;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -81,6 +81,7 @@ Item {
|
||||||
root.parent?.playerid);
|
root.parent?.playerid);
|
||||||
if (data && data.qml_path) {
|
if (data && data.qml_path) {
|
||||||
params.data = JSON.parse(_data);
|
params.data = JSON.parse(_data);
|
||||||
|
params.owner = root.parent?.playerid;
|
||||||
roomScene.startCheat("../../" + data.qml_path, params);
|
roomScene.startCheat("../../" + data.qml_path, params);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -94,7 +95,7 @@ Item {
|
||||||
params.ids = data;
|
params.ids = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just for using room's right drawer
|
// Just for using right drawer of the room
|
||||||
roomScene.startCheat("../RoomElement/ViewPile", params);
|
roomScene.startCheat("../RoomElement/ViewPile", params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ Item {
|
||||||
property bool selected: false
|
property bool selected: false
|
||||||
property bool draggable: false
|
property bool draggable: false
|
||||||
property bool autoBack: true
|
property bool autoBack: true
|
||||||
property bool showDetail: false
|
property bool showDetail: true
|
||||||
property int origX: 0
|
property int origX: 0
|
||||||
property int origY: 0
|
property int origY: 0
|
||||||
property int initialZ: 0
|
property int initialZ: 0
|
||||||
|
@ -76,7 +76,7 @@ Item {
|
||||||
signal hoverChanged(bool enter)
|
signal hoverChanged(bool enter)
|
||||||
|
|
||||||
onRightClicked: {
|
onRightClicked: {
|
||||||
if (!showDetail) return;
|
if (!showDetail || !known) return;
|
||||||
roomScene.startCheat("CardDetail", { card: this });
|
roomScene.startCheat("CardDetail", { card: this });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ Item {
|
||||||
card.autoBack = true;
|
card.autoBack = true;
|
||||||
card.draggable = true;
|
card.draggable = true;
|
||||||
card.selectable = false;
|
card.selectable = false;
|
||||||
card.showDetail = true;
|
|
||||||
card.clicked.connect(adjustCards);
|
card.clicked.connect(adjustCards);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +45,6 @@ Item {
|
||||||
card = result[i];
|
card = result[i];
|
||||||
card.draggable = false;
|
card.draggable = false;
|
||||||
card.selectable = false;
|
card.selectable = false;
|
||||||
// card.showDetail = false;
|
|
||||||
card.selectedChanged.disconnect(adjustCards);
|
card.selectedChanged.disconnect(adjustCards);
|
||||||
card.prohibitReason = "";
|
card.prohibitReason = "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,6 @@ Item {
|
||||||
state.y = parentPos.y;
|
state.y = parentPos.y;
|
||||||
state.opacity = 0;
|
state.opacity = 0;
|
||||||
card = component.createObject(roomScene.dynamicCardArea, state);
|
card = component.createObject(roomScene.dynamicCardArea, state);
|
||||||
card.showDetail = true
|
|
||||||
card.x -= card.width / 2;
|
card.x -= card.width / 2;
|
||||||
card.x += (i - outputs.length / 2) * 15;
|
card.x += (i - outputs.length / 2) * 15;
|
||||||
card.y -= card.height / 2;
|
card.y -= card.height / 2;
|
||||||
|
|
|
@ -399,6 +399,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePileInfo(areaName) {
|
function updatePileInfo(areaName) {
|
||||||
|
if (areaName.startsWith('#')) return;
|
||||||
const data = lcall("GetPile", root.playerid, areaName);
|
const data = lcall("GetPile", root.playerid, areaName);
|
||||||
if (data.length === 0) {
|
if (data.length === 0) {
|
||||||
root.markArea.removeMark(areaName);
|
root.markArea.removeMark(areaName);
|
||||||
|
|
|
@ -211,7 +211,11 @@ end
|
||||||
|
|
||||||
---@param msg LogMessage
|
---@param msg LogMessage
|
||||||
function Client:appendLog(msg)
|
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
|
end
|
||||||
|
|
||||||
---@param msg LogMessage
|
---@param msg LogMessage
|
||||||
|
@ -790,9 +794,19 @@ fk.client_callback["SetPlayerMark"] = function(jsonData)
|
||||||
-- jsonData: [ int id, string mark, int value ]
|
-- jsonData: [ int id, string mark, int value ]
|
||||||
local data = json.decode(jsonData)
|
local data = json.decode(jsonData)
|
||||||
local player, mark, value = data[1], data[2], data[3]
|
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 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)
|
ClientInstance:notifyUI("SetPlayerMark", jsonData)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -159,27 +159,10 @@ end
|
||||||
request_handlers["surrender"] = function(room, id, reqlist)
|
request_handlers["surrender"] = function(room, id, reqlist)
|
||||||
local player = room:getPlayerById(id)
|
local player = room:getPlayerById(id)
|
||||||
if not player then return end
|
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
|
|
||||||
|
|
||||||
-- 以防万一
|
room.hasSurrendered = true
|
||||||
player.surrendered = false
|
player.surrendered = true
|
||||||
room.hasSurrendered = false
|
room:doBroadcastNotify("CancelRequest", "")
|
||||||
end
|
|
||||||
)
|
|
||||||
room.hasSurrendered = true
|
|
||||||
room:doBroadcastNotify("CancelRequest", "")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
request_handlers["updatemini"] = function(room, pid, reqlist)
|
request_handlers["updatemini"] = function(room, pid, reqlist)
|
||||||
|
|
|
@ -687,6 +687,29 @@ function Room:doBroadcastNotify(command, jsonData, players)
|
||||||
end
|
end
|
||||||
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。
|
--- 向某个玩家发起一次Request。
|
||||||
---@param player ServerPlayer @ 发出这个请求的目标玩家
|
---@param player ServerPlayer @ 发出这个请求的目标玩家
|
||||||
---@param command string @ 请求的类型
|
---@param command string @ 请求的类型
|
||||||
|
@ -703,6 +726,7 @@ function Room:doRequest(player, command, jsonData, wait)
|
||||||
local ret = player:waitForReply(self.timeout)
|
local ret = player:waitForReply(self.timeout)
|
||||||
player.serverplayer:setBusy(false)
|
player.serverplayer:setBusy(false)
|
||||||
player.serverplayer:setThinking(false)
|
player.serverplayer:setThinking(false)
|
||||||
|
surrenderCheck(self)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -731,6 +755,8 @@ function Room:doBroadcastRequest(command, players, jsonData)
|
||||||
p.serverplayer:setBusy(false)
|
p.serverplayer:setBusy(false)
|
||||||
p.serverplayer:setThinking(false)
|
p.serverplayer:setThinking(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
surrenderCheck(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- 向多名玩家发出竞争请求。
|
--- 向多名玩家发出竞争请求。
|
||||||
|
@ -798,6 +824,7 @@ function Room:doRaceRequest(command, players, jsonData)
|
||||||
p.serverplayer:setThinking(false)
|
p.serverplayer:setThinking(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
surrenderCheck(self)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -187,8 +187,34 @@ fk.IceDamage = 4
|
||||||
---@field public pattern string
|
---@field public pattern string
|
||||||
---@field public result Card
|
---@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.ReasonJustMove = 1
|
||||||
fk.ReasonDraw = 2
|
fk.ReasonDraw = 2
|
||||||
fk.ReasonDiscard = 3
|
fk.ReasonDiscard = 3
|
||||||
|
@ -201,29 +227,3 @@ fk.ReasonUse = 9
|
||||||
fk.ReasonResonpse = 10
|
fk.ReasonResonpse = 10
|
||||||
fk.ReasonJudge = 11
|
fk.ReasonJudge = 11
|
||||||
fk.ReasonRecast = 12
|
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"
|
|
||||||
|
|
Loading…
Reference in New Issue