QML修改+bugfix (#181)

*因为一些原因,带动了之前的内容*

- 将QML的大多数let改成了const
- 修复一些bug
This commit is contained in:
YoumuKon 2023-06-09 17:23:02 +08:00 committed by GitHub
parent a6ad71c19f
commit 1556da2f13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 166 additions and 165 deletions

View File

@ -110,7 +110,7 @@ Item {
} }
function load() { function load() {
let packs = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", [])); const packs = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", []));
packs.forEach((name) => packages.append({ name: name })); packs.forEach((name) => packages.append({ name: name }));
} }

View File

@ -97,13 +97,13 @@ Flickable {
screenName.text = ""; screenName.text = "";
skillDesc.text = ""; skillDesc.text = "";
let id = extra_data.photo.playerid; const id = extra_data.photo.playerid;
if (id == 0) return; if (id == 0) return;
root.pid = id; root.pid = id;
screenName.text = extra_data.photo.screenName; screenName.text = extra_data.photo.screenName;
let data = JSON.parse(Backend.callLuaFunction("GetPlayerSkills", [id])); const data = JSON.parse(Backend.callLuaFunction("GetPlayerSkills", [id]));
data.forEach(t => { data.forEach(t => {
skillDesc.append("<b>" + Backend.translate(t.name) + "</b>: " + t.description) skillDesc.append("<b>" + Backend.translate(t.name) + "</b>: " + t.description)
}); });

View File

@ -44,7 +44,7 @@ ListView {
} }
function append(text) { function append(text) {
let autoScroll = root.currentIndex === logModel.count - 1; const autoScroll = root.currentIndex === logModel.count - 1;
logModel.append({ logText: text }); logModel.append({ logText: text });
if (autoScroll) { if (autoScroll) {
root.currentIndex = logModel.count - 1; root.currentIndex = logModel.count - 1;

View File

@ -57,7 +57,7 @@ Flickable {
} }
onCurrentIndexChanged: { onCurrentIndexChanged: {
let data = gameModeList.get(currentIndex); const data = gameModeList.get(currentIndex);
playerNum.from = data.minPlayer; playerNum.from = data.minPlayer;
playerNum.to = data.maxPlayer; playerNum.to = data.maxPlayer;
@ -188,7 +188,7 @@ Flickable {
} }
Component.onCompleted: { Component.onCompleted: {
let mode_data = JSON.parse(Backend.callLuaFunction("GetGameModes", [])); const mode_data = JSON.parse(Backend.callLuaFunction("GetGameModes", []));
let i = 0; let i = 0;
for (let d of mode_data) { for (let d of mode_data) {
gameModeList.append(d); gameModeList.append(d);

View File

@ -45,9 +45,9 @@ Flickable {
enabled: orig_name !== "test_p_0" enabled: orig_name !== "test_p_0"
onCheckedChanged: { onCheckedChanged: {
let packs = config.disabledPack; const packs = config.disabledPack;
if (checked) { if (checked) {
let idx = packs.indexOf(orig_name); const idx = packs.indexOf(orig_name);
if (idx !== -1) packs.splice(idx, 1); if (idx !== -1) packs.splice(idx, 1);
} else { } else {
packs.push(orig_name); packs.push(orig_name);
@ -76,9 +76,9 @@ Flickable {
checked: pkg_enabled checked: pkg_enabled
onCheckedChanged: { onCheckedChanged: {
let packs = config.disabledPack; const packs = config.disabledPack;
if (checked) { if (checked) {
let idx = packs.indexOf(orig_name); const idx = packs.indexOf(orig_name);
if (idx !== -1) packs.splice(idx, 1); if (idx !== -1) packs.splice(idx, 1);
} else { } else {
packs.push(orig_name); packs.push(orig_name);
@ -90,7 +90,7 @@ Flickable {
} }
Component.onCompleted: { Component.onCompleted: {
let g = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", [])); const g = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", []));
for (let orig of g) { for (let orig of g) {
gpacklist.append({ gpacklist.append({
name: Backend.translate(orig), name: Backend.translate(orig),
@ -99,7 +99,7 @@ Flickable {
}); });
} }
let c = JSON.parse(Backend.callLuaFunction("GetAllCardPack", [])); const c = JSON.parse(Backend.callLuaFunction("GetAllCardPack", []));
for (let orig of c) { for (let orig of c) {
cpacklist.append({ cpacklist.append({
name: Backend.translate(orig), name: Backend.translate(orig),

View File

@ -105,7 +105,7 @@ callbacks["EnterRoom"] = (jsonData) => {
callbacks["UpdateRoomList"] = (jsonData) => { callbacks["UpdateRoomList"] = (jsonData) => {
const current = mainStack.currentItem; // should be lobby const current = mainStack.currentItem; // should be lobby
if (mainStack.currentItem === lobby) { if (mainStack.depth === 2) {
current.roomModel.clear(); current.roomModel.clear();
JSON.parse(jsonData).forEach(function (room) { JSON.parse(jsonData).forEach(function (room) {
current.roomModel.append({ current.roomModel.append({
@ -122,7 +122,7 @@ callbacks["UpdateRoomList"] = (jsonData) => {
callbacks["UpdatePlayerNum"] = (j) => { callbacks["UpdatePlayerNum"] = (j) => {
const current = mainStack.currentItem; // should be lobby const current = mainStack.currentItem; // should be lobby
if (mainStack.currentItem === lobby) { if (mainStack.depth === 2) {
const data = JSON.parse(j); const data = JSON.parse(j);
const l = data[0]; const l = data[0];
const s = data[1]; const s = data[1];

View File

@ -72,7 +72,7 @@ Item {
} }
Component.onCompleted: { Component.onCompleted: {
let data = modelData; const data = modelData;
if (!data.cards) { if (!data.cards) {
name = data.name; name = data.name;
suit = data.suit; suit = data.suit;
@ -113,15 +113,15 @@ Item {
easing.type: Easing.InOutQuad easing.type: Easing.InOutQuad
} }
onFinished: { onFinished: {
let pkg = [listView.model.get(listView.currentIndex).name]; const pkg = [listView.model.get(listView.currentIndex).name];
let idList = JSON.parse(Backend.callLuaFunction("GetCards", pkg)); const idList = JSON.parse(Backend.callLuaFunction("GetCards", pkg));
let cardList = idList.map(id => JSON.parse(Backend.callLuaFunction const cardList = idList.map(id => JSON.parse(Backend.callLuaFunction
("GetCardData",[id]))); ("GetCardData",[id])));
let groupedCardList = []; const groupedCardList = [];
let groupedCards = {}; let groupedCards = {};
cardList.forEach(c => { cardList.forEach(c => {
let name = c.name; const name = c.name;
if (!groupedCards[name]) { if (!groupedCards[name]) {
groupedCardList.push(name); groupedCardList.push(name);
groupedCards[name] = []; groupedCards[name] = [];
@ -133,9 +133,9 @@ Item {
}); });
}); });
let model = []; const model = [];
groupedCardList.forEach(name => { groupedCardList.forEach(name => {
let cards = groupedCards[name]; const cards = groupedCards[name];
if (cards.length === 1) { if (cards.length === 1) {
model.push({ model.push({
name: name, name: name,
@ -192,7 +192,7 @@ Item {
property int cid: 1 property int cid: 1
property var cards property var cards
function updateCard() { function updateCard() {
let data = JSON.parse(Backend.callLuaFunction("GetCardData", [cid])); const data = JSON.parse(Backend.callLuaFunction("GetCardData", [cid]));
const suitTable = { const suitTable = {
spade: "♠", heart: '<font color="red">♥</font>', spade: "♠", heart: '<font color="red">♥</font>',
club: "♣", diamond: '<font color="red">♦</font>', club: "♣", diamond: '<font color="red">♦</font>',
@ -226,7 +226,7 @@ Item {
cardText.clear(); cardText.clear();
cardText.append(Backend.translate(":" + data.name)); cardText.append(Backend.translate(":" + data.name));
let skills = JSON.parse(Backend.callLuaFunction const skills = JSON.parse(Backend.callLuaFunction
("GetCardSpecialSkills", [cid])); ("GetCardSpecialSkills", [cid]));
if (skills.length > 0) { if (skills.length > 0) {
cardText.append("<br/>" + Backend.translate("Special card skills:")); cardText.append("<br/>" + Backend.translate("Special card skills:"));
@ -299,7 +299,7 @@ Item {
function loadPackages() { function loadPackages() {
if (loaded) return; if (loaded) return;
let packs = JSON.parse(Backend.callLuaFunction("GetAllCardPack", [])); const packs = JSON.parse(Backend.callLuaFunction("GetAllCardPack", []));
packs.forEach((name) => packages.append({ name: name })); packs.forEach((name) => packages.append({ name: name }));
loaded = true; loaded = true;
} }

View File

@ -13,8 +13,8 @@ Item {
if (!newTxtAvailable || stashedTxt.length === 0) { if (!newTxtAvailable || stashedTxt.length === 0) {
return; return;
} }
let t = stashedTxt.splice(0, 1)[0]; const t = stashedTxt.splice(0, 1)[0];
let obj = txtComponent.createObject(root, { text: t }); const obj = txtComponent.createObject(root, { text: t });
obj.finished.connect(() => obj.destroy()); obj.finished.connect(() => obj.destroy());
obj.start(); obj.start();
} }

View File

@ -150,7 +150,7 @@ Item {
property string general: "caocao" property string general: "caocao"
function updateGeneral() { function updateGeneral() {
detailGeneralCard.name = general; detailGeneralCard.name = general;
let data = JSON.parse(Backend.callLuaFunction("GetGeneralDetail", [general])); const data = JSON.parse(Backend.callLuaFunction("GetGeneralDetail", [general]));
generalText.clear(); generalText.clear();
data.skill.forEach(t => { data.skill.forEach(t => {
generalText.append("<b>" + Backend.translate(t.name) + "</b>: " + t.description) generalText.append("<b>" + Backend.translate(t.name) + "</b>: " + t.description)
@ -233,7 +233,7 @@ Item {
function loadPackages() { function loadPackages() {
if (loaded) return; if (loaded) return;
let packs = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", [])); const packs = JSON.parse(Backend.callLuaFunction("GetAllGeneralPack", []));
packs.forEach((name) => packages.append({ name: name })); packs.forEach((name) => packages.append({ name: name }));
generalDetail.updateGeneral(); generalDetail.updateGeneral();
loaded = true; loaded = true;

View File

@ -71,7 +71,7 @@ Item {
if (model.indexOf(editText) === -1) { if (model.indexOf(editText) === -1) {
passwordEdit.text = ""; passwordEdit.text = "";
} else { } else {
let data = config.savedPassword[editText]; const data = config.savedPassword[editText];
screenNameEdit.text = data.username; screenNameEdit.text = data.username;
passwordEdit.text = data.shorten_password; passwordEdit.text = data.shorten_password;
} }
@ -89,7 +89,7 @@ Item {
text: "" text: ""
onTextChanged: { onTextChanged: {
passwordEdit.text = ""; passwordEdit.text = "";
let data = config.savedPassword[server_addr.editText]; const data = config.savedPassword[server_addr.editText];
if (data) { if (data) {
if (text === data.username) { if (text === data.username) {
passwordEdit.text = data.shorten_password; passwordEdit.text = data.shorten_password;
@ -207,7 +207,7 @@ Item {
server_addr.onModelChanged(); server_addr.onModelChanged();
server_addr.currentIndex = server_addr.model.indexOf(config.lastLoginServer); server_addr.currentIndex = server_addr.model.indexOf(config.lastLoginServer);
let data = config.savedPassword[config.lastLoginServer]; const data = config.savedPassword[config.lastLoginServer];
if (data) { if (data) {
screenNameEdit.text = data.username; screenNameEdit.text = data.username;
passwordEdit.text = data.shorten_password; passwordEdit.text = data.shorten_password;

View File

@ -67,7 +67,7 @@ Item {
} }
Component.onCompleted: { Component.onCompleted: {
let mode_data = JSON.parse(Backend.callLuaFunction("GetGameModes", [])); const mode_data = JSON.parse(Backend.callLuaFunction("GetGameModes", []));
for (let d of mode_data) { for (let d of mode_data) {
modeList.append(d); modeList.append(d);
} }

View File

@ -33,7 +33,7 @@ Item {
text: qsTr("Enable All") text: qsTr("Enable All")
onTriggered: { onTriggered: {
for (let i = 0; i < packageModel.count; i++) { for (let i = 0; i < packageModel.count; i++) {
let name = packageModel.get(i).pkgName; const name = packageModel.get(i).pkgName;
Pacman.enablePack(name); Pacman.enablePack(name);
} }
updatePackageList(); updatePackageList();
@ -43,7 +43,7 @@ Item {
text: qsTr("Disable All") text: qsTr("Disable All")
onTriggered: { onTriggered: {
for (let i = 0; i < packageModel.count; i++) { for (let i = 0; i < packageModel.count; i++) {
let name = packageModel.get(i).pkgName; const name = packageModel.get(i).pkgName;
Pacman.disablePack(name); Pacman.disablePack(name);
} }
updatePackageList(); updatePackageList();
@ -53,7 +53,7 @@ Item {
text: qsTr("Upgrade All") text: qsTr("Upgrade All")
onTriggered: { onTriggered: {
for (let i = 0; i < packageModel.count; i++) { for (let i = 0; i < packageModel.count; i++) {
let name = packageModel.get(i).pkgName; const name = packageModel.get(i).pkgName;
Pacman.upgradePack(name); Pacman.upgradePack(name);
} }
updatePackageList(); updatePackageList();
@ -162,7 +162,7 @@ Item {
text: qsTr("Install From URL") text: qsTr("Install From URL")
enabled: urlEdit.text !== "" enabled: urlEdit.text !== ""
onClicked: { onClicked: {
let url = urlEdit.text; const url = urlEdit.text;
mainWindow.busy = true; mainWindow.busy = true;
Pacman.downloadNewPack(url, true); Pacman.downloadNewPack(url, true);
} }
@ -172,7 +172,7 @@ Item {
function updatePackageList() { function updatePackageList() {
packageModel.clear(); packageModel.clear();
let data = JSON.parse(Pacman.listPackages()); const data = JSON.parse(Pacman.listPackages());
data.forEach(e => packageModel.append({ data.forEach(e => packageModel.append({
pkgName: e.name, pkgName: e.name,
pkgURL: e.url, pkgURL: e.url,
@ -182,7 +182,7 @@ Item {
} }
function downloadComplete() { function downloadComplete() {
let idx = packageList.currentIndex; const idx = packageList.currentIndex;
updatePackageList(); updatePackageList();
packageList.currentIndex = idx; packageList.currentIndex = idx;
} }

View File

@ -125,7 +125,7 @@ Item {
Text { Text {
x: 8; y: 8 x: 8; y: 8
Component.onCompleted: { Component.onCompleted: {
let data = JSON.parse(Backend.callLuaFunction("GetRoomConfig", [])); const data = JSON.parse(Backend.callLuaFunction("GetRoomConfig", []));
text = "手气卡次数:" + data.luckTime + "<br />出手时间:" + config.roomTimeout text = "手气卡次数:" + data.luckTime + "<br />出手时间:" + config.roomTimeout
+ "<br />选将框数:" + data.generalNum + "<br />选将框数:" + data.generalNum
} }
@ -315,7 +315,7 @@ Item {
Logic.enableTargets(card); Logic.enableTargets(card);
if (typeof card === "number" && card !== -1 && roomScene.state === "playing") { if (typeof card === "number" && card !== -1 && roomScene.state === "playing") {
let skills = JSON.parse(Backend.callLuaFunction("GetCardSpecialSkills", [card])); const skills = JSON.parse(Backend.callLuaFunction("GetCardSpecialSkills", [card]));
if (JSON.parse(Backend.callLuaFunction("CanUseCard", [card, Self.id]))) { if (JSON.parse(Backend.callLuaFunction("CanUseCard", [card, Self.id]))) {
skills.unshift("_normal_use"); skills.unshift("_normal_use");
} }
@ -532,7 +532,7 @@ Item {
function activateSkill(skill_name, pressed) { function activateSkill(skill_name, pressed) {
if (pressed) { if (pressed) {
let data = JSON.parse(Backend.callLuaFunction("GetInteractionOfSkill", [skill_name])); const data = JSON.parse(Backend.callLuaFunction("GetInteractionOfSkill", [skill_name]));
if (data) { if (data) {
Backend.callLuaFunction("SetInteractionDataOfSkill", [skill_name, "null"]); Backend.callLuaFunction("SetInteractionDataOfSkill", [skill_name, "null"]);
switch (data.type) { switch (data.type) {
@ -735,9 +735,9 @@ Item {
} }
for (let i = 1; i < specialCardSkills.count; i++) { for (let i = 1; i < specialCardSkills.count; i++) {
let item = specialCardSkills.itemAt(i); const item = specialCardSkills.itemAt(i);
if (item.checked) { if (item.checked) {
let ret = item.orig_text; const ret = item.orig_text;
return ret; return ret;
} }
} }
@ -753,10 +753,10 @@ Item {
if (specialChat(pid, raw, raw.msg.slice(1))) return; if (specialChat(pid, raw, raw.msg.slice(1))) return;
} }
chat.append(msg); chat.append(msg);
let photo = Logic.getPhoto(pid); const photo = Logic.getPhoto(pid);
if (photo === undefined) { if (photo === undefined) {
let user = raw.userName; const user = raw.userName;
let m = raw.msg; const m = raw.msg;
danmaku.sendLog(`${user}: ${m}`); danmaku.sendLog(`${user}: ${m}`);
return; return;
} }
@ -768,13 +768,13 @@ Item {
// death audio: ~%s // death audio: ~%s
// something special: !%s:... // something special: !%s:...
let time = data.time; const time = data.time;
let userName = data.userName; const userName = data.userName;
let general = Backend.translate(data.general); const general = Backend.translate(data.general);
if (msg.startsWith("!")) { if (msg.startsWith("!")) {
let splited = msg.split(":"); const splited = msg.split(":");
let type = splited[0].slice(1); const type = splited[0].slice(1);
switch (type) { switch (type) {
case "Egg": case "Egg":
case "GiantEgg": case "GiantEgg":
@ -800,18 +800,18 @@ Item {
return false; return false;
} }
} else if (msg.startsWith("~")) { } else if (msg.startsWith("~")) {
let g = msg.slice(1); const g = msg.slice(1);
let extension = JSON.parse(Backend.callLuaFunction("GetGeneralData", [g])).extension; const extension = JSON.parse(Backend.callLuaFunction("GetGeneralData", [g])).extension;
if (!config.disableMsgAudio) if (!config.disableMsgAudio)
Backend.playSound("./packages/" + extension + "/audio/death/" + g); Backend.playSound("./packages/" + extension + "/audio/death/" + g);
let m = Backend.translate("~" + g); const m = Backend.translate("~" + g);
if (general === "") if (general === "")
chat.append(`[${time}] ${userName}: ${m}`); chat.append(`[${time}] ${userName}: ${m}`);
else else
chat.append(`[${time}] ${userName}(${general}): ${m}`); chat.append(`[${time}] ${userName}(${general}): ${m}`);
let photo = Logic.getPhoto(pid); const photo = Logic.getPhoto(pid);
if (photo === undefined) { if (photo === undefined) {
danmaku.sendLog(`${userName}: ${m}`); danmaku.sendLog(`${userName}: ${m}`);
return true; return true;
@ -820,24 +820,24 @@ Item {
return true; return true;
} else { } else {
let splited = msg.split(":"); const splited = msg.split(":");
if (splited.length < 2) return false; if (splited.length < 2) return false;
let skill = splited[0]; const skill = splited[0];
let idx = parseInt(splited[1]); const idx = parseInt(splited[1]);
let data2 = JSON.parse(Backend.callLuaFunction("GetSkillData", [skill])); const data2 = JSON.parse(Backend.callLuaFunction("GetSkillData", [skill]));
if (!data2) return false; if (!data2) return false;
let extension = data2.extension; const extension = data2.extension;
if (!config.disableMsgAudio) if (!config.disableMsgAudio)
Backend.playSound("./packages/" + extension + "/audio/skill/" + skill, idx); Backend.playSound("./packages/" + extension + "/audio/skill/" + skill, idx);
let m = Backend.translate("$" + skill + idx.toString()); const m = Backend.translate("$" + skill + idx.toString());
if (general === "") if (general === "")
chat.append(`[${time}] ${userName}: ${m}`); chat.append(`[${time}] ${userName}: ${m}`);
else else
chat.append(`[${time}] ${userName}(${general}): ${m}`); chat.append(`[${time}] ${userName}(${general}): ${m}`);
let photo = Logic.getPhoto(pid); const photo = Logic.getPhoto(pid);
if (photo === undefined) { if (photo === undefined) {
danmaku.sendLog(`${userName}: ${m}`); danmaku.sendLog(`${userName}: ${m}`);
return true; return true;
@ -861,9 +861,9 @@ Item {
function showDistance(show) { function showDistance(show) {
for (let i = 0; i < photoModel.count; i++) { for (let i = 0; i < photoModel.count; i++) {
let item = photos.itemAt(i); const item = photos.itemAt(i);
if (show) { if (show) {
let dis = Backend.callLuaFunction("DistanceTo",[Self.id, item.playerid]); const dis = Backend.callLuaFunction("DistanceTo",[Self.id, item.playerid]);
item.distance = parseInt(dis); item.distance = parseInt(dis);
} else { } else {
item.distance = 0; item.distance = 0;
@ -878,9 +878,9 @@ Item {
} }
function resetToInit() { function resetToInit() {
let datalist = []; const datalist = [];
for (let i = 0; i < photoModel.count; i++) { for (let i = 0; i < photoModel.count; i++) {
let item = photoModel.get(i); const item = photoModel.get(i);
if (item.id > 0) { if (item.id > 0) {
datalist.push({ datalist.push({
id: item.id, id: item.id,

View File

@ -288,8 +288,8 @@ function doIndicate(from, tos) {
for (let i = 0; i < tos.length; i++) { for (let i = 0; i < tos.length; i++) {
if (from === tos[i]) if (from === tos[i])
continue; continue;
let toItem = getPhotoOrDashboard(tos[i]); const toItem = getPhotoOrDashboard(tos[i]);
let toPos = mapFromItem(toItem, toItem.width / 2, toItem.height / 2); const toPos = mapFromItem(toItem, toItem.width / 2, toItem.height / 2);
end.push(toPos); end.push(toPos);
} }
@ -315,7 +315,7 @@ function changeSelf(id) {
// move new selfPhoto to dashboard // move new selfPhoto to dashboard
let order = new Array(photoModel.count); let order = new Array(photoModel.count);
for (let i = 0; i < photoModel.count; i++) { for (let i = 0; i < photoModel.count; i++) {
let item = photoModel.get(i); const item = photoModel.get(i);
order[item.seatNumber - 1] = item.id; order[item.seatNumber - 1] = item.id;
if (item.id === Self.id) { if (item.id === Self.id) {
dashboard.self = photos.itemAt(i); dashboard.self = photos.itemAt(i);
@ -389,7 +389,7 @@ function enableTargets(card) { // card: int | { skill: string, subcards: int[] }
} }
if (candidate) { if (candidate) {
let data = { const data = {
ok_enabled: false, ok_enabled: false,
enabled_targets: [] enabled_targets: []
} }
@ -866,7 +866,7 @@ callbacks["AskForMoveCardInBoard"] = (jsonData) => {
const boxCards = []; const boxCards = [];
cards.forEach(id => { cards.forEach(id => {
let d = Backend.callLuaFunction("GetCardData", [id]); const d = Backend.callLuaFunction("GetCardData", [id]);
boxCards.push(JSON.parse(d)); boxCards.push(JSON.parse(d));
}); });
@ -1032,7 +1032,7 @@ callbacks["SetPlayerMark"] = (jsonData) => {
const player = getPhoto(data[0]); const player = getPhoto(data[0]);
const mark = data[1]; const mark = data[1];
const value = data[2] instanceof Array ? data[2] : data[2].toString(); const value = data[2] instanceof Array ? data[2] : data[2].toString();
if (value === 0) { if (data[2] === 0) {
player.markArea.removeMark(mark); player.markArea.removeMark(mark);
} else { } else {
player.markArea.setMark(mark, mark.startsWith("@@") ? "" : value); player.markArea.setMark(mark, mark.startsWith("@@") ? "" : value);

View File

@ -37,7 +37,7 @@ Item {
inputs = [inputs]; inputs = [inputs];
} }
inputs.forEach(card => { inputs.forEach(card => {
let v = JSON.parse(Backend.callLuaFunction("GetVirtualEquip", [parent.playerid, card.cid])); const v = JSON.parse(Backend.callLuaFunction("GetVirtualEquip", [parent.playerid, card.cid]));
if (v !== null) { if (v !== null) {
cards.append(v); cards.append(v);
} else { } else {
@ -51,11 +51,11 @@ Item {
function remove(outputs) function remove(outputs)
{ {
let result = area.remove(outputs); const result = area.remove(outputs);
for (let i = 0; i < result.length; i++) { for (let i = 0; i < result.length; i++) {
let item = result[i]; const item = result[i];
for (let j = 0; j < cards.count; j++) { for (let j = 0; j < cards.count; j++) {
let icon = cards.get(j); const icon = cards.get(j);
if (icon.cid === item.cid) { if (icon.cid === item.cid) {
cards.remove(j, 1); cards.remove(j, 1);
break; break;

View File

@ -100,11 +100,11 @@ Column {
function remove(outputs) function remove(outputs)
{ {
let result = area.remove(outputs); const result = area.remove(outputs);
for (let i = 0; i < result.length; i++) { for (let i = 0; i < result.length; i++) {
let card = result[i]; const card = result[i];
for (let j = 0; j < items.length; j++) { for (let j = 0; j < items.length; j++) {
let item = items[j]; const item = items[j];
if (item.cid === card.cid) { if (item.cid === card.cid) {
item.reset(); item.reset();
item.hide(); item.hide();

View File

@ -19,7 +19,7 @@ ColumnLayout {
function update(skill, times) { function update(skill, times) {
for (let i = 0; i < rep.count; i++) { for (let i = 0; i < rep.count; i++) {
let data = skills.get(i); const data = skills.get(i);
if (data.skillname_ === skill) { if (data.skillname_ === skill) {
data.times = times; data.times = times;
return; return;

View File

@ -120,17 +120,17 @@ Item {
let x = 0; let x = 0;
let y = 0; let y = 0;
let i; let i;
let marks = []; const marks = [];
let long_marks = []; const long_marks = [];
for (i = 0; i < markRepeater.count; i++) { for (i = 0; i < markRepeater.count; i++) {
let item = markRepeater.itemAt(i); const item = markRepeater.itemAt(i);
let w = item.width; const w = item.width;
if (w < width / 2) marks.push(item); if (w < width / 2) marks.push(item);
else long_marks.push(item); else long_marks.push(item);
} }
marks.concat(long_marks).forEach(item => { marks.concat(long_marks).forEach(item => {
let w = item.width; const w = item.width;
if (x === 0) { if (x === 0) {
item.x = x; item.y = y; item.x = x; item.y = y;

View File

@ -56,7 +56,7 @@ GraphicsBox {
function takeAG(g, cid) { function takeAG(g, cid) {
for (let i = 0; i < cards.count; i++) { for (let i = 0; i < cards.count; i++) {
let item = cards.get(i); const item = cards.get(i);
if (item.cid !== cid) continue; if (item.cid !== cid) continue;
item.footnote = g; item.footnote = g;
item.selectable = false; item.selectable = false;

View File

@ -26,7 +26,7 @@ Item {
for (let i = 0; i < cards.length; i++) { for (let i = 0; i < cards.length; i++) {
for (let j = 0; j < outputs.length; j++) { for (let j = 0; j < outputs.length; j++) {
if (outputs[j] === cards[i].cid) { if (outputs[j] === cards[i].cid) {
let state = JSON.parse(Backend.callLuaFunction("GetCardData", [cards[i].cid])); const state = JSON.parse(Backend.callLuaFunction("GetCardData", [cards[i].cid]));
cards[i].setData(state); cards[i].setData(state);
result.push(cards[i]); result.push(cards[i]);
cards.splice(i, 1); cards.splice(i, 1);
@ -56,8 +56,8 @@ Item {
if (overflow) { if (overflow) {
// TODO: Adjust cards in multiple lines if there are too many cards // TODO: Adjust cards in multiple lines if there are too many cards
let xLimit = root.width - card.width; const xLimit = root.width - card.width;
let spacing = xLimit / (cards.length - 1); const spacing = xLimit / (cards.length - 1);
for (i = 0; i < cards.length; i++) { for (i = 0; i < cards.length; i++) {
card = cards[i]; card = cards[i];
card.origX = i * spacing; card.origX = i * spacing;
@ -65,7 +65,7 @@ Item {
} }
} }
let parentPos = roomScene.mapFromItem(root, 0, 0); const parentPos = roomScene.mapFromItem(root, 0, 0);
for (i = 0; i < cards.length; i++) { for (i = 0; i < cards.length; i++) {
card = cards[i]; card = cards[i];
card.origX += parentPos.x; card.origX += parentPos.x;

View File

@ -257,7 +257,7 @@ Item {
function toData() function toData()
{ {
let data = { const data = {
cid: cid, cid: cid,
name: name, name: name,
suit: suit, suit: suit,

View File

@ -69,32 +69,32 @@ RowLayout {
} }
function expandPile(pile) { function expandPile(pile) {
let expanded_pile_names = Object.keys(expanded_piles); const expanded_pile_names = Object.keys(expanded_piles);
if (expanded_pile_names.indexOf(pile) !== -1) if (expanded_pile_names.indexOf(pile) !== -1)
return; return;
let component = Qt.createComponent("../RoomElement/CardItem.qml"); const component = Qt.createComponent("../RoomElement/CardItem.qml");
let parentPos = roomScene.mapFromItem(self, 0, 0); const parentPos = roomScene.mapFromItem(self, 0, 0);
expanded_piles[pile] = []; expanded_piles[pile] = [];
if (pile === "_equip") { if (pile === "_equip") {
let equips = self.equipArea.getAllCards(); const equips = self.equipArea.getAllCards();
equips.forEach(data => { equips.forEach(data => {
data.x = parentPos.x; data.x = parentPos.x;
data.y = parentPos.y; data.y = parentPos.y;
let card = component.createObject(roomScene, data); const card = component.createObject(roomScene, data);
card.footnoteVisible = true; card.footnoteVisible = true;
card.footnote = Backend.translate("$Equip"); card.footnote = Backend.translate("$Equip");
handcardAreaItem.add(card); handcardAreaItem.add(card);
}) })
handcardAreaItem.updateCardPosition(); handcardAreaItem.updateCardPosition();
} else { } else {
let ids = JSON.parse(Backend.callLuaFunction("GetPile", [self.playerid, pile])); const ids = JSON.parse(Backend.callLuaFunction("GetPile", [self.playerid, pile]));
ids.forEach(id => { ids.forEach(id => {
let data = JSON.parse(Backend.callLuaFunction("GetCardData", [id])); const data = JSON.parse(Backend.callLuaFunction("GetCardData", [id]));
data.x = parentPos.x; data.x = parentPos.x;
data.y = parentPos.y; data.y = parentPos.y;
let card = component.createObject(roomScene, data); const card = component.createObject(roomScene, data);
card.footnoteVisible = true; card.footnoteVisible = true;
card.footnote = Backend.translate(pile); card.footnote = Backend.translate(pile);
handcardAreaItem.add(card); handcardAreaItem.add(card);
@ -104,17 +104,17 @@ RowLayout {
} }
function retractPile(pile) { function retractPile(pile) {
let expanded_pile_names = Object.keys(expanded_piles); const expanded_pile_names = Object.keys(expanded_piles);
if (expanded_pile_names.indexOf(pile) === -1) if (expanded_pile_names.indexOf(pile) === -1)
return; return;
let parentPos = roomScene.mapFromItem(self, 0, 0); const parentPos = roomScene.mapFromItem(self, 0, 0);
delete expanded_piles[pile]; delete expanded_piles[pile];
if (pile === "_equip") { if (pile === "_equip") {
let equips = self.equipArea.getAllCards(); const equips = self.equipArea.getAllCards();
equips.forEach(data => { equips.forEach(data => {
let card = handcardAreaItem.remove([data.cid])[0]; const card = handcardAreaItem.remove([data.cid])[0];
card.origX = parentPos.x; card.origX = parentPos.x;
card.origY = parentPos.y; card.origY = parentPos.y;
card.destroyOnStop(); card.destroyOnStop();
@ -122,9 +122,9 @@ RowLayout {
}) })
handcardAreaItem.updateCardPosition(); handcardAreaItem.updateCardPosition();
} else { } else {
let ids = JSON.parse(Backend.callLuaFunction("GetPile", [self.playerid, pile])); const ids = JSON.parse(Backend.callLuaFunction("GetPile", [self.playerid, pile]));
ids.forEach(id => { ids.forEach(id => {
let card = handcardAreaItem.remove([id])[0]; const card = handcardAreaItem.remove([id])[0];
card.origX = parentPos.x; card.origX = parentPos.x;
card.origY = parentPos.y; card.origY = parentPos.y;
card.destroyOnStop(); card.destroyOnStop();
@ -159,7 +159,8 @@ RowLayout {
return ret; return ret;
} }
if (cname) { if (cname) {
let ids = [], cards = handcardAreaItem.cards; const ids = [];
let cards = handcardAreaItem.cards;
for (let i = 0; i < cards.length; i++) { for (let i = 0; i < cards.length; i++) {
if (cardValid(cards[i].cid, cname)) { if (cardValid(cards[i].cid, cname)) {
ids.push(cards[i].cid); ids.push(cards[i].cid);
@ -177,7 +178,7 @@ RowLayout {
// Must manually analyze pattern here // Must manually analyze pattern here
let pile_list = cname.split("|")[4]; let pile_list = cname.split("|")[4];
let pile_data = JSON.parse(Backend.callLuaFunction("GetAllPiles", [self.playerid])); const pile_data = JSON.parse(Backend.callLuaFunction("GetAllPiles", [self.playerid]));
if (pile_list && pile_list !== "." && !(pile_data instanceof Array)) { if (pile_list && pile_list !== "." && !(pile_data instanceof Array)) {
pile_list = pile_list.split(","); pile_list = pile_list.split(",");
for (let pile_name of pile_list) { for (let pile_name of pile_list) {
@ -196,15 +197,15 @@ RowLayout {
return; return;
} }
let ids = [], cards = handcardAreaItem.cards; const ids = [], cards = handcardAreaItem.cards;
for (let i = 0; i < cards.length; i++) { for (let i = 0; i < cards.length; i++) {
if (JSON.parse(Backend.callLuaFunction("CanUseCard", [cards[i].cid, Self.id]))) { if (JSON.parse(Backend.callLuaFunction("CanUseCard", [cards[i].cid, Self.id]))) {
ids.push(cards[i].cid); ids.push(cards[i].cid);
} else { } else {
// cannot use? considering special_skills // cannot use? considering special_skills
let skills = JSON.parse(Backend.callLuaFunction("GetCardSpecialSkills", [cards[i].cid])); const skills = JSON.parse(Backend.callLuaFunction("GetCardSpecialSkills", [cards[i].cid]));
for (let j = 0; j < skills.length; j++) { for (let j = 0; j < skills.length; j++) {
let s = skills[j]; const s = skills[j];
if (JSON.parse(Backend.callLuaFunction("ActiveCanUse", [s]))) { if (JSON.parse(Backend.callLuaFunction("ActiveCanUse", [s]))) {
ids.push(cards[i].cid); ids.push(cards[i].cid);
break; break;
@ -253,8 +254,8 @@ RowLayout {
function updatePending() { function updatePending() {
if (pending_skill === "") return; if (pending_skill === "") return;
let enabled_cards = []; const enabled_cards = [];
let targets = roomScene.selected_targets; const targets = roomScene.selected_targets;
handcardAreaItem.cards.forEach((card) => { handcardAreaItem.cards.forEach((card) => {
if (card.selected || JSON.parse(Backend.callLuaFunction( if (card.selected || JSON.parse(Backend.callLuaFunction(
@ -264,7 +265,7 @@ RowLayout {
enabled_cards.push(card.cid); enabled_cards.push(card.cid);
}); });
let cards = self.equipArea.getAllCards(); const cards = self.equipArea.getAllCards();
cards.forEach(c => { cards.forEach(c => {
if (JSON.parse(Backend.callLuaFunction( if (JSON.parse(Backend.callLuaFunction(
"ActiveCardFilter", "ActiveCardFilter",
@ -277,8 +278,8 @@ RowLayout {
} }
}) })
let pile = Backend.callLuaFunction("GetExpandPileOfSkill", [pending_skill]); const pile = Backend.callLuaFunction("GetExpandPileOfSkill", [pending_skill]);
let pile_ids = JSON.parse(Backend.callLuaFunction("GetPile", [self.playerid, pile])); const pile_ids = JSON.parse(Backend.callLuaFunction("GetPile", [self.playerid, pile]));
pile_ids.forEach(cid => { pile_ids.forEach(cid => {
if (JSON.parse(Backend.callLuaFunction( if (JSON.parse(Backend.callLuaFunction(
"ActiveCardFilter", "ActiveCardFilter",
@ -313,7 +314,7 @@ RowLayout {
pendings = []; pendings = [];
handcardAreaItem.unselectAll(); handcardAreaItem.unselectAll();
for (let i = 0; i < skillButtons.count; i++) { for (let i = 0; i < skillButtons.count; i++) {
let item = skillButtons.itemAt(i); const item = skillButtons.itemAt(i);
item.enabled = item.pressed; item.enabled = item.pressed;
} }
@ -347,9 +348,9 @@ RowLayout {
} }
function prelightSkill(skill_name, prelight) { function prelightSkill(skill_name, prelight) {
let btns = skillPanel.prelight_buttons; const btns = skillPanel.prelight_buttons;
for (let i = 0; i < btns.count; i++) { for (let i = 0; i < btns.count; i++) {
let btn = btns.itemAt(i); const btn = btns.itemAt(i);
if (btn.orig === skill_name) { if (btn.orig === skill_name) {
btn.prelighted = prelight; btn.prelighted = prelight;
btn.enabled = true; btn.enabled = true;
@ -361,15 +362,15 @@ RowLayout {
if (cname) { if (cname) {
// if cname is presented, we are responding use or play. // if cname is presented, we are responding use or play.
for (let i = 0; i < skillButtons.count; i++) { for (let i = 0; i < skillButtons.count; i++) {
let item = skillButtons.itemAt(i); const item = skillButtons.itemAt(i);
let fitpattern = JSON.parse(Backend.callLuaFunction("SkillFitPattern", [item.orig, cname])); const fitpattern = JSON.parse(Backend.callLuaFunction("SkillFitPattern", [item.orig, cname]));
let canresp = JSON.parse(Backend.callLuaFunction("SkillCanResponse", [item.orig, cardResponsing])); const canresp = JSON.parse(Backend.callLuaFunction("SkillCanResponse", [item.orig, cardResponsing]));
item.enabled = fitpattern && canresp; item.enabled = fitpattern && canresp;
} }
return; return;
} }
for (let i = 0; i < skillButtons.count; i++) { for (let i = 0; i < skillButtons.count; i++) {
let item = skillButtons.itemAt(i); const item = skillButtons.itemAt(i);
item.enabled = JSON.parse(Backend.callLuaFunction("ActiveCanUse", [item.orig])); item.enabled = JSON.parse(Backend.callLuaFunction("ActiveCanUse", [item.orig]));
} }
} }
@ -387,8 +388,8 @@ RowLayout {
unSelectAll(); unSelectAll();
disableSkills(); disableSkills();
let cards = handcardAreaItem.cards; const cards = handcardAreaItem.cards;
let toRemove = []; const toRemove = [];
for (let c of cards) { for (let c of cards) {
toRemove.push(c.cid); toRemove.push(c.cid);
c.origY += 30; c.origY += 30;
@ -400,7 +401,7 @@ RowLayout {
skillPanel.clearSkills(); skillPanel.clearSkills();
let skills = JSON.parse(Backend.callLuaFunction("GetPlayerSkills", [Self.id])); const skills = JSON.parse(Backend.callLuaFunction("GetPlayerSkills", [Self.id]));
for (let s of skills) { for (let s of skills) {
addSkill(s.name); addSkill(s.name);
} }

View File

@ -155,14 +155,14 @@ CardItem {
} }
onNameChanged: { onNameChanged: {
let data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [name])); const data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [name]));
kingdom = data.kingdom; kingdom = data.kingdom;
subkingdom = (data.subkingdom !== kingdom && data.subkingdom) || ""; subkingdom = (data.subkingdom !== kingdom && data.subkingdom) || "";
hp = data.hp; hp = data.hp;
maxHp = data.maxHp; maxHp = data.maxHp;
shieldNum = data.shield; shieldNum = data.shield;
let splited = name.split("__"); const splited = name.split("__");
if (splited.length > 1) { if (splited.length > 1) {
pkgName = splited[0]; pkgName = splited[0];
} else { } else {

View File

@ -144,9 +144,9 @@ GraphicsBox {
} }
function getResult() { function getResult() {
let ret = []; const ret = [];
result.forEach(t => { result.forEach(t => {
let t2 = []; const t2 = [];
t.forEach(v => t2.push(v.cid)); t.forEach(v => t2.push(v.cid));
ret.push(t2); ret.push(t2);
}); });

View File

@ -40,7 +40,7 @@ Item {
function remove(outputs) function remove(outputs)
{ {
let result = cardArea.remove(outputs); const result = cardArea.remove(outputs);
let card; let card;
for (let i = 0; i < result.length; i++) { for (let i = 0; i < result.length; i++) {
card = result[i]; card = result[i];
@ -87,7 +87,7 @@ Item {
area.updateCardPosition(true); area.updateCardPosition(true);
for (let i = 0; i < cards.length; i++) { for (let i = 0; i < cards.length; i++) {
let card = cards[i]; const card = cards[i];
if (card.selected) { if (card.selected) {
if (!selectedCards.contains(card)) if (!selectedCards.contains(card))
selectCard(card); selectCard(card);

View File

@ -50,16 +50,16 @@ Item {
function remove(outputs) function remove(outputs)
{ {
let component = Qt.createComponent("CardItem.qml"); const component = Qt.createComponent("CardItem.qml");
if (component.status !== Component.Ready) if (component.status !== Component.Ready)
return []; return [];
let parentPos = roomScene.mapFromItem(root, 0, 0); const parentPos = roomScene.mapFromItem(root, 0, 0);
let card; let card;
let items = []; const items = [];
for (let i = 0; i < outputs.length; i++) { for (let i = 0; i < outputs.length; i++) {
if (_contains(outputs[i])) { if (_contains(outputs[i])) {
let state = JSON.parse(Backend.callLuaFunction("GetCardData", [outputs[i]])) const state = JSON.parse(Backend.callLuaFunction("GetCardData", [outputs[i]]))
state.x = parentPos.x; state.x = parentPos.x;
state.y = parentPos.y; state.y = parentPos.y;
state.opacity = 0; state.opacity = 0;
@ -90,7 +90,7 @@ Item {
let i, card; let i, card;
if (animated) { if (animated) {
let parentPos = roomScene.mapFromItem(root, 0, 0); const parentPos = roomScene.mapFromItem(root, 0, 0);
for (i = 0; i < pendingInput.length; i++) { for (i = 0; i < pendingInput.length; i++) {
card = pendingInput[i]; card = pendingInput[i];
card.origX = parentPos.x - card.width / 2 + ((i - pendingInput.length / 2) * 15); card.origX = parentPos.x - card.width / 2 + ((i - pendingInput.length / 2) * 15);

View File

@ -9,9 +9,9 @@ Item {
visible: roundNum || pileNum visible: roundNum || pileNum
function getTimeString(time) { function getTimeString(time) {
let s = time % 60; const s = time % 60;
let m = (time - s) / 60; const m = (time - s) / 60;
let h = (time - s - m * 60) / 3600; const h = (time - s - m * 60) / 3600;
return h ? `${h}:${m}:${s}` : `${m}:${s}`; return h ? `${h}:${m}:${s}` : `${m}:${s}`;
} }

View File

@ -293,7 +293,7 @@ Item {
} }
function updatePileInfo(areaName) { function updatePileInfo(areaName) {
let data = JSON.parse(Backend.callLuaFunction("GetPile", [root.playerid, areaName])); const data = JSON.parse(Backend.callLuaFunction("GetPile", [root.playerid, areaName]));
if (data.length === 0) { if (data.length === 0) {
root.markArea.removeMark(areaName); root.markArea.removeMark(areaName);
} else { } else {
@ -576,7 +576,7 @@ Item {
onGeneralChanged: { onGeneralChanged: {
if (!roomScene.isStarted) return; if (!roomScene.isStarted) return;
let text = Backend.translate(general); const text = Backend.translate(general);
if (text.length > 6) { if (text.length > 6) {
generalName.text = ""; generalName.text = "";
longGeneralName.text = text; longGeneralName.text = text;

View File

@ -111,7 +111,7 @@ Flickable {
return false; return false;
}; };
let data = JSON.parse(Backend.callLuaFunction( const data = JSON.parse(Backend.callLuaFunction(
"GetSkillData", "GetSkillData",
[skill_name] [skill_name]
)); ));
@ -133,7 +133,7 @@ Flickable {
function loseSkill(skill_name, prelight) { function loseSkill(skill_name, prelight) {
if (prelight) { if (prelight) {
for (let i = 0; i < prelight_skills.count; i++) { for (let i = 0; i < prelight_skills.count; i++) {
let item = prelight_skills.get(i); const item = prelight_skills.get(i);
if (item.orig_skill == skill_name) { if (item.orig_skill == skill_name) {
prelight_skills.remove(i); prelight_skills.remove(i);
} }
@ -142,13 +142,13 @@ Flickable {
} }
for (let i = 0; i < active_skills.count; i++) { for (let i = 0; i < active_skills.count; i++) {
let item = active_skills.get(i); const item = active_skills.get(i);
if (item.orig_skill == skill_name) { if (item.orig_skill == skill_name) {
active_skills.remove(i); active_skills.remove(i);
} }
} }
for (let i = 0; i < not_active_skills.count; i++) { for (let i = 0; i < not_active_skills.count; i++) {
let item = not_active_skills.get(i); const item = not_active_skills.get(i);
if (item.orig_skill == skill_name) { if (item.orig_skill == skill_name) {
not_active_skills.remove(i); not_active_skills.remove(i);
} }

View File

@ -61,7 +61,7 @@ Item {
area.add(inputs); area.add(inputs);
// if (!inputs instanceof Array) // if (!inputs instanceof Array)
for (let i = 0; i < inputs.length; i++) { for (let i = 0; i < inputs.length; i++) {
let c = inputs[i]; const c = inputs[i];
c.footnoteVisible = true; c.footnoteVisible = true;
c.selectable = true; c.selectable = true;
c.height = c.height * 0.8; c.height = c.height * 0.8;
@ -76,14 +76,14 @@ Item {
let result = area.remove(outputs); let result = area.remove(outputs);
for (let i = 0; i < result.length; i++) { for (let i = 0; i < result.length; i++) {
let c = result[i]; const c = result[i];
c.footnoteVisible = false; c.footnoteVisible = false;
c.selectable = false; c.selectable = false;
c.height = c.height / 0.8; c.height = c.height / 0.8;
c.width = c.width / 0.8; c.width = c.width / 0.8;
c.rotation = 0; c.rotation = 0;
} }
let vanished = []; const vanished = [];
if (result.length < outputs.length) { if (result.length < outputs.length) {
for (i = 0; i < outputs.length; i++) { for (i = 0; i < outputs.length; i++) {
let exists = false; let exists = false;
@ -131,8 +131,8 @@ Item {
if (overflow) { if (overflow) {
//@to-do: Adjust cards in multiple lines if there are too many cards //@to-do: Adjust cards in multiple lines if there are too many cards
let xLimit = root.width - card.width; const xLimit = root.width - card.width;
let spacing = xLimit / (cards.length - 1); const spacing = xLimit / (cards.length - 1);
for (i = 0; i < cards.length; i++) { for (i = 0; i < cards.length; i++) {
card = cards[i]; card = cards[i];
card.origX = i * spacing; card.origX = i * spacing;
@ -140,8 +140,8 @@ Item {
} }
} }
let offsetX = Math.max(0, (root.width - cards.length * card.width) / 2); const offsetX = Math.max(0, (root.width - cards.length * card.width) / 2);
let parentPos = roomScene.mapFromItem(root, 0, 0); const parentPos = roomScene.mapFromItem(root, 0, 0);
for (i = 0; i < cards.length; i++) { for (i = 0; i < cards.length; i++) {
card = cards[i]; card = cards[i];
card.origX += parentPos.x + offsetX; card.origX += parentPos.x + offsetX;

View File

@ -35,7 +35,7 @@ MetroButton {
onClicked: { onClicked: {
roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/ChoiceBox.qml"); roomScene.popupBox.sourceComponent = Qt.createComponent("../RoomElement/ChoiceBox.qml");
let box = roomScene.popupBox.item; const box = roomScene.popupBox.item;
box.options = choices; box.options = choices;
box.accepted.connect(() => { box.accepted.connect(() => {
answer = choices[box.result]; answer = choices[box.result];

View File

@ -168,7 +168,7 @@ Window {
} }
function fetchMessage() { function fetchMessage() {
let ret = pending_message.splice(0, 1)[0]; const ret = pending_message.splice(0, 1)[0];
if (pending_message.length === 0) { if (pending_message.length === 0) {
is_pending = false; is_pending = false;
} }
@ -176,7 +176,7 @@ Window {
} }
function handleMessage(command, jsonData) { function handleMessage(command, jsonData) {
let cb = callbacks[command] const cb = callbacks[command]
if (typeof(cb) === "function") { if (typeof(cb) === "function") {
cb(jsonData); cb(jsonData);
} else { } else {

View File

@ -20,9 +20,9 @@ var TILE_ICON_DIR = AppPath + "/image/button/tileicon/"
var LOBBY_IMG_DIR = AppPath + "/image/lobby/"; var LOBBY_IMG_DIR = AppPath + "/image/lobby/";
function getGeneralPicture(name) { function getGeneralPicture(name) {
let data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [name])); const data = JSON.parse(Backend.callLuaFunction("GetGeneralData", [name]));
let extension = data.extension; const extension = data.extension;
let path = AppPath + "/packages/" + extension + "/image/generals/" + name + ".jpg"; const path = AppPath + "/packages/" + extension + "/image/generals/" + name + ".jpg";
if (Backend.exists(path)) { if (Backend.exists(path)) {
return path; return path;
} }
@ -54,7 +54,7 @@ function getCardPicture(cidOrName) {
} }
function getDelayedTrickPicture(name) { function getDelayedTrickPicture(name) {
let extension = Backend.callLuaFunction("GetCardExtensionByName", [name]); const extension = Backend.callLuaFunction("GetCardExtensionByName", [name]);
let path = AppPath + "/packages/" + extension + "/image/card/delayedTrick/" + name + ".png"; let path = AppPath + "/packages/" + extension + "/image/card/delayedTrick/" + name + ".png";
if (Backend.exists(path)) { if (Backend.exists(path)) {
@ -70,9 +70,9 @@ function getDelayedTrickPicture(name) {
function getEquipIcon(cid, icon) { function getEquipIcon(cid, icon) {
let data = JSON.parse(Backend.callLuaFunction("GetCardData", [cid])); const data = JSON.parse(Backend.callLuaFunction("GetCardData", [cid]));
let extension = data.extension; const extension = data.extension;
let name = icon || data.name; const name = icon || data.name;
let path = AppPath + "/packages/" + extension + "/image/card/equipIcon/" + name + ".png"; let path = AppPath + "/packages/" + extension + "/image/card/equipIcon/" + name + ".png";
if (Backend.exists(path)) { if (Backend.exists(path)) {
return path; return path;

View File

@ -1307,8 +1307,8 @@ function Room:askForGuanxing(player, cards, top_limit, bottom_limit, customNotif
bottom = d[2] bottom = d[2]
end end
else else
top = table.random(cards, top_limit and top_limit[2] or #cards) top = table.random(cards, top_limit and top_limit[2] or #cards) or {}
bottom = table.shuffle(table.filter(cards, function(id) return not table.contains(top, id) end)) bottom = table.shuffle(table.filter(cards, function(id) return not table.contains(top, id) end)) or {}
end end
if not noPut then if not noPut then