From: xangelo Date: Thu, 24 Aug 2023 17:53:27 +0000 (-0400) Subject: fix: add block timer for casting and clear after fight X-Git-Tag: v0.2.15~4 X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=bffb4156fdb5137d2969f04a973a71e471cd7746;p=risinglegends.git fix: add block timer for casting and clear after fight --- 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()} `: ''}