From bffb4156fdb5137d2969f04a973a71e471cd7746 Mon Sep 17 00:00:00 2001 From: xangelo Date: Thu, 24 Aug 2023 13:53:27 -0400 Subject: [PATCH] fix: add block timer for casting and clear after fight --- src/server/api.ts | 4 ++++ src/server/views/fight.ts | 22 ++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/server/api.ts b/src/server/api.ts index 359c07e..d9f67ab 100644 --- a/src/server/api.ts +++ b/src/server/api.ts @@ -863,6 +863,10 @@ app.post('/fight/turn', authEndpoint, async (req: AuthRequest, res: Response) => cache[fightBlockKey] ); + if(fightData.roundData.winner !== 'in-progress') { + delete cache[fightBlockKey]; + } + if(fightData.monsters.length && monster.fight_trigger === 'explore') { html += renderMonsterSelector(fightData.monsters, monster.ref_id); } diff --git a/src/server/views/fight.ts b/src/server/views/fight.ts index 02f595b..06ebcdb 100644 --- a/src/server/views/fight.ts +++ b/src/server/views/fight.ts @@ -34,6 +34,24 @@ export function renderRoundDetails(roundData: FightRound): string { return html.join("\n"); } +function CastButton(blockTime?: number): string { + const attrs = { + id: 'cast-button', + type: 'submit', + class: ['fight-action', 'red'], + name: 'action', + value: 'cast' + }; + + if(blockTime) { + return ButtonWithBlock(attrs, 'Cast', blockTime); + } + else { + return Button(attrs, 'Cast'); + } + +} + function AttackButton(blockTime?: number): string { const attrs = { id: 'attack-button', @@ -75,7 +93,7 @@ export function renderFight(monster: MonsterForFight, results: string = '', disp ${AttackButton(blockTime)} - + ${CastButton(blockTime)} `: ''} @@ -118,7 +136,7 @@ export function renderFightPreRound(monster: MonsterForFight, displayFightActio ${AttackButton()} - + ${CastButton()} `: ''} -- 2.25.1