This commit is contained in:
Putoo
2026-05-27 18:26:50 +08:00
parent 36a7575990
commit 0d5443ef36
28 changed files with 1043 additions and 25 deletions

View File

@@ -1,9 +1,9 @@
export class GameTool {
/**
* 静态方法:将总铜数转换为 金/银/铜 字符串
* @param totalCopper 总铜数量
* @returns 格式化字符串1金 234银 567铜
*/
/**
* 静态方法:将总铜数转换为 金/银/铜 字符串
* @param totalCopper 总铜数量
* @returns 格式化字符串1金 234银 567铜
*/
public static FormatCopper(totalCopper: number | string): string {
// 安全转为数字并取整(货币无小数)
let copper = Math.floor(Number(totalCopper) || 0);
@@ -35,4 +35,49 @@ export class GameTool {
return result;
}
/**获取货币名称 */
public static GetCurrencyName(pay: string): string {
let result = "";
switch (pay) {
case 'gold':
result = '金元';
break;
case 'cowry':
result = '金贝';
break;
case 'copper':
result = '铜贝';
break;
case 'teach':
result = '师德';
break;
case 'renown':
result = '声望';
break;
}
return result;
}
public static GetCurrencyNameAll(num: number, pay: string): string {
let result = "";
switch (pay) {
case 'gold':
result = '金元';
break;
case 'cowry':
result = '金贝';
break;
case 'copper':
return this.FormatCopper(num);
break;
case 'teach':
result = '师德';
break;
case 'renown':
result = '声望';
break;
}
return `${num}${result}`;
}
}