From dd8536833a81c0c33c3a91880630a6d547743d43 Mon Sep 17 00:00:00 2001 From: panw Date: Fri, 26 Dec 2025 11:01:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E8=8B=B1=E9=9B=84=E5=B1=9E=E6=80=A7):?= =?UTF-8?q?=20=E7=A7=BB=E9=99=A4=E9=AD=94=E6=B3=95=E6=94=BB=E5=87=BB?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=B1=9E=E6=80=A7=E5=B9=B6=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=A4=A9=E8=B5=8B=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除英雄和怪物类中的魔法攻击(MAP)相关属性 - 重命名getRandomOptions为getNormalBuffs以更准确表达功能 - 新增getTalentOptions函数用于从天赋池中随机获取天赋 - 清理无用注释和空行 --- .../game/common/config/TDLevelOptions.ts | 29 ++++++++++++++++++- assets/script/game/common/config/TalSet.ts | 1 - assets/script/game/hero/Hero.ts | 6 ++-- assets/script/game/hero/HeroAttrsComp.ts | 5 ---- assets/script/game/hero/Mon.ts | 2 -- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/assets/script/game/common/config/TDLevelOptions.ts b/assets/script/game/common/config/TDLevelOptions.ts index e10cf3ce..245f760a 100644 --- a/assets/script/game/common/config/TDLevelOptions.ts +++ b/assets/script/game/common/config/TDLevelOptions.ts @@ -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 = { /** * 获取指定等级的随机选项 */ -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; +}; diff --git a/assets/script/game/common/config/TalSet.ts b/assets/script/game/common/config/TalSet.ts index 1b2934e5..0e9985a5 100644 --- a/assets/script/game/common/config/TalSet.ts +++ b/assets/script/game/common/config/TalSet.ts @@ -131,4 +131,3 @@ export const talConf: Record = { }; // ========== 工具函数 ========== - diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index 3bf5c465..f4f64659 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -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; diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index 57b5fa82..71833d8b 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -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; diff --git a/assets/script/game/hero/Mon.ts b/assets/script/game/hero/Mon.ts index 49573a77..c35d3898 100644 --- a/assets/script/game/hero/Mon.ts +++ b/assets/script/game/hero/Mon.ts @@ -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;