Co-authored-by: YoumuKon <38815081+YoumuKon@users.noreply.github.com>
This commit is contained in:
notify 2024-10-22 00:03:42 +08:00 committed by GitHub
parent 210ca99d2f
commit 220fb93b0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 203 additions and 80 deletions

View File

@ -244,6 +244,7 @@ Item {
config.curSchemeChanged();
} else {
generalText.clear();
generalText.clearSavedText();
generalDetail.general = modelData;
generalDetail.updateGeneral();
generalDetail.open();
@ -505,6 +506,7 @@ Item {
detailFlickable.contentY = 0; //
const data = lcall("GetGeneralDetail", general);
generalText.clear();
generalText.clearSavedText();
audioModel.clear();
if (data.companions.length > 0){
@ -619,6 +621,10 @@ Item {
TextEdit {
id: generalText
property var savedtext: []
function clearSavedText() {
savedtext = [];
}
Layout.fillWidth: true
readOnly: true
selectByKeyboard: true
@ -626,6 +632,14 @@ Item {
wrapMode: TextEdit.WordWrap
textFormat: TextEdit.RichText
font.pixelSize: 18
onLinkActivated: (link) => {
if (link === "back") {
text = savedtext.pop();
} else {
savedtext.push(text);
text = '<a href="back">点击返回</a><br>' + luatr(link);
}
}
}
GridLayout {

View File

@ -1290,6 +1290,10 @@ Item {
});
}
function getPhoto(id) {
return Logic.getPhoto(id);
}
function applyChange(uiUpdate) {
uiUpdate["_delete"]?.forEach(data => {
if (data.type == "Interaction") {

View File

@ -199,14 +199,15 @@ function getAreaItem(area, id) {
return null;
}
function moveCards(moves) {
function moveCards(data) {
const moves = data.merged;
for (let i = 0; i < moves.length; i++) {
const move = moves[i];
const from = getAreaItem(move.fromArea, move.from);
const to = getAreaItem(move.toArea, move.to);
if (!from || !to || (from === to && move.fromArea !== Card.DiscardPile))
continue;
const items = from.remove(move.ids, move.fromSpecialName);
const items = from.remove(move.ids, move.fromSpecialName, data);
if (to === tablePile) {
let vanished = items.filter(c => c.cid === -1);
if (vanished.length > 0) {
@ -569,30 +570,6 @@ callbacks["MaxCard"] = (data) => {
}
}
function changeSelf(id) {
lcall("ChangeSelf", id);
// move new selfPhoto to dashboard
let order = new Array(photoModel.count);
for (let i = 0; i < photoModel.count; i++) {
const item = photoModel.get(i);
order[item.seatNumber - 1] = item.id;
if (item.id === Self.id) {
dashboard.self = photos.itemAt(i);
}
}
callbacks["ArrangeSeats"](order);
// update dashboard
dashboard.update();
// handle pending messages
if (mainWindow.is_pending) {
const data = mainWindow.fetchMessage();
return mainWindow.handleMessage(data.command, data.jsonData);
}
}
callbacks["AddPlayer"] = (data) => {
// jsonData: int id, string screenName, string avatar, bool ready
for (let i = 0; i < photoModel.count; i++) {
@ -1538,21 +1515,20 @@ callbacks["UpdateGameData"] = (data) => {
}
// 神貂蝉
callbacks["StartChangeSelf"] = (j) => {
const id = parseInt(j);
ClientInstance.notifyServer("PushRequest", "changeself," + j);
}
callbacks["ChangeSelf"] = (j) => {
const data = parseInt(j);
if (Self.id === data) {
const msg = mainWindow.fetchMessage();
if (!msg) return;
mainWindow.handleMessage(msg.command, msg.jsonData);
return;
// move new selfPhoto to dashboard
let order = new Array(photoModel.count);
for (let i = 0; i < photoModel.count; i++) {
const item = photoModel.get(i);
order[item.seatNumber - 1] = item.id;
if (item.id === Self.id) {
dashboard.self = photos.itemAt(i);
}
}
changeSelf(data);
callbacks["ArrangeSeats"](order);
// update dashboard
dashboard.update();
}
callbacks["UpdateRequestUI"] = (uiUpdate) => {

View File

@ -88,7 +88,7 @@ Item {
} else {
if (!root.parent.playerid) return;
let data = lcall("GetPile", root.parent.playerid, mark_name);
data = data.filter((e) => e !== -1);
data = data.filter((e) => lcall("CardVisibility", e));
if (data.length === 0)
return;

View File

@ -48,7 +48,7 @@ Item {
return false;
}
function remove(outputs)
function remove(outputs, _, visibleData)
{
const component = Qt.createComponent("CardItem.qml");
if (component.status !== Component.Ready)
@ -67,6 +67,7 @@ Item {
card.x -= card.width / 2;
card.x += (i - outputs.length / 2) * 15;
card.y -= card.height / 2;
if (visibleData) card.known = !!visibleData[outputs[i].toString()];
items.push(card);
if (checkExisting) {
for (let j = 0; j < length; j++) {

View File

@ -507,23 +507,6 @@ Item {
anchors.bottomMargin: 4
style: Text.Outline
}
TapHandler {
enabled: (root.state != "candidate" || !root.selectable)
&& root.playerid !== Self.id
onTapped: {
const params = { name: "hand_card" };
let data = lcall("GetPlayerHandcards", root.playerid);
data = data.filter((e) => e !== -1);
if (data.length === 0)
return;
params.ids = data;
// Just for using room's right drawer
roomScene.startCheat("../RoomElement/ViewPile", params);
}
}
}
TapHandler {
@ -548,7 +531,10 @@ Item {
RoleComboBox {
id: role
value: root.role
value: {
if (root.role === "hidden") return "hidden";
lcall("RoleVisibility", root.playerid) ? root.role : "unknown";
}
anchors.top: parent.top
anchors.topMargin: -4
anchors.right: parent.right
@ -798,6 +784,91 @@ Item {
}
}
Rectangle {
color: "#CC2E2C27"
radius: 6
border.color: "#A6967A"
border.width: 1
width: 44
height: 112
/*
x: {
const roomX = mapToItem(roomScene, root.x, root.y).x;
if (roomX < 48) return 175;
return -44;
}
*/
x: -44
y: 128
visible: {
if (root.playerid === Self.id) return false;
if (root.handcards === 0) return false; // buddy
if (!lcall("IsMyBuddy", Self.id, root.playerid) &&
!lcall("HasVisibleCard", Self.id, root.playerid)) return false;
return true;
}
Text {
x: 2; y: 2
width: 42
text: {
if (!parent.visible) return "";
const unused = root.handcards; //
const ids = lcall("GetPlayerHandcards", root.playerid);
const txt = [];
for (const cid of ids) {
if (txt.length >= 4) {
// txt.push("&nbsp;&nbsp;&nbsp;...");
txt.push("...");
break;
}
if (!lcall("CardVisibility", cid)) continue;
const data = lcall("GetCardData", cid);
let a = luatr(data.name);
/* if (a.length === 1) {
a = "&nbsp;&nbsp;" + a;
} else */
if (a.length >= 2) {
a = a.slice(0, 2);
}
txt.push(a);
}
if (txt.length < 5) {
const unknownCards = ids.length - txt.length;
for (let i = 0; i < unknownCards; i++) {
if (txt.length >= 4) {
txt.push("...");
break;
} else {
txt.push("?");
}
}
}
return txt.join("<br>");
}
color: "#E4D5A0"
font.family: fontLibian.name
font.pixelSize: 18
textFormat: Text.RichText
horizontalAlignment: Text.AlignHCenter
}
TapHandler {
onTapped: {
const params = { name: "hand_card" };
let data = lcall("GetPlayerHandcards", root.playerid);
data = data.filter((e) => lcall("CardVisibility", e));
params.ids = data;
// Just for using room's right drawer
roomScene.startCheat("../RoomElement/ViewPile", params);
}
}
}
onGeneralChanged: {
if (!roomScene.isStarted) return;
const text = luatr(general);

View File

@ -75,7 +75,7 @@ GraphicsBox {
suit: model.suit || ""
number: model.number || 0
autoBack: false
known: model.cid !== -1
known: model.known
selectable: true
onClicked: {
if (!root.multiChoose) {

View File

@ -71,7 +71,7 @@ GraphicsBox {
suit: model.suit || ""
number: model.number || 0
autoBack: false
known: model.cid !== -1
known: model.known
selectable: chosenInBox ||
lcall("PoxiFilter", root.poxi_type, model.cid, root.selected_ids,
root.card_data, root.extra_data);

View File

@ -21,7 +21,7 @@ Item {
function inTable(cid) {
return leval(`(function()
local client = Fk:currentRoom()
if client._processing[${cid}] then
if table.contains(client.processing_area, ${cid}) then
return true
end
return false

View File

@ -26,8 +26,6 @@ Window {
? 540 : 960 * parent.height / parent.width
scale: parent.width / width
anchors.centerIn: parent
property bool is_pending: false
property var pending_message: []
Config {
id: config
@ -158,17 +156,7 @@ Window {
errDialog.open();
return;
}
if (mainWindow.is_pending && command !== "ChangeSelf") {
mainWindow.pending_message.push({
command: command,
jsonData: jsonData,
});
} else {
if (command === "StartChangeSelf") {
mainWindow.is_pending = true;
}
mainWindow.handleMessage(command, jsonData);
}
mainWindow.handleMessage(command, jsonData);
}
}

View File

@ -356,6 +356,22 @@ test2:addSkill(test_zhenggong)
test2:addSkill(change_hero)
-- test2:addSkill(test_feichu)
local kansha=fk.CreateVisibilitySkill{
name='test_kansha',
frequency=Skill.Compulsory,
card_visible = function(self, player, card)
if player:hasSkill(self) and card.trueName == 'slash' and
Fk:currentRoom():getCardArea(card) == Card.PlayerHand then
return true
end
end
}
test2:addSkill(kansha)
Fk:loadTranslationTable{
["test_kansha"] = "看杀",
[":test_kansha"] = "锁定技,你看得到人们手中的【杀】"
}
local shibing = General(extension, "blank_shibing", "qun", 5)
shibing.hidden = true
Fk:loadTranslationTable{

View File

@ -50,3 +50,26 @@ public:
QByteArray toJson(QJsonDocument::JsonFormat format = 1) const;
QVariant toVariant() const;
};
class QRandomGenerator {
public:
QRandomGenerator(unsigned int seed = 1);
unsigned int generate();
unsigned int bounded(unsigned int lowest, unsigned int highest);
};
%extend QRandomGenerator {
QVariant random(int low = -1, int high = -1) {
QVariant ret;
if (high < 0) {
if (low < 1) {
ret.setValue($self->bounded(0, 100001) / 100000);
} else {
ret.setValue($self->bounded(1, low + 1));
}
} else {
ret.setValue($self->bounded(low, high + 1));
}
return ret;
}
}

View File

@ -3,6 +3,8 @@
local fk = {}
local testFail = false
local json = require "lua.lib.json"
local os, io = os, io
-- 这下Linux专用了
@ -13,12 +15,35 @@ end
function fk.QmlBackend_isDir(dir)
local f = io.popen("if [ -d " .. dir .. " ]; then echo OK; fi")
return f:read("*a"):startsWith("OK")
return f:read("*a"):sub(1, 2) == "OK"
end
function fk.QmlBackend_exists(dir)
local f = io.popen("if [ -e " .. dir .. " ]; then echo OK; fi")
return f:read("*a"):startsWith("OK")
return f:read("*a"):sub(1, 2) == "OK"
end
function fk.QmlBackend_pwd()
local f = io.popen("pwd")
return f:read("*a")
end
function fk.QmlBackend_cd(dir) end
function fk.QJsonDocument_fromVariant(e)
return {
toJson = function(_, __)
return json.encode(e)
end,
}
end
function fk.QJsonDocument_fromJson(str)
return {
toVariant = function(_)
return json.decode(str)
end,
}
end
function fk.GetDisabledPacks()
@ -46,7 +71,7 @@ end
function fk.roomtest(croom, f)
local room = Room(croom)
RoomInstance = room
room.action = function() f(room) end
--room.action = function() f(room) end
while true do
local over = room:resume()
if over then break else room.in_delay = false end

View File

@ -7,6 +7,11 @@ function Room:getPlayers() return self.players end
function Room:getTimeout() return 15 end
function Room:updateWinRate() end
function Room:gameOver() end
function Room:setRequestTimer() end
function Room:destroyRequestTimer() end
function Room:delay(ms)
-- fk.io.popen("sleep " .. ms/1000):read()
end
function Room:settings()
return json.encode{
enableFreeAssign = false,

View File

@ -581,7 +581,7 @@ function ServerPlayer:waitForReply()
return ""
end
function ServerPlayer:doNotify(cmd, j)
if self.id ~= 1 then
if self.id ~= 100 then
return
end
if cmd == "GameLog" then

View File

@ -5,7 +5,7 @@ _TestGameLogic = {
setup = function()
croom = fk.Room:new()
croom.players = {
fk.ServerPlayer:new(1),
fk.ServerPlayer:new(100),
fk.ServerPlayer:new(2),
fk.ServerPlayer:new(3),
fk.ServerPlayer:new(4),