mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-23 20:13:37 +00:00
Updated MarkDisconnectedExecution to remove unnecessary steps
This commit is contained in:
@@ -122,7 +122,7 @@ export class Executor {
|
||||
intent.variables ?? {},
|
||||
);
|
||||
case "mark_disconnected":
|
||||
return new MarkDisconnectedExecution(playerID, intent.isDisconnected);
|
||||
return new MarkDisconnectedExecution(player, intent.isDisconnected);
|
||||
default:
|
||||
throw new Error(`intent type ${intent} not found`);
|
||||
}
|
||||
|
||||
@@ -1,40 +1,21 @@
|
||||
import { Execution, Game, Player, PlayerID } from "../game/Game";
|
||||
import { Execution, Game, Player } from "../game/Game";
|
||||
|
||||
export class MarkDisconnectedExecution implements Execution {
|
||||
private player: Player;
|
||||
private active: boolean = true;
|
||||
|
||||
constructor(
|
||||
private playerID: PlayerID,
|
||||
private player: Player,
|
||||
private isDisconnected: boolean,
|
||||
) {}
|
||||
|
||||
init(mg: Game, ticks: number): void {
|
||||
if (!mg.hasPlayer(this.playerID)) {
|
||||
console.warn(
|
||||
`MarkDisconnectedExecution: player ${this.playerID} not found in game`,
|
||||
);
|
||||
this.active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.player = mg.player(this.playerID);
|
||||
if (!this.player) {
|
||||
console.warn(
|
||||
`MarkDisconnectedExecution: failed to retrieve player ${this.playerID}`,
|
||||
);
|
||||
this.active = false;
|
||||
return;
|
||||
}
|
||||
this.player.markDisconnected(this.isDisconnected);
|
||||
}
|
||||
|
||||
tick(ticks: number): void {
|
||||
this.player.markDisconnected(this.isDisconnected);
|
||||
this.active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
return false;
|
||||
}
|
||||
|
||||
activeDuringSpawnPhase(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user