From daeef6c6473cc6285f75f45f56e074c6acd0525e Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 27 Jun 2021 18:55:06 +0200 Subject: crusader: Flash 'click next' when out of options in battles. --- ui.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'ui.js') diff --git a/ui.js b/ui.js index 3ced0b1..b778e85 100644 --- a/ui.js +++ b/ui.js @@ -808,6 +808,24 @@ function update_battle() { } } +let flash_timer = 0; +function start_flash() { + let element = document.querySelector(".battle_message"); + let tick = true; + if (flash_timer) + return; + flash_timer = setInterval(function () { + if (!game.flash_next) { + element.textContent = game.battle.flash; + clearInterval(flash_timer); + flash_timer = 0; + } else { + element.textContent = tick ? game.battle.flash : game.flash_next; + tick = !tick; + } + }, 1000); +} + function on_update() { show_action_button("#next_button", "next"); show_action_button("#pass_button", "pass"); @@ -833,6 +851,8 @@ function on_update() { if (game.battle) { document.querySelector(".battle_header").textContent = game.battle.title; document.querySelector(".battle_message").textContent = game.battle.flash; + if (game.flash_next) + start_flash(); document.querySelector(".battle").classList.add("show"); update_battle(); } else { -- cgit v1.2.3