feat(combat): start real combats from the hunt page and navigate to /combat/:combatId
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user