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.
57 lines
1.5 KiB
57 lines
1.5 KiB
import type {
|
|
AbilityDef,
|
|
BuffDef,
|
|
LevelDef,
|
|
UnitDef,
|
|
WaveDef,
|
|
} from './BattleConfigTypes';
|
|
import type { IConfigProvider } from './IConfigProvider';
|
|
|
|
/** 内存配置(测试 / 竖切片 / 单元测试) */
|
|
export class InMemoryConfigProvider implements IConfigProvider {
|
|
/** 单位配置表 */
|
|
units = new Map<string, UnitDef>();
|
|
/** 技能配置表 */
|
|
abilities = new Map<string, AbilityDef>();
|
|
/** Buff 配置表 */
|
|
buffs = new Map<string, BuffDef>();
|
|
/** 关卡配置表 */
|
|
levels = new Map<string, LevelDef>();
|
|
|
|
/** @inheritdoc */
|
|
getUnit(id: string): UnitDef | undefined {
|
|
return this.units.get(id);
|
|
}
|
|
|
|
/** @inheritdoc */
|
|
getAbility(id: string): AbilityDef | undefined {
|
|
return this.abilities.get(id);
|
|
}
|
|
|
|
/** @inheritdoc */
|
|
getBuff(id: string): BuffDef | undefined {
|
|
return this.buffs.get(id);
|
|
}
|
|
|
|
/** @inheritdoc */
|
|
getLevel(id: string): LevelDef | undefined {
|
|
return this.levels.get(id);
|
|
}
|
|
|
|
/** @inheritdoc */
|
|
getWave(levelId: string, waveIndex: number): WaveDef | undefined {
|
|
const level = this.levels.get(levelId);
|
|
if (!level || waveIndex < 0 || waveIndex >= level.waves.length) return undefined;
|
|
return level.waves[waveIndex];
|
|
}
|
|
|
|
/** @inheritdoc */
|
|
registerBuff(id: string, def: BuffDef): void {
|
|
this.buffs.set(id, def);
|
|
}
|
|
|
|
/** @inheritdoc */
|
|
registerAbility(id: string, def: AbilityDef): void {
|
|
this.abilities.set(id, def);
|
|
}
|
|
}
|
|
|