diff --git a/play.pokemonshowdown.com/js/client-battle.js b/play.pokemonshowdown.com/js/client-battle.js index 9cec457aa3..a857a4dd61 100644 --- a/play.pokemonshowdown.com/js/client-battle.js +++ b/play.pokemonshowdown.com/js/client-battle.js @@ -486,6 +486,7 @@ }, 1000); } else if (this.battle.kickingInactive > 1) { this.battle.kickingInactive--; + this.battle.currTurnTimeElapsed++; if (this.battle.graceTimeLeft) this.battle.graceTimeLeft--; else if (this.battle.totalTimeLeft) this.battle.totalTimeLeft--; } diff --git a/play.pokemonshowdown.com/src/battle-log.ts b/play.pokemonshowdown.com/src/battle-log.ts index 722f4089ac..93aa30b3f0 100644 --- a/play.pokemonshowdown.com/src/battle-log.ts +++ b/play.pokemonshowdown.com/src/battle-log.ts @@ -210,6 +210,17 @@ export class BattleLog { case 'error': case 'inactive': case 'inactiveoff': divClass = 'chat message-error'; + battle = this.scene?.battle; + + if (battle?.kickingInactive && battle.timerMessageHighlighted) { + divClass += ' highlighted'; + if (this.scene?.battle?.roomid) { + const title = 'Make your move!'; + const body = `${battle?.kickingInactive || 'Only a few'} seconds remaining!`; + const tag = 'highlight'; + app.rooms[this.scene?.battle?.roomid].notifyOnce(title, body, tag); + } + } divHTML = BattleLog.escapeHTML(args[1]); break; diff --git a/play.pokemonshowdown.com/src/battle.ts b/play.pokemonshowdown.com/src/battle.ts index a5595832f1..d86a07b6fe 100644 --- a/play.pokemonshowdown.com/src/battle.ts +++ b/play.pokemonshowdown.com/src/battle.ts @@ -1100,6 +1100,9 @@ export class Battle { endLastTurnPending = false; totalTimeLeft = 0; graceTimeLeft = 0; + currTurnTimeElapsed = 0; + timerMessageHighlighted = false; + /** * true: timer on, state unknown * false: timer off @@ -3369,6 +3372,7 @@ export class Battle { break; } case 'turn': { + this.currTurnTimeElapsed = 0; this.setTurn(parseInt(args[1], 10)); this.log(args); break; @@ -3471,7 +3475,14 @@ export class Battle { let hasIndex = args[1].indexOf(' has '); let userid = window.app?.user?.get('userid'); if (toID(args[1].slice(0, hasIndex)) === userid) { - this.kickingInactive = parseInt(args[1].slice(hasIndex + 5), 10) || true; + const timerValue = parseInt(args[1].slice(hasIndex + 5), 10) || true; + this.kickingInactive = timerValue; + + if (typeof timerValue === "number") { + this.timerMessageHighlighted = this.currTurnTimeElapsed >= 30 && timerValue <= 10; + } + } else { + this.timerMessageHighlighted = false; } } else if (args[1].slice(-27) === ' 15 seconds left this turn.') { if (this.isBlitz) return; @@ -3481,6 +3492,7 @@ export class Battle { } case 'inactiveoff': { this.kickingInactive = false; + this.timerMessageHighlighted = false; this.log(args, undefined, preempt); break; }