You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.5 KiB
112 lines
3.5 KiB
|
3 weeks ago
|
import { calcMonsterHpBaseByBattleTime } from '../battle/config/MonsterHpCalculator';
|
||
|
|
import { TableNames } from '../game/ConfigTableData';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Monster.type(与 AutoTable / Monster.json 对齐)
|
||
|
|
* 1 小怪 · 2 BOSS · 3 召唤怪物
|
||
|
|
*/
|
||
|
|
export enum MonsterType {
|
||
|
|
/** 小怪 */
|
||
|
|
SmallMonster = 1,
|
||
|
|
/** BOSS */
|
||
|
|
Boss = 2,
|
||
|
|
/** 召唤怪物 */
|
||
|
|
SummonMonster = 3,
|
||
|
|
/** @deprecated 新表无中期 Boss;数值同 Boss,旧分支兼容 */
|
||
|
|
MidBoss = 2,
|
||
|
|
/** @deprecated 新表无 */
|
||
|
|
SilverBoss = 4,
|
||
|
|
/** @deprecated 新表无 */
|
||
|
|
GoldenBoss = 5,
|
||
|
|
/** @deprecated 新表无 */
|
||
|
|
OrangeBoss = 6,
|
||
|
|
/** @deprecated 新表无 */
|
||
|
|
ZombieFactory = 7,
|
||
|
|
/** @deprecated 新表无 */
|
||
|
|
TreasureBox = 8,
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 怪物表数据管理 */
|
||
|
|
export class MonsterDataManager {
|
||
|
|
/** 获取怪物配表列表 */
|
||
|
|
public static getAllMonsterList1() {
|
||
|
|
return gg.data.table.getTableList<ITableMonster>(TableNames.Monster);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 通过怪物 id 获取配表
|
||
|
|
* @param id 怪物 id
|
||
|
|
*/
|
||
|
|
public static getMonsterDataById(id: number) {
|
||
|
|
const allList = this.getAllMonsterList1();
|
||
|
|
return allList.find((x) => x.id === id);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 战斗 Spine 皮肤名(按出怪阵营)
|
||
|
|
* - type1 小怪 / type3 召唤:己方口=`icon`,敌方口=`icon`+`2`(如 哮天犬 / 哮天犬2)
|
||
|
|
* - type2 Boss:己方口=`皮肤字1_1`,敌方口=`皮肤字2_1`(资源无「皮肤字_」中间下划线)
|
||
|
|
* @param row Monster 行
|
||
|
|
* @param enemyCamp 是否敌方出怪口放出的怪
|
||
|
|
*/
|
||
|
|
public static resolveBattleSpineSkin(row: ITableMonster, enemyCamp: boolean): string {
|
||
|
|
const icon = String(row.icon ?? '').trim();
|
||
|
|
if (row.type === MonsterType.SmallMonster || row.type === MonsterType.SummonMonster) {
|
||
|
|
if (!icon) {
|
||
|
|
console.log('[MonsterDataManager] 怪物 icon 为空,无法定皮肤', row.id, row.type);
|
||
|
|
return '';
|
||
|
|
}
|
||
|
|
return enemyCamp ? `${icon}2` : icon;
|
||
|
|
}
|
||
|
|
if (row.type === MonsterType.Boss) {
|
||
|
|
return enemyCamp ? '皮肤字2_1' : '皮肤字1_1';
|
||
|
|
}
|
||
|
|
if (!icon) {
|
||
|
|
console.log('[MonsterDataManager] 怪物 icon 为空', row.id, row.type);
|
||
|
|
return '';
|
||
|
|
}
|
||
|
|
return icon;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 可被吞噬的小兵:小怪或召唤物,不含 Boss。
|
||
|
|
* @param monsterId Monster.id
|
||
|
|
*/
|
||
|
|
static isDevourMinion(monsterId: number): boolean {
|
||
|
|
const row = this.getMonsterDataById(monsterId);
|
||
|
|
if (!row) return false;
|
||
|
|
return row.type === MonsterType.SmallMonster || row.type === MonsterType.SummonMonster;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 是否为 Boss 类型(含旧表银/金/橙 Boss)。
|
||
|
|
* @param type Monster.type
|
||
|
|
*/
|
||
|
|
static isBossType(type: number): boolean {
|
||
|
|
return type === MonsterType.Boss
|
||
|
|
|| type === MonsterType.SilverBoss
|
||
|
|
|| type === MonsterType.GoldenBoss
|
||
|
|
|| type === MonsterType.OrangeBoss;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 通过难度和时间和战力获取怪物血量
|
||
|
|
* @param diff 难度
|
||
|
|
* @param time 时间
|
||
|
|
* @param power 战力
|
||
|
|
* @param powerPara 战力参数(玩家战力 >= 推荐)
|
||
|
|
* @param powerPara2 战力参数(玩家战力 < 推荐)
|
||
|
|
*/
|
||
|
|
public static getMonsterHpByDiffAndTime(
|
||
|
|
diff: number,
|
||
|
|
time: number,
|
||
|
|
power: number,
|
||
|
|
powerPara: number,
|
||
|
|
powerPara2: number = 0,
|
||
|
|
) {
|
||
|
|
return calcMonsterHpBaseByBattleTime(diff, time, power, powerPara, powerPara2);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|