combine Game & MutableGame

This commit is contained in:
evanpelle
2025-02-01 12:05:11 -08:00
committed by Evan
parent 7d15c0c065
commit de1dbff570
30 changed files with 101 additions and 101 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
import {MutableAlliance, MutableGame, Player, Tick} from "./Game";
import {MutableAlliance, Game, Player, Tick} from "./Game";
import {GameImpl} from "./GameImpl";
import {PlayerImpl} from "./PlayerImpl";
+27 -25
View File
@@ -128,7 +128,7 @@ export interface ExecutionView {
}
export interface Execution extends ExecutionView {
init(mg: MutableGame, ticks: number): void
init(mg: Game, ticks: number): void
tick(ticks: number): void
owner(): Player
}
@@ -290,43 +290,45 @@ export interface Player {
}
export interface Game extends GameMap {
// Throws exception is player not found
player(id: PlayerID): Player
playerByClientID(id: ClientID): Player | null
hasPlayer(id: PlayerID): boolean
players(): Player[]
// Map & Dimensions
isOnMap(cell: Cell): boolean
width(): number
height(): number
forEachTile(fn: (tile: TileRef) => void): void
executions(): ExecutionView[]
terraNullius(): TerraNullius
executeNextTick(): GameUpdates
ticks(): Tick
inSpawnPhase(): boolean
addExecution(...exec: Execution[]): void
nations(): Nation[]
config(): Config
displayMessage(message: string, type: MessageType, playerID: PlayerID | null): void
units(...types: UnitType[]): Unit[]
unitInfo(type: UnitType): UnitInfo
playerBySmallID(id: number): Player | TerraNullius
map(): GameMap
miniMap(): GameMap
owner(ref: TileRef): Player | TerraNullius
}
forEachTile(fn: (tile: TileRef) => void): void
export interface MutableGame extends Game {
// Player Management
player(id: PlayerID): Player
playerByClientID(id: ClientID): Player | null
players(): Player[]
allPlayers(): Player[]
playerByClientID(id: ClientID): Player | null
playerBySmallID(id: number): Player | TerraNullius
hasPlayer(id: PlayerID): boolean
addPlayer(playerInfo: PlayerInfo, manpower: number): Player
executions(): Execution[]
terraNullius(): TerraNullius
owner(ref: TileRef): Player | TerraNullius
// Game State
ticks(): Tick
inSpawnPhase(): boolean
executeNextTick(): GameUpdates
setWinner(winner: Player): void
config(): Config
// Units
units(...types: UnitType[]): MutableUnit[]
unitInfo(type: UnitType): UnitInfo
addTileDefenseBonus(tile: TileRef, unit: Unit, amount: number): DefenseBonus
removeTileDefenseBonus(bonus: DefenseBonus): void
setWinner(winner: Player): void
// Events & Messages
executions(): Execution[]
addExecution(...exec: Execution[]): void
displayMessage(message: string, type: MessageType, playerID: PlayerID | null): void
// Nations
nations(): Nation[]
}
export enum GameUpdateType {
+2 -2
View File
@@ -1,5 +1,5 @@
import { Config } from "../configuration/Config";
import { Cell, Execution, MutableGame, Game, PlayerID, PlayerInfo, Player, TerraNullius, Unit, MutableAllianceRequest, Alliance, Nation, UnitType, UnitInfo, DefenseBonus, GameUpdate, GameUpdateType, AllPlayers, GameUpdates, TerrainType, EmojiMessage } from "./Game";
import { Cell, Execution, Game, PlayerID, PlayerInfo, Player, TerraNullius, Unit, MutableAllianceRequest, Alliance, Nation, UnitType, UnitInfo, DefenseBonus, GameUpdate, GameUpdateType, AllPlayers, GameUpdates, TerrainType, EmojiMessage } from "./Game";
import { NationMap } from "./TerrainMapLoader";
import { PlayerImpl } from "./PlayerImpl";
import { TerraNulliusImpl } from "./TerraNulliusImpl";
@@ -17,7 +17,7 @@ export function createGame(gameMap: GameMap, miniGameMap: GameMap, nationMap: Na
export type CellString = string
export class GameImpl implements MutableGame {
export class GameImpl implements Game {
private _ticks = 0
private unInitExecs: Execution[] = []