mirror of
https://github.com/Qsgs-Fans/FreeKill.git
synced 2024-11-16 11:42:45 +08:00
parent
84b8600981
commit
73fcb765d4
|
@ -716,6 +716,35 @@ callbacks["AskForGuanxing"] = function(jsonData) {
|
|||
});
|
||||
}
|
||||
|
||||
callbacks["AskForExchange"] = function(jsonData) {
|
||||
let data = JSON.parse(jsonData);
|
||||
let cards = [];
|
||||
let cards_name = [];
|
||||
let capacities = [];
|
||||
let limits = [];
|
||||
roomScene.state = "replying";
|
||||
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/GuanxingBox.qml");
|
||||
let for_i = 0;
|
||||
let box = roomScene.popupBox.item;
|
||||
data.piles.forEach(ids => {
|
||||
ids.forEach(id => {
|
||||
let d = Backend.callLuaFunction("GetCardData", [id]);
|
||||
cards.push(JSON.parse(d));
|
||||
});
|
||||
capacities.push(ids.length);
|
||||
limits.push(0);
|
||||
cards_name.push(Backend.translate(data.piles_name[for_i]));
|
||||
for_i ++;
|
||||
});
|
||||
box.areaCapacities = capacities
|
||||
box.areaLimits = limits
|
||||
box.areaNames = cards_name
|
||||
box.cards = cards;
|
||||
box.arrangeCards();
|
||||
box.accepted.connect(() => {
|
||||
replyToServer(JSON.stringify(box.getResult()));
|
||||
});
|
||||
}
|
||||
callbacks["AskForChoice"] = function(jsonData) {
|
||||
// jsonData: [ string[] choices, string skill ]
|
||||
// TODO: multiple choices, e.g. benxi_ol
|
||||
|
|
|
@ -105,10 +105,11 @@ GraphicsBox {
|
|||
}
|
||||
|
||||
if (stay) {
|
||||
if (result[0].length >= areaCapacities[0]) {
|
||||
result[1].push(card);
|
||||
} else {
|
||||
result[0].push(card);
|
||||
for (j = 0; j < areaRepeater.count; j++) {
|
||||
if (result[j].length < areaCapacities[j]) {
|
||||
result[j].push(card);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,6 +156,7 @@ FreeKill使用的是libgit2的C API,与此同时使用Git完成拓展包的下
|
|||
[" thinking..."] = " 思考中...",
|
||||
["AskForGeneral"] = "选择武将",
|
||||
["AskForGuanxing"] = "观星",
|
||||
["AskForExchange"] = "换牌",
|
||||
["AskForChoice"] = "选择",
|
||||
["AskForKingdom"] = "选择势力",
|
||||
["AskForPindian"] = "拼点",
|
||||
|
|
|
@ -1331,6 +1331,35 @@ function Room:askForGuanxing(player, cards, top_limit, bottom_limit, customNotif
|
|||
return { top = top, bottom = bottom }
|
||||
end
|
||||
|
||||
--- 询问玩家任意交换几堆牌堆。
|
||||
---
|
||||
---@param player ServerPlayer @ 要询问的玩家
|
||||
---@param piles table<cardIds, cardId[]> @ 卡牌id列表的列表,也就是……几堆牌堆的集合
|
||||
---@param piles_name string[] @ 牌堆名,必须一一对应,否则统一替换为“牌堆X”
|
||||
---@param customNotify string|null @ 自定义读条操作提示
|
||||
---@return table<cardIds, cardId[]>
|
||||
function Room:AskForExchange(player, piles, piles_name, customNotify)
|
||||
local command = "AskForExchange"
|
||||
piles_name = piles_name or {}
|
||||
if #piles_name ~= #piles then
|
||||
piles_name = {}
|
||||
for i, _ in ipairs(piles) do
|
||||
table.insert(piles_name, "牌堆" .. i)
|
||||
end
|
||||
end
|
||||
self:notifyMoveFocus(player, customNotify or command)
|
||||
local data = {
|
||||
piles = piles,
|
||||
piles_name = piles_name,
|
||||
}
|
||||
local result = self:doRequest(player, command, json.encode(data))
|
||||
if result ~= "" then
|
||||
local d = json.decode(result)
|
||||
return d
|
||||
else
|
||||
return piles
|
||||
end
|
||||
end
|
||||
--- 平时写DIY用不到的函数。
|
||||
---@param player ServerPlayer
|
||||
---@param data string
|
||||
|
|
Loading…
Reference in New Issue
Block a user