FreeKill/Fk/util.js
Nyutanislavsky 4235bf6237
enhance processPrompt (#355)
1. 改进processPrompt,支持双将和暗将
2. 副将长名旋转
3. 国战体力上限优化,包括一览和选将框
4. 空格添加结束出牌阶段,Escape键呼出菜单
5. 武将一览左栏文本换行
6. 同名替换影响已选择的武将
7. 再次排序手牌时按照点数排序
8. Logic.js翻译
9. 进入房间翻译删去句号,跟房间内其他toast风格统一
10. 常见疑问最后一张“下一条”改为“OK!”
11. 录像回放“从文件打开”翻译
12. interaction自动弹出和关闭,comboBox补技能名
13. 卡牌音效添加装备效果音效和使用音效,小小重构
14. activeSkill的prompt的selected_targets实装
15. 禁用扩展包文本ui限制长度
16. 右键技能呼出气泡
Qsgs-Fans/freekill-core#3
2024-06-10 14:58:48 +08:00

48 lines
1.2 KiB
JavaScript

// SPDX-License-Identifier: GPL-3.0-or-later
function convertNumber(number) {
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 "";
}
function getPlayerStr(playerid) {
const photo = getPhoto(playerid);
if (photo.general === "anjiang" && (photo.deputyGeneral === "anjiang" || !p.deputyGeneral)) {
return luatr("seat#" + photo.seatNumber);
}
let ret = photo.general;
ret = luatr(ret);
if (photo.deputyGeneral && photo.deputyGeneral !== "") {
ret = ret + "/" + luatr(photo.deputyGeneral);
}
return ret;
}
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"))
raw = raw.replace(/%src/g, getPlayerStr(src));
if (raw.match("%dest"))
raw = raw.replace(/%dest/g, getPlayerStr(dest));
if (raw.match("%arg2"))
raw = raw.replace(/%arg2/g, luatr(data[4]));
if (raw.match("%arg"))
raw = raw.replace(/%arg/g, luatr(data[3]));
return raw;
}
Array.prototype.prepend = function() {
this.splice(0, 0, ...arguments);
}