This commit is contained in:
jude 2023-04-21 21:47:02 +01:00
parent 8eb68d3fe0
commit 07269df66d
2 changed files with 22 additions and 8 deletions

View File

@ -298,16 +298,30 @@ export class Player {
} else { } else {
offender.strength.transparentUpdate(-1n); offender.strength.transparentUpdate(-1n);
} }
}
// Handle region capture. // Handle aftermath.
if (defender.strength === 0) { if (defender.owner === game.us) {
defender.strength = offenderRolls.length + 1; if (defender.strength.cipherText.plainText === 0n) {
offender.strength -= offenderRolls.length + 1; // Handle region loss
defender.owner = this; } else {
break; // Prove we still control the region
} }
} }
if (this === game.us) {
if (defender.strength.assumedStrength === 0n) {
// Handle region gain
defender.owner = this;
defender.strength = new Strength(
new Ciphertext(this.paillierPubKey, offenderRolls.length + 1),
defender.name
);
}
}
await defender.resolveConflict();
// Reset the promises in case they attack again. // Reset the promises in case they attack again.
defender.owner.defenderPromise = null; defender.owner.defenderPromise = null;
defender.owner.defenderAmount = null; defender.owner.defenderAmount = null;

View File

@ -404,6 +404,8 @@ export function proveFortify(fortify) {
} }
} }
// TODO range proof for regions
return { return {
fortify: fortify, fortify: fortify,
proofs: proofs, proofs: proofs,
@ -413,6 +415,4 @@ export function proveFortify(fortify) {
window.proveFortify = proveFortify; window.proveFortify = proveFortify;
function verifyFortify(obj, key) {}
// proveRegions({A:paillier.pubKey.encrypt(0n),B:paillier.pubKey.encrypt(3n),C:paillier.pubKey.encrypt(-3n),D:paillier.pubKey.encrypt(0n),E:paillier.pubKey.encrypt(0n)}) // proveRegions({A:paillier.pubKey.encrypt(0n),B:paillier.pubKey.encrypt(3n),C:paillier.pubKey.encrypt(-3n),D:paillier.pubKey.encrypt(0n),E:paillier.pubKey.encrypt(0n)})