[Cleanup] Pass Player into execution constructor instead of PlayerID (#1022)

## Description:
Answering issue:  #1017 
[Cleanup] Pass Player into the execution constructor instead of PlayerID

I have tested the changes running and playing a full game. I do not know
other way to test the changes, please inform me ❤️

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

Lele

---------

Co-authored-by: lva <lva@rovsing.dk>
This commit is contained in:
Léo Joly
2025-06-06 11:58:15 -07:00
committed by GitHub
co-authored by lva
parent b09abc8bf6
commit 9c7e0ce32f
32 changed files with 120 additions and 361 deletions
@@ -3,11 +3,10 @@ import { Execution, Game, Player, PlayerID } from "../../game/Game";
export class AllianceRequestReplyExecution implements Execution {
private active = true;
private requestor: Player | null = null;
private recipient: Player | null = null;
constructor(
private requestorID: PlayerID,
private recipientID: PlayerID,
private recipient: Player,
private accept: boolean,
) {}
@@ -19,19 +18,11 @@ export class AllianceRequestReplyExecution implements Execution {
this.active = false;
return;
}
if (!mg.hasPlayer(this.recipientID)) {
console.warn(
`AllianceRequestReplyExecution recipient ${this.recipientID} not found`,
);
this.active = false;
return;
}
this.requestor = mg.player(this.requestorID);
this.recipient = mg.player(this.recipientID);
}
tick(ticks: number): void {
if (this.requestor === null || this.recipient === null) {
if (this.requestor === null) {
throw new Error("Not initialized");
}
if (this.requestor.isFriendly(this.recipient)) {