|
|
@@ -8,6 +8,7 @@ window.addEventListener("DOMContentLoaded", () => {
|
|
|
class Puzzeltocht {
|
|
|
|
|
|
constructor() {
|
|
|
+ this.errorCount = 0;
|
|
|
this.joinScreen = new JoinScreen();
|
|
|
this.joinScreen.setJoinListener((e, t) => this.start(e, t));
|
|
|
this.missionScreen = new MissionScreen();
|
|
|
@@ -27,7 +28,10 @@ class Puzzeltocht {
|
|
|
answer(a) {
|
|
|
this.lastUpdate = Date.now();
|
|
|
Api.sendUpdate(this.eventId, this.teamId, this.position, a)
|
|
|
- .then(m => this.missionScreen.update(m))
|
|
|
+ .then(m => {
|
|
|
+ this.missionScreen.update(m);
|
|
|
+ this.errorCount = 0;
|
|
|
+ })
|
|
|
.catch(e => this.onError(e));
|
|
|
}
|
|
|
|
|
|
@@ -43,16 +47,22 @@ class Puzzeltocht {
|
|
|
|
|
|
if (this.lastUpdate === undefined || Date.now() - this.lastUpdate > 5000) {
|
|
|
Api.sendUpdate(this.eventId, this.teamId, position)
|
|
|
- .then(m => this.missionScreen.update(m))
|
|
|
+ .then(m => {
|
|
|
+ this.missionScreen.update(m);
|
|
|
+ this.lastUpdate = Date.now();
|
|
|
+ this.errorCount = 0;
|
|
|
+ })
|
|
|
.catch(e => this.onError(e));
|
|
|
- this.lastUpdate = Date.now();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
onError(e) {
|
|
|
- this.location.disable();
|
|
|
- let l = document.getElementById("location");
|
|
|
- l.innerText = "Error!";
|
|
|
+ this.errorCount++;
|
|
|
+ if (this.errorCount > 10) {
|
|
|
+ this.location.disable();
|
|
|
+ let l = document.getElementById("location");
|
|
|
+ l.innerText = "Error!";
|
|
|
+ }
|
|
|
console.log(e);
|
|
|
}
|
|
|
|