Skip to content

Commit

Permalink
Better disagreement timer
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantumplation committed Dec 10, 2024
1 parent 3059ebe commit d9477fd
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/utils/HydraMultiplayer/dedicated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class HydraMultiplayerDedicated extends HydraMultiplayer {
console.log("Kills: ", this.clients);

let keys = Object.keys(this.clients);
let allAgree = true;
for(let i = 0; i < keys.length; i++) {
for(let j = i + 1; j < keys.length; j++) {
const clientA = this.clients[keys[i]];
Expand All @@ -69,18 +70,21 @@ export class HydraMultiplayerDedicated extends HydraMultiplayer {
console.log(`Client A: ${clientA.kills}`);
console.log(`Client B: ${clientB.kills}`);
if(clientA.kills.toString() != clientB.kills.toString()) {
this.disagreeementTimer += 1;
console.log(`Players disagree on kills! They have ${10 - this.disagreeementTimer} to resolve this`);
if (this.disagreeementTimer > 10) {
console.log(`Players disagree on kills for too long; cancelling game!`);
this.onDisagreement?.();
}
} else {
this.disagreeementTimer = 0;
allAgree = false;
}
}
}
}
if (!allAgree) {
this.disagreeementTimer++;
console.log(`Players disagree on kills! They have ${10 - this.disagreeementTimer} to resolve this`);
if (this.disagreeementTimer > 10) {
console.log(`Players disagree on kills for too long; cancelling game!`);
this.onDisagreement?.();
}
} else {
this.disagreeementTimer = 0;
}
}

protected override buildTx(datum: string): [UTxO, string] {
Expand Down

0 comments on commit d9477fd

Please sign in to comment.