From 52dcce30133964a3199a4caefe47446cb9a29116 Mon Sep 17 00:00:00 2001 From: Florian Schmid Date: Wed, 26 Apr 2023 23:44:35 +0200 Subject: [PATCH] add more stuff --- src/newMode.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/newMode.ts b/src/newMode.ts index 91e2b45..23c0025 100644 --- a/src/newMode.ts +++ b/src/newMode.ts @@ -36,19 +36,32 @@ class UI { ) } - buttonClick(btn: HTMLElement) { + async buttonClick(btn: HTMLElement) { btn.setAttribute("disabled", ""); let result = this.model.processClick(btn.innerText); btn.style.backgroundColor = result ? "lightgreen" : "#FF4444"; this.updateScores(); + + await this.delay(1500); + + if (result) { + this.nextRound(); + } + } + private async delay(time) { + return new Promise(resolve => setTimeout(resolve, time)); } nextRound() { this.buttons.forEach( - (btn) => {btn.removeAttribute("disabled"); + (btn) => { + btn.removeAttribute("disabled"); + btn.style.backgroundColor = "#5bc0de"; } ) + this.model.nextRound(); + this.cpuName.innerText = this.model.currentCpu.name;