Files
SpaceRace/server/src/game/Ship.ts
T

46 lines
1.1 KiB
TypeScript

import { Ship as ShipType, Position, Direction, posEqual } from '@spacerace/shared';
export class Ship {
id: string;
playerId: string;
playerName: string;
position: Position;
direction: Direction;
alive: boolean;
shielded: boolean;
phaseShifting: boolean;
empActive: boolean;
boostSteps: number;
constructor(id: string, playerId: string, playerName: string, position: Position, direction: Direction) {
this.id = id;
this.playerId = playerId;
this.playerName = playerName;
this.position = { ...position };
this.direction = direction;
this.alive = true;
this.shielded = false;
this.phaseShifting = false;
this.empActive = false;
this.boostSteps = 0;
}
resetRoundEffects(): void {
this.shielded = false;
this.phaseShifting = false;
this.empActive = false;
this.boostSteps = 0;
}
toState(): ShipType {
return {
id: this.id,
playerId: this.playerId,
playerName: this.playerName,
position: { ...this.position },
direction: this.direction,
alive: this.alive,
};
}
}