feat(combat): start real combats from the hunt page and navigate to /combat/:combatId

This commit is contained in:
Bastian Wagner
2026-08-19 17:03:35 +02:00
parent 1fd62cddde
commit aa8c374db0
3 changed files with 95 additions and 28 deletions

View File

@@ -1,8 +1,9 @@
import { Component, OnInit, inject } from '@angular/core';
import { Router } from '@angular/router';
import { CombatStore } from '../../combat/combat.store';
import { WorldStore } from '../../world/world.store';
import { EncounterCardComponent } from '../encounter-card/encounter-card.component';
import { HuntingStore } from '../hunting.store';
import { WorldStore } from '../../world/world.store';
@Component({
selector: 'app-hunt-page',
@@ -13,6 +14,7 @@ import { WorldStore } from '../../world/world.store';
export class HuntPageComponent implements OnInit {
protected readonly worldStore = inject(WorldStore);
protected readonly huntingStore = inject(HuntingStore);
protected readonly combatStore = inject(CombatStore);
private readonly router = inject(Router);
ngOnInit(): void {
@@ -41,8 +43,15 @@ export class HuntPageComponent implements OnInit {
void this.router.navigate(['/world']);
}
protected onAttack(encounterId: string): void {
this.huntingStore.selectEncounter(encounterId);
void this.router.navigate(['/combat/new'], { queryParams: { encounterId } });
protected async onAttack(encounterId: string): Promise<void> {
await this.combatStore.startCombat(encounterId);
const combat = this.combatStore.combat();
if (combat) {
void this.router.navigate(['/combat', combat.id]);
}
}
protected dismissCombatError(): void {
this.combatStore.clearError();
}
}