Erneutes Spielen sicherer Gemacht

This commit is contained in:
2025-05-06 17:04:54 +02:00
parent 9b56ad321a
commit 6607cd500e
4 changed files with 77 additions and 30 deletions

View File

@@ -118,24 +118,41 @@ class UIManager{
endDiv.appendChild(scoreDiv);
const replayButton = document.createElement("button");
replayButton.id = "replayBtn";
replayButton.innerHTML = `
<div class="buttonIcon">
<svg xmlns="http://www.w3.org/2000/svg" height="40px" viewBox="0 -960 960 960" width="40px" fill="#FFFFFF">
<path d="M447.33-122Q325-133.67 242.5-224.5 160-315.33 160-439.33q0-73.34 32.33-138.84 32.34-65.5
91-109.16L331-639.67q-50 33.34-77.17 86.67-27.16 53.33-27.16 113.67 0 96 62.66 167.16 62.67 71.17
158 83.5V-122Zm66.67 0v-66.67q95.67-13.33 157.83-84Q734-343.33 734-439.33q0-106-73.67-179.67-73.66-73.67-179.66-73.67h-14.3
4L521-638l-47.33 47.33L338.33-726l135.34-135.33L521-814l-54.67 54.67h14.34q134 0 227 93.33t93 226.67q0 123.66-82.17 214.5
Q636.33-134 514-122Z"/>
</svg>
</div>
<div class="buttonText">
Neue Runde
</div>
`;
replayButton.addEventListener("click", () => { window.location.href = "/game" })
endDiv.appendChild(replayButton);
if(data.replay.possible){
this.replayContainer = document.createElement("div");
this.replayContainer.id = "replayContainer"; // ID für den Container
endDiv.appendChild(this.replayContainer);
this.replayButton = document.createElement("button");
this.replayButton.id = "replayBtn";
this.replayButton.innerHTML = `
<div class="buttonIcon">
<svg xmlns="http://www.w3.org/2000/svg" height="40px" viewBox="0 -960 960 960" width="40px" fill="#FFFFFF">
<path d="M447.33-122Q325-133.67 242.5-224.5 160-315.33 160-439.33q0-73.34 32.33-138.84 32.34-65.5
91-109.16L331-639.67q-50 33.34-77.17 86.67-27.16 53.33-27.16 113.67 0 96 62.66 167.16 62.67 71.17
158 83.5V-122Zm66.67 0v-66.67q95.67-13.33 157.83-84Q734-343.33 734-439.33q0-106-73.67-179.67-73.66-73.67-179.66-73.67h-14.3
4L521-638l-47.33 47.33L338.33-726l135.34-135.33L521-814l-54.67 54.67h14.34q134 0 227 93.33t93 226.67q0 123.66-82.17 214.5
Q636.33-134 514-122Z"/>
</svg>
</div>
<div class="buttonText">
Neue Runde
</div>
`;
this.replayButton.addEventListener("click", () => { window.location.href = "/game"; });
this.replayContainer.appendChild(this.replayButton);
this.timeText = document.createElement("p");
this.timeText.id = "timeText";
this.timeText.innerText = `Möglichkeit für nächste: ${data.replay.time / 1000} Sekunden`;
this.replayContainer.appendChild(this.timeText);
this.time = data.replay.time;
setTimeout(() => {
this.timerTimeOut();
}, 1000);
}
const dashButton = document.createElement("button");
dashButton.id = "leaveBtn";
@@ -155,6 +172,20 @@ class UIManager{
dashButton.addEventListener("click", () => { window.location.href = "/dashboard" })
endDiv.appendChild(dashButton);
}
timerTimeOut(){
this.time -= 1000;
const newTime = this.time / 1000;
this.timeText.innerText = `Möglichkeit für nächste: ${newTime} Sekunden`
if(newTime <= 0){
this.replayContainer.style.display = "none";
}else{
setTimeout(() => {
this.timerTimeOut();
}, 1000);
}
}
}
export default UIManager;