refactor: 重构英雄卡池为动态生成方式
更新导入以包含HeroList,移除硬编码的英雄卡池条目,改为动态生成卡牌,适配英雄等级与卡池等级的计算规则,提升代码可维护性。
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import * as exp from "constants"
|
import * as exp from "constants"
|
||||||
import { HeroInfo, HType } from "./heroSet"
|
import { HeroInfo, HeroList, HType } from "./heroSet"
|
||||||
import { FightSet } from "./GameSet"
|
import { FightSet } from "./GameSet"
|
||||||
import { oops } from "db://oops-framework/core/Oops"
|
import { oops } from "db://oops-framework/core/Oops"
|
||||||
|
|
||||||
@@ -81,51 +81,48 @@ export const CARD_POOL_MAX_LEVEL = CardLV.LV3
|
|||||||
export const CARD_HERO_MAX_LEVEL = 1
|
export const CARD_HERO_MAX_LEVEL = 1
|
||||||
/** 基础卡池(英雄、技能、功能) */
|
/** 基础卡池(英雄、技能、功能) */
|
||||||
|
|
||||||
export const CardPoolList: CardConfig[] = [
|
export const CardPoolList: CardConfig[] = [];
|
||||||
{ uuid: 5001, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
|
||||||
{ uuid: 5006, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
|
||||||
{ uuid: 5007, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
|
||||||
{ uuid: 5101, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
|
||||||
{ uuid: 5106, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
|
||||||
{ uuid: 5301, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
|
||||||
{ uuid: 5303, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
|
||||||
|
|
||||||
{ uuid: 5107, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 2, kind: CKind.Hero, hero_lv: 1 },
|
// 动态生成英雄卡池
|
||||||
{ uuid: 5205, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 2, kind: CKind.Hero, hero_lv: 1 },
|
HeroList.forEach(uuid => {
|
||||||
{ uuid: 5302, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 2, kind: CKind.Hero, hero_lv: 1 },
|
const hero = HeroInfo[uuid];
|
||||||
{ uuid: 5304, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 2, kind: CKind.Hero, hero_lv: 1 },
|
if (!hero) return;
|
||||||
|
|
||||||
{ uuid: 5002, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 3, kind: CKind.Hero, hero_lv: 1 },
|
const basePoolLv = hero.pool_lv || 1;
|
||||||
{ uuid: 5008, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 3, kind: CKind.Hero, hero_lv: 1 },
|
const baseHeroLv = hero.lv || 1;
|
||||||
{ uuid: 5009, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 3, kind: CKind.Hero, hero_lv: 1 },
|
const baseCost = 10;
|
||||||
{ uuid: 5108, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 3, kind: CKind.Hero, hero_lv: 1 },
|
const baseWeight = 25;
|
||||||
{ uuid: 5305, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 3, kind: CKind.Hero, hero_lv: 1 },
|
|
||||||
{ uuid: 5403, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 3, kind: CKind.Hero, hero_lv: 1 },
|
|
||||||
|
|
||||||
|
// 生成从 basePoolLv 到 CARD_POOL_MAX_LEVEL 的卡牌
|
||||||
|
for (let pLv = basePoolLv; pLv <= CARD_POOL_MAX_LEVEL; pLv++) {
|
||||||
|
const offset = pLv - basePoolLv;
|
||||||
|
const targetHeroLv = baseHeroLv + offset;
|
||||||
|
|
||||||
{ uuid: 5001, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
// 英雄的最高等级 是MERGE_MAX-1
|
||||||
{ uuid: 5002, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
if (targetHeroLv > FightSet.MERGE_MAX - 1) {
|
||||||
{ uuid: 5003, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
break;
|
||||||
{ uuid: 5004, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
}
|
||||||
{ uuid: 5005, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
|
||||||
|
|
||||||
{ uuid: 5101, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
// cost = 原始的cost*MERGE_NEED*hero_lv
|
||||||
{ uuid: 5102, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
let cost = baseCost;
|
||||||
{ uuid: 5103, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
if (targetHeroLv > 1) {
|
||||||
{ uuid: 5104, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
cost = baseCost * FightSet.MERGE_NEED * targetHeroLv;
|
||||||
{ uuid: 5105, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
}
|
||||||
|
|
||||||
{ uuid: 5201, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
CardPoolList.push({
|
||||||
{ uuid: 5202, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
uuid: hero.uuid,
|
||||||
{ uuid: 5203, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
type: CardType.Hero,
|
||||||
{ uuid: 5204, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
cost: cost,
|
||||||
|
weight: baseWeight,
|
||||||
{ uuid: 5301, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
pool_lv: pLv as CardLV,
|
||||||
{ uuid: 5302, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
kind: CKind.Hero,
|
||||||
|
hero_lv: targetHeroLv
|
||||||
{ uuid: 5401, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
});
|
||||||
{ uuid: 5402, type: CardType.Hero, cost: 10, weight: 25, pool_lv: 1, kind: CKind.Hero, hero_lv: 1 },
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 添加非英雄卡牌 (技能、功能卡)
|
||||||
|
CardPoolList.push(
|
||||||
// 技能卡牌 (以增益/辅助为主,因为在备战期没有敌人)
|
// 技能卡牌 (以增益/辅助为主,因为在备战期没有敌人)
|
||||||
{ uuid: 6401, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 1, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6401"), info: t("skill_info_6401"), 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, name: t("skill_name_6401"), info: 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, name: t("skill_name_6402"), info: t("skill_info_6402"), 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: t("skill_name_6402"), info: t("skill_info_6402"), is_inst: true, t_times: 1, t_inv: 0 },
|
||||||
@@ -135,11 +132,7 @@ export const CardPoolList: CardConfig[] = [
|
|||||||
{ uuid: 6406, type: CardType.Skill, cost: 10, weight: 20, pool_lv: 2, kind: CKind.Skill, card_lv: 1, name: t("skill_name_6406"), info: t("skill_info_6406"), 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: t("skill_name_6406"), info: 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, name: t("skill_name_6304"), info: t("skill_info_6304"), 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: t("skill_name_6304"), info: 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, name: t("skill_name_6305"), info: t("skill_info_6305"), 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: t("skill_name_6305"), info: 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 },
|
|
||||||
// { uuid: 7103, type: CardType.SpecialRefresh, cost: 1, weight: 12, pool_lv: 1 ,kind: CKind.Card },
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
export enum SpecialRefreshHeroType {
|
export enum SpecialRefreshHeroType {
|
||||||
|
|||||||
Reference in New Issue
Block a user