feat(i18n): 为英雄、技能和成就添加本地化支持

在多个配置文件中引入本地化函数,将硬编码的文本替换为从语言文件获取的键值。
添加了对应的中文字符串到语言文件,支持游戏内多语言切换。
This commit is contained in:
panw
2026-04-29 09:47:32 +08:00
parent a36516db60
commit 958aa0a9d2
6 changed files with 582 additions and 407 deletions

View File

@@ -1,6 +1,9 @@
import * as exp from "constants"
import { HeroInfo, HType } from "./heroSet"
import { FightSet } from "./GameSet"
import { oops } from "db://oops-framework/core/Oops"
const t = (key: string) => oops.language.getLangByID(key);
/** 卡牌大类定义 */
export enum CardType {
@@ -84,14 +87,14 @@ export const CardPoolList: CardConfig[] = [
{ uuid: 5304, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 3, kind: CKind.Hero, hero_lv: 1 },
// 技能卡牌 (以增益/辅助为主,因为在备战期没有敌人)
{ uuid: 6401, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: "单体攻击", info: "随机1个友方+5攻击", is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6402, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: "单体生命", info: "随机1个友方+20最大生命值", is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6403, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: "单体全能", info: "随机1个友方+2攻击,+10最大生命值", is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6404, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: "群体攻击", info: "随机3个友方+2攻击", is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6405, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, name: "群体生命", info: "随机3个友方+10最大生命值", is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6406, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, name: "群体全能", info: "为随机3个友方单位增加攻击力和生命上限", is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6304, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 3, kind: CKind.Skill, card_lv: 1, name: "神圣治疗", info: "恢复场上随机3个友方单位的生命值", is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6305, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 3, kind: CKind.Skill, card_lv: 1, name: "群体护盾", info: "随机3个友方获得2次伤害免疫", is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6401, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, get name(){return t("skill_name_6401")}, get info(){return t("skill_info_6401")}, is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6402, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, get name(){return t("skill_name_6402")}, get info(){return t("skill_info_6402")}, is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6403, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, get name(){return t("skill_name_6403")}, get info(){return t("skill_info_6403")}, is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6404, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, get name(){return t("skill_name_6404")}, get info(){return t("skill_info_6404")}, is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6405, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, get name(){return t("skill_name_6405")}, get info(){return t("skill_info_6405")}, is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6406, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, get name(){return t("skill_name_6406")}, get info(){return t("skill_info_6406")}, is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6304, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 3, kind: CKind.Skill, card_lv: 1, get name(){return t("skill_name_6304")}, get info(){return t("skill_info_6304")}, is_inst: true, t_times: 1, t_inv: 0 },
{ uuid: 6305, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 3, kind: CKind.Skill, card_lv: 1, get name(){return t("skill_name_6305")}, get info(){return t("skill_info_6305")}, is_inst: true, t_times: 1, t_inv: 0 },
// { uuid: 7101, type: CardType.SpecialRefresh, cost: 1, weight: 12, pool_lv: 1 ,kind: CKind.Card },
// { uuid: 7102, type: CardType.SpecialRefresh, cost: 1, weight: 12, pool_lv: 1 ,kind: CKind.Card },
@@ -126,22 +129,22 @@ export interface SpecialRefreshCardConfig extends CardConfig {
export const SpecialUpgradeCardList: Record<number, SpecialUpgradeCardConfig> = {
7001: { uuid: 7001,type: CardType.SpecialUpgrade,cost: 6,weight: 16,pool_lv: CardLV.LV1,kind:CKind.Card,name:"战术晋升",info: "升级场上随机1个1级英雄到2级",
7001: { uuid: 7001,type: CardType.SpecialUpgrade,cost: 6,weight: 16,pool_lv: CardLV.LV1,kind:CKind.Card,get name(){return t("scard_name_7001")},get info(){return t("scard_info_7001")},
currentLv: 1, targetLv: 2,
},
7002: { uuid: 7002,type: CardType.SpecialUpgrade,cost: 6,weight: 14,pool_lv: CardLV.LV2,kind:CKind.Card,name:"进阶战术",info: "升级场上随机1个2级英雄到3级",
7002: { uuid: 7002,type: CardType.SpecialUpgrade,cost: 6,weight: 14,pool_lv: CardLV.LV2,kind:CKind.Card,get name(){return t("scard_name_7002")},get info(){return t("scard_info_7002")},
currentLv: 2, targetLv: 3,
},
}
export const SpecialRefreshCardList: Record<number, SpecialRefreshCardConfig> = {
7101: { uuid: 7101,type: CardType.SpecialRefresh,cost: 4,weight: 14,pool_lv: CardLV.LV1,kind:CKind.Card,name:"近战征召",info: "刷新卡池,都是近战英雄",
7101: { uuid: 7101,type: CardType.SpecialRefresh,cost: 4,weight: 14,pool_lv: CardLV.LV1,kind:CKind.Card,get name(){return t("scard_name_7101")},get info(){return t("scard_info_7101")},
refreshLv: 0, refreshHeroType: SpecialRefreshHeroType.Melee,
},
7102: { uuid: 7102,type: CardType.SpecialRefresh,cost: 4,weight: 14,pool_lv: CardLV.LV1,kind:CKind.Card,name:"远程征召",info: "刷新卡池,都是远程英雄",
7102: { uuid: 7102,type: CardType.SpecialRefresh,cost: 4,weight: 14,pool_lv: CardLV.LV1,kind:CKind.Card,get name(){return t("scard_name_7102")},get info(){return t("scard_info_7102")},
refreshLv: 0, refreshHeroType: SpecialRefreshHeroType.Ranged,
},
7103: { uuid: 7103,type: CardType.SpecialRefresh,cost: 5,weight: 12,pool_lv: CardLV.LV2,kind:CKind.Card,name:"精英筛选",info: "刷新卡池都是3级卡池等级英雄",
7103: { uuid: 7103,type: CardType.SpecialRefresh,cost: 5,weight: 12,pool_lv: CardLV.LV2,kind:CKind.Card,get name(){return t("scard_name_7103")},get info(){return t("scard_info_7103")},
refreshLv: 3, refreshHeroType: SpecialRefreshHeroType.Any,
},
}