Fleshed out stub. Added fortify and stub for attack.

This commit is contained in:
jude 2023-02-13 15:52:17 +00:00
parent d99b5b3373
commit 9ffd43e944
3 changed files with 50 additions and 1 deletions

View File

@ -91,6 +91,55 @@ class Player {
this.turnPhase = PHASE_ATTACK;
}
return false;
} else {
// End turn prematurely.
if (data.action === "END") {
return true;
}
if (this.turnPhase === PHASE_ATTACK && data.action === "ATTACK") {
if (this.attack(data)) {
this.turnPhase = PHASE_FORTIFY;
}
return false;
}
this.turnPhase = PHASE_FORTIFY;
if (data.action === "FORTIFY") {
return this.fortify(data);
}
}
return false;
}
/**
* Process an action which is to attack another region.
*
* @param data Data received via socket
*/
attack(data) {}
/**
* Process an action which is to attack another region.
*
* @param data Data received via socket
*/
fortify(data) {
let sender = Region.getRegion(data.sender);
let receiver = Region.getRegion(data.receiver);
if (
sender.owner === this &&
receiver.owner === this &&
sender.strength > data.strength
) {
receiver.reinforce(data.strength);
sender.strength -= data.strength;
return true;
} else {
return false;
}
}

Binary file not shown.

View File

@ -297,7 +297,7 @@ As the prime generation routine generates primes of equal length, this property
We see that $(1 + n)^n \equiv 1 \mod n^2$ from binomial expansion. So $1 + n$ is invertible as required.
\end{proof}
The selection of such $g$ is ideal, as the binomial expansion property helps to optimise exponentiation. Clearly, from the same result, $g^m = 1 + mn$. This operation is far easier to perform, as it can be performed without having to take the modulus to keep the computed value within range (for $m$ of sufficiently small size).
The selection of such $g$ is ideal, as the binomial expansion property helps to optimise exponentiation. Clearly, from the same result, $g^m = 1 + mn$. This operation is far easier to perform, as it can be performed without having to take the modulus to keep the computed value within range.
\subsection{Encryption}