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 {
offender.strength.transparentUpdate(-1n);
}
}
// Handle region capture.
if (defender.strength === 0) {
defender.strength = offenderRolls.length + 1;
offender.strength -= offenderRolls.length + 1;
defender.owner = this;
break;
// Handle aftermath.
if (defender.owner === game.us) {
if (defender.strength.cipherText.plainText === 0n) {
// Handle region loss
} else {
// 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.
defender.owner.defenderPromise = null;
defender.owner.defenderAmount = null;

View File

@ -404,6 +404,8 @@ export function proveFortify(fortify) {
}
}
// TODO range proof for regions
return {
fortify: fortify,
proofs: proofs,
@ -413,6 +415,4 @@ export function proveFortify(fortify) {
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)})