refactor(英雄属性): 移除魔法攻击相关属性并重构天赋系统
- 移除英雄和怪物类中的魔法攻击(MAP)相关属性 - 重命名getRandomOptions为getNormalBuffs以更准确表达功能 - 新增getTalentOptions函数用于从天赋池中随机获取天赋 - 清理无用注释和空行
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Attrs } from "./HeroAttrs";
|
||||
import { ItalConf, talConf } from "./TalSet";
|
||||
|
||||
export interface ITDLevelOption {
|
||||
attr: Attrs;
|
||||
@@ -155,7 +156,7 @@ export const LEVEL_OPTIONS_TABLE: Record<number, ITDLevelOption[]> = {
|
||||
/**
|
||||
* 获取指定等级的随机选项
|
||||
*/
|
||||
export const getRandomOptions = (level: number, count: number = 4): ITDLevelOption[] => {
|
||||
export const getNormalBuffs = (level: number, count: number = 4): ITDLevelOption[] => {
|
||||
const pool = LEVEL_OPTIONS_TABLE[level];
|
||||
if (!pool || pool.length === 0) return [];
|
||||
|
||||
@@ -186,3 +187,29 @@ export const getRandomOptions = (level: number, count: number = 4): ITDLevelOpti
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// 天赋获取等级
|
||||
export const TALENT_LEVELS = [5, 10, 15, 20];
|
||||
|
||||
/**
|
||||
* 获取天赋选项(从天赋池中随机抽取)
|
||||
* @param count 选项数量,默认4个
|
||||
*/
|
||||
export const getTalentOptions = (count: number = 4): ItalConf[] => {
|
||||
// 获取所有天赋列表
|
||||
const allTalents = Object.values(talConf);
|
||||
|
||||
if (allTalents.length === 0) return [];
|
||||
|
||||
const result: ItalConf[] = [];
|
||||
const tempPool = [...allTalents];
|
||||
|
||||
// 随机抽取指定数量
|
||||
while (result.length < count && tempPool.length > 0) {
|
||||
const index = Math.floor(Math.random() * tempPool.length);
|
||||
result.push(tempPool[index]);
|
||||
tempPool.splice(index, 1);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -131,4 +131,3 @@ export const talConf: Record<number, ItalConf> = {
|
||||
};
|
||||
|
||||
// ========== 工具函数 ==========
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ export class Hero extends ecs.Entity {
|
||||
|
||||
// 设置基础属性
|
||||
model.base_ap = hero.ap;
|
||||
model.base_map = hero.mp;
|
||||
model.base_def = hero.def;
|
||||
model.base_hp = hero.hp;
|
||||
model.base_mp = hero.mp;
|
||||
@@ -87,13 +86,12 @@ export class Hero extends ecs.Entity {
|
||||
model.base_speed = hero.speed;
|
||||
|
||||
// 初始化属性数组
|
||||
model.Attrs = getAttrs();
|
||||
model.NeAttrs = getNeAttrs();
|
||||
model.Attrs = getAttrs(); // 属性
|
||||
model.NeAttrs = getNeAttrs(); //负面属性
|
||||
model.hp = model.Attrs[Attrs.HP_MAX] = model.base_hp;
|
||||
model.mp = model.Attrs[Attrs.MP_MAX] = model.base_mp;
|
||||
model.Attrs[Attrs.DEF] = model.base_def;
|
||||
model.Attrs[Attrs.AP] = model.base_ap;
|
||||
model.Attrs[Attrs.MAP] = model.base_map;
|
||||
model.Attrs[Attrs.SPEED] = hero.speed;
|
||||
model.Attrs[Attrs.DIS] = hero.dis;
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
|
||||
// ==================== 基础属性(有初始值) ====================
|
||||
base_ap: number = 0; // 基础攻击
|
||||
base_map: number = 0; // 基础魔法攻击
|
||||
base_def: number = 5; // 基础防御
|
||||
base_hp: number = 100; // 基础血量
|
||||
base_mp: number = 100; // 基础魔法值
|
||||
@@ -91,7 +90,6 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.Attrs[Attrs.MP_MAX] = this.base_mp;
|
||||
this.Attrs[Attrs.DEF] = this.base_def;
|
||||
this.Attrs[Attrs.AP] = this.base_ap;
|
||||
this.Attrs[Attrs.MAP] = this.base_map;
|
||||
this.Attrs[Attrs.SPEED] = this.base_speed;
|
||||
this.Attrs[Attrs.DIS] = this.base_dis;
|
||||
|
||||
@@ -103,7 +101,6 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
attrIndex !== Attrs.MP_MAX &&
|
||||
attrIndex !== Attrs.DEF &&
|
||||
attrIndex !== Attrs.AP &&
|
||||
attrIndex !== Attrs.MAP &&
|
||||
attrIndex !== Attrs.SPEED &&
|
||||
attrIndex !== Attrs.DIS
|
||||
) {
|
||||
@@ -189,7 +186,6 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
case Attrs.MP_MAX: return this.base_mp;
|
||||
case Attrs.DEF: return this.base_def;
|
||||
case Attrs.AP: return this.base_ap;
|
||||
case Attrs.MAP: return this.base_map;
|
||||
case Attrs.SPEED: return this.base_speed;
|
||||
case Attrs.DIS: return this.base_dis;
|
||||
case Attrs.SHIELD_MAX: return 0;
|
||||
@@ -533,7 +529,6 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.type = 0;
|
||||
this.fac = 0;
|
||||
this.base_ap = 0;
|
||||
this.base_map = 0;
|
||||
this.base_def = 5;
|
||||
this.base_hp = 100;
|
||||
this.base_mp = 100;
|
||||
|
||||
@@ -77,9 +77,7 @@ export class Monster extends ecs.Entity {
|
||||
model.hp = model.Attrs[Attrs.HP_MAX] = hp;
|
||||
model.mp = model.Attrs[Attrs.MP_MAX] = mp;
|
||||
model.Attrs[Attrs.DEF] = def;
|
||||
model.Attrs[Attrs.MDEF] = mdef;
|
||||
model.Attrs[Attrs.AP] = ap;
|
||||
model.Attrs[Attrs.MAP] = map;
|
||||
model.Attrs[Attrs.SPEED] = hero.speed;
|
||||
model.Attrs[Attrs.DIS] = hero.dis;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user