feat(battle-sim): implement battle simulation logic and metrics tracking
- Added WarBattleMetrics interface to track attacker and defender skills during battles. - Enhanced WarUnit class with method to log activated skills. - Introduced environment setup for battle simulation, including unit set loading and configuration resolution. - Developed in-memory and Redis transport layers for handling battle simulation requests and results. - Created types and interfaces for battle simulation payloads and responses. - Implemented battle simulation processing logic, including logging and skill tracking. - Added tests for battle simulation processor to ensure functionality and correctness.
This commit is contained in:
@@ -237,6 +237,17 @@ export abstract class WarUnit<
|
||||
(this.hasActivatedSkill(skillName) ? 1 : 0);
|
||||
}
|
||||
|
||||
public getActivatedSkillLog(): Record<string, number> {
|
||||
const snapshot: Record<string, number> = { ...this.logActivatedSkill };
|
||||
for (const [skillName, active] of Object.entries(this.activatedSkill)) {
|
||||
if (!active) {
|
||||
continue;
|
||||
}
|
||||
snapshot[skillName] = (snapshot[skillName] ?? 0) + 1;
|
||||
}
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
public activateSkill(...skillNames: string[]): void {
|
||||
for (const skillName of skillNames) {
|
||||
this.activatedSkill[skillName] = true;
|
||||
|
||||
Reference in New Issue
Block a user