feat(combat): rejoin the running combat instead of dead-ending
Attacking while a combat is already active returned COMBAT_ALREADY_ACTIVE and left the hunt page showing an error the player could not act on, with no way back into the fight they were already in. Add GET /api/combats/active so the client can resolve that combat, and have the hunt page navigate into it when an attack is rejected for this reason. CombatStore now also exposes the error code so callers can tell this case apart from a genuinely failed attack.
This commit is contained in:
@@ -48,6 +48,16 @@ export class HuntPageComponent implements OnInit {
|
||||
const combat = this.combatStore.combat();
|
||||
if (combat) {
|
||||
void this.router.navigate(['/combat', combat.id]);
|
||||
return;
|
||||
}
|
||||
|
||||
// A fight already running is not a dead end: rejoin it rather than
|
||||
// leaving the player stuck behind an error they cannot act on.
|
||||
if (this.combatStore.errorCode() === 'COMBAT_ALREADY_ACTIVE') {
|
||||
const active = await this.combatStore.loadActiveCombat();
|
||||
if (active) {
|
||||
void this.router.navigate(['/combat', active.id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user