2023-04-09 13:35:35 +08:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-04-14 18:22:00 +08:00
|
|
|
function convertNumber(number) {
|
2022-04-30 15:27:56 +08:00
|
|
|
if (number === 1)
|
|
|
|
return "A";
|
|
|
|
if (number >= 2 && number <= 10)
|
|
|
|
return number;
|
|
|
|
if (number >= 11 && number <= 13) {
|
|
|
|
const strs = ["J", "Q", "K"];
|
|
|
|
return strs[number - 11];
|
|
|
|
}
|
|
|
|
return "";
|
2022-04-14 18:22:00 +08:00
|
|
|
}
|
|
|
|
|
2024-06-10 14:58:48 +08:00
|
|
|
function getPlayerStr(playerid) {
|
|
|
|
const photo = getPhoto(playerid);
|
2024-06-27 18:42:06 +08:00
|
|
|
if (photo.general === "anjiang" && (photo.deputyGeneral === "anjiang" || !photo.deputyGeneral)) {
|
2024-06-10 14:58:48 +08:00
|
|
|
return luatr("seat#" + photo.seatNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
let ret = photo.general;
|
|
|
|
ret = luatr(ret);
|
|
|
|
if (photo.deputyGeneral && photo.deputyGeneral !== "") {
|
|
|
|
ret = ret + "/" + luatr(photo.deputyGeneral);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2024-01-25 03:23:29 +08:00
|
|
|
function processPrompt(prompt) {
|
|
|
|
const data = prompt.split(":");
|
|
|
|
let raw = luatr(data[0]);
|
|
|
|
const src = parseInt(data[1]);
|
|
|
|
const dest = parseInt(data[2]);
|
|
|
|
if (raw.match("%src"))
|
2024-06-10 14:58:48 +08:00
|
|
|
raw = raw.replace(/%src/g, getPlayerStr(src));
|
2024-01-25 03:23:29 +08:00
|
|
|
if (raw.match("%dest"))
|
2024-09-19 00:00:58 +08:00
|
|
|
raw = raw.replace(/%dest/g, luatr(getPhoto(dest).general));
|
|
|
|
|
|
|
|
if (data.length > 3) {
|
|
|
|
for (let i = 4; i < data.length; i++) {
|
|
|
|
raw = raw.replace(new RegExp("%arg" + (i - 2), "g"), data[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
raw = raw.replace(new RegExp("%arg", "g"), data[3]);
|
|
|
|
}
|
2024-01-25 03:23:29 +08:00
|
|
|
return raw;
|
2022-04-14 18:22:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Array.prototype.prepend = function() {
|
2022-04-30 15:27:56 +08:00
|
|
|
this.splice(0, 0, ...arguments);
|
2022-04-14 18:22:00 +08:00
|
|
|
}
|