combine Game & MutableGame

This commit is contained in:
evanpelle
2025-01-23 11:12:01 -08:00
committed by Evan
parent 7d15c0c065
commit de1dbff570
30 changed files with 101 additions and 101 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
import { Executor } from "../core/execution/ExecutionManager";
import { Cell, MutableGame, PlayerID, GameMapType, Difficulty, GameType } from "../core/game/Game";
import { Cell, Game, PlayerID, GameMapType, Difficulty, GameType } from "../core/game/Game";
import { EventBus } from "../core/EventBus";
import { createRenderer, GameRenderer } from "./graphics/GameRenderer";
import { InputHandler, MouseUpEvent, ZoomEvent, DragEvent, MouseDownEvent } from "./InputHandler"
+3 -3
View File
@@ -4,7 +4,7 @@ import { getConfig } from "./configuration/Config";
import { EventBus } from "./EventBus";
import { Executor } from "./execution/ExecutionManager";
import { WinCheckExecution } from "./execution/WinCheckExecution";
import { AllPlayers, Cell, DisplayMessageUpdate, Game, GameUpdateType, MessageType, MutableGame, NameViewData, Player, PlayerActions, PlayerID, PlayerProfile, PlayerType, UnitType } from "./game/Game";
import { AllPlayers, Cell, DisplayMessageUpdate, Game, GameUpdateType, MessageType, NameViewData, Player, PlayerActions, PlayerID, PlayerProfile, PlayerType, UnitType } from "./game/Game";
import { createGame } from "./game/GameImpl";
import { loadTerrainMap as loadGameMap } from "./game/TerrainMapLoader";
import { GameConfig, Turn } from "./Schemas";
@@ -16,7 +16,7 @@ export async function createGameRunner(gameID: string, gameConfig: GameConfig, c
const config = getConfig(gameConfig)
const gameMap = await loadGameMap(gameConfig.gameMap);
const game = createGame(gameMap.gameMap, gameMap.miniGameMap, gameMap.nationMap, config)
const gr = new GameRunner(game as MutableGame, new Executor(game, gameID), callBack)
const gr = new GameRunner(game as Game, new Executor(game, gameID), callBack)
gr.init()
return gr
}
@@ -30,7 +30,7 @@ export class GameRunner {
private playerViewData: Record<PlayerID, NameViewData> = {}
constructor(
public game: MutableGame,
public game: Game,
private execManager: Executor,
private callBack: (gu: GameUpdateViewData) => void
) {
+2 -4
View File
@@ -1,9 +1,7 @@
import { v4 as uuidv4 } from 'uuid';
import twemoji from 'twemoji';
import DOMPurify from 'dompurify';
import { Cell, Game, MutableGame, Player, Unit } from "./game/Game";
import { Cell, Game, Player, Unit } from "./game/Game";
import { GameConfig, GameID, GameRecord, PlayerRecord, Turn } from './Schemas';
import { customAlphabet, nanoid } from 'nanoid';
import { andFN, GameMap, manhattanDistFN, TileRef } from './game/GameMap';
@@ -46,7 +44,7 @@ export function distSortUnit(gm: GameMap, target: Unit | TileRef): (a: Unit, b:
// TODO: refactor to new file
export function sourceDstOceanShore(gm: MutableGame, src: Player, tile: TileRef): [TileRef | null, TileRef | null] {
export function sourceDstOceanShore(gm: Game, src: Player, tile: TileRef): [TileRef | null, TileRef | null] {
const dst = gm.owner(tile)
let srcTile = closestOceanShoreFromPlayer(gm, src, tile)
let dstTile: TileRef | null = null
+3 -3
View File
@@ -1,5 +1,5 @@
import { PriorityQueue } from "@datastructures-js/priority-queue";
import { Cell, Execution, MutableGame, Player, PlayerID, PlayerType, TerrainType, TerraNullius } from "../game/Game";
import { Cell, Execution, Game, Player, PlayerID, PlayerType, TerrainType, TerraNullius } from "../game/Game";
import { PseudoRandom } from "../PseudoRandom";
import { MessageType } from '../game/Game';
import { renderNumber } from "../../client/Utils";
@@ -23,7 +23,7 @@ export class AttackExecution implements Execution {
private _owner: Player
private target: Player | TerraNullius
private mg: MutableGame
private mg: Game
private border = new Set<TileRef>()
@@ -43,7 +43,7 @@ export class AttackExecution implements Execution {
return false
}
init(mg: MutableGame, ticks: number) {
init(mg: Game, ticks: number) {
if (!this.active) {
return
}
+3 -3
View File
@@ -1,4 +1,4 @@
import { Cell, Execution, MutableGame, Player, MutableUnit, PlayerID, TerrainType, Unit, UnitType } from "../game/Game";
import { Cell, Execution, Game, Player, MutableUnit, PlayerID, TerrainType, Unit, UnitType } from "../game/Game";
import { PathFinder } from "../pathfinding/PathFinding";
import { PathFindResultType } from "../pathfinding/AStar";
import { PseudoRandom } from "../PseudoRandom";
@@ -13,7 +13,7 @@ export class BattleshipExecution implements Execution {
private _owner: Player
private active = true
private battleship: MutableUnit = null
private mg: MutableGame = null
private mg: Game = null
private pathfinder: PathFinder
@@ -32,7 +32,7 @@ export class BattleshipExecution implements Execution {
) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.pathfinder = PathFinder.Mini(mg, 5000, false)
this._owner = mg.player(this.playerID)
this.mg = mg
+3 -3
View File
@@ -1,4 +1,4 @@
import { Cell, Execution, MutableGame, Player, PlayerType, TerraNullius } from "../game/Game"
import { Cell, Execution, Game, Player, PlayerType, TerraNullius } from "../game/Game"
import { PseudoRandom } from "../PseudoRandom"
import { simpleHash } from "../Util";
import { AttackExecution } from "./AttackExecution";
@@ -8,7 +8,7 @@ export class BotExecution implements Execution {
private active = true
private random: PseudoRandom;
private attackRate: number
private mg: MutableGame
private mg: Game
private neighborsTerraNullius = true
@@ -20,7 +20,7 @@ export class BotExecution implements Execution {
return false
}
init(mg: MutableGame, ticks: number) {
init(mg: Game, ticks: number) {
this.mg = mg
// this.neighborsTerra = this.bot.neighbors().filter(n => n == this.gs.terraNullius()).length > 0
}
+3 -3
View File
@@ -1,17 +1,17 @@
import { consolex } from "../Consolex";
import { Execution, MutableGame, Player, MutableUnit, PlayerID, UnitType } from "../game/Game";
import { Execution, Game, Player, MutableUnit, PlayerID, UnitType } from "../game/Game";
import { TileRef } from "../game/GameMap";
export class CityExecution implements Execution {
private player: Player
private mg: MutableGame
private mg: Game
private city: MutableUnit
private active: boolean = true
constructor(private ownerId: PlayerID, private tile: TileRef) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.mg = mg
this.player = mg.player(this.ownerId)
}
+3 -3
View File
@@ -1,11 +1,11 @@
import { consolex } from "../Consolex";
import { Cell, DefenseBonus, Execution, MutableGame, Player, MutableUnit, PlayerID, UnitType } from "../game/Game";
import { Cell, DefenseBonus, Execution, Game, Player, MutableUnit, PlayerID, UnitType } from "../game/Game";
import { manhattanDistFN, TileRef } from "../game/GameMap";
export class DefensePostExecution implements Execution {
private player: Player
private mg: MutableGame
private mg: Game
private post: MutableUnit
private active: boolean = true
@@ -13,7 +13,7 @@ export class DefensePostExecution implements Execution {
constructor(private ownerId: PlayerID, private tile: TileRef) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.mg = mg
this.player = mg.player(this.ownerId)
}
+3 -3
View File
@@ -1,4 +1,4 @@
import { Cell, Execution, MutableGame, Player, MutableUnit, PlayerID, TerrainType, UnitType } from "../game/Game";
import { Cell, Execution, Game, Player, MutableUnit, PlayerID, TerrainType, UnitType } from "../game/Game";
import { PathFinder } from "../pathfinding/PathFinding";
import { PathFindResultType } from "../pathfinding/AStar";
import { PseudoRandom } from "../PseudoRandom";
@@ -12,7 +12,7 @@ export class DestroyerExecution implements Execution {
private _owner: Player
private active = true
private destroyer: MutableUnit = null
private mg: MutableGame = null
private mg: Game = null
private target: MutableUnit = null
private pathfinder: PathFinder
@@ -28,7 +28,7 @@ export class DestroyerExecution implements Execution {
) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.pathfinder = PathFinder.Mini(mg, 5000, false)
this._owner = mg.player(this.playerID)
this.mg = mg
+2 -2
View File
@@ -1,5 +1,5 @@
import { consolex } from "../Consolex";
import { Execution, MutableGame, Player, PlayerID } from "../game/Game";
import { Execution, Game, Player, PlayerID } from "../game/Game";
export class DonateExecution implements Execution {
@@ -15,7 +15,7 @@ export class DonateExecution implements Execution {
) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.sender = mg.player(this.senderID)
this.recipient = mg.player(this.recipientID)
if (this.troops == null) {
+2 -2
View File
@@ -1,5 +1,5 @@
import { consolex } from "../Consolex";
import { AllPlayers, Execution, MutableGame, Player, PlayerID, PlayerType, UnitType } from "../game/Game";
import { AllPlayers, Execution, Game, Player, PlayerID, PlayerType, UnitType } from "../game/Game";
export class EmojiExecution implements Execution {
@@ -15,7 +15,7 @@ export class EmojiExecution implements Execution {
) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.requestor = mg.player(this.senderID)
this.recipient = this.recipientID == AllPlayers ? AllPlayers : mg.player(this.recipientID)
}
+1 -1
View File
@@ -1,4 +1,4 @@
import { Cell, Execution, MutableGame, Game, Player, PlayerInfo, TerraNullius, PlayerType, Alliance, UnitType } from "../game/Game";
import { Cell, Execution, Game, Player, PlayerInfo, TerraNullius, PlayerType, Alliance, UnitType } from "../game/Game";
import { AttackIntent, BoatAttackIntentSchema, GameID, Intent, Turn } from "../Schemas";
import { AttackExecution } from "./AttackExecution";
import { SpawnExecution } from "./SpawnExecution";
+3 -3
View File
@@ -1,4 +1,4 @@
import { AllianceRequest, Cell, Difficulty, Execution, MutableGame, Player, PlayerInfo, PlayerType, Relation, TerrainType, TerraNullius, UnitType } from "../game/Game"
import { AllianceRequest, Cell, Difficulty, Execution, Game, Player, PlayerInfo, PlayerType, Relation, TerrainType, TerraNullius, UnitType } from "../game/Game"
import { PseudoRandom } from "../PseudoRandom"
import { AttackExecution } from "./AttackExecution";
import { TransportShipExecution } from "./TransportShipExecution";
@@ -23,7 +23,7 @@ export class FakeHumanExecution implements Execution {
private active = true
private random: PseudoRandom;
private mg: MutableGame
private mg: Game
private player: Player = null
private enemy: Player | null = null
@@ -36,7 +36,7 @@ export class FakeHumanExecution implements Execution {
this.random = new PseudoRandom(simpleHash(playerInfo.id) + simpleHash(gameID))
}
init(mg: MutableGame, ticks: number) {
init(mg: Game, ticks: number) {
this.mg = mg
if (this.random.chance(10)) {
// this.isTraitor = true
+3 -3
View File
@@ -1,11 +1,11 @@
import { consolex } from "../Consolex";
import { Cell, Execution, MutableGame, Player, MutableUnit, PlayerID, UnitType } from "../game/Game";
import { Cell, Execution, Game, Player, MutableUnit, PlayerID, UnitType } from "../game/Game";
import { TileRef } from "../game/GameMap";
export class MissileSiloExecution implements Execution {
private active = true
private mg: MutableGame
private mg: Game
private player: Player
private silo: MutableUnit
@@ -15,7 +15,7 @@ export class MissileSiloExecution implements Execution {
) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.mg = mg
this.player = mg.player(this._owner)
}
+3 -3
View File
@@ -1,5 +1,5 @@
import { nextTick } from "process";
import { Cell, Execution, MutableGame, Player, PlayerID, MutableUnit, UnitType, TerraNullius } from "../game/Game";
import { Cell, Execution, Game, Player, PlayerID, MutableUnit, UnitType, TerraNullius } from "../game/Game";
import { PathFinder } from "../pathfinding/PathFinding";
import { PathFindResultType } from "../pathfinding/AStar";
import { PseudoRandom } from "../PseudoRandom";
@@ -12,7 +12,7 @@ export class NukeExecution implements Execution {
private active = true
private mg: MutableGame
private mg: Game
private nuke: MutableUnit
@@ -24,7 +24,7 @@ export class NukeExecution implements Execution {
) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.mg = mg
this.pathFinder = PathFinder.Mini(mg, 10_000, true)
this.player = mg.player(this.senderID)
+3 -3
View File
@@ -1,5 +1,5 @@
import { Config } from "../configuration/Config"
import { Execution, MutableGame, Player, PlayerID, TerraNullius, UnitType } from "../game/Game"
import { Execution, Game, Player, PlayerID, TerraNullius, UnitType } from "../game/Game"
import { calculateBoundingBox, getMode, inscribed, simpleHash } from "../Util"
import { GameImpl } from "../game/GameImpl"
import { consolex } from "../Consolex"
@@ -12,7 +12,7 @@ export class PlayerExecution implements Execution {
private player: Player
private config: Config
private lastCalc = 0
private mg: MutableGame
private mg: Game
private active = true
constructor(private playerID: PlayerID) {
@@ -22,7 +22,7 @@ export class PlayerExecution implements Execution {
return false
}
init(mg: MutableGame, ticks: number) {
init(mg: Game, ticks: number) {
this.mg = mg
this.config = mg.config()
this.player = mg.player(this.playerID)
+3 -3
View File
@@ -1,4 +1,4 @@
import { AllPlayers, Cell, Execution, MutableGame, Player, MutableUnit, PlayerID, TerrainType, UnitType } from "../game/Game";
import { AllPlayers, Cell, Execution, Game, Player, MutableUnit, PlayerID, TerrainType, UnitType } from "../game/Game";
import { PathFinder } from "../pathfinding/PathFinding";
import { PathFindResultType } from "../pathfinding/AStar";
import { PseudoRandom } from "../PseudoRandom";
@@ -10,7 +10,7 @@ import { manhattanDistFN, TileRef } from "../game/GameMap";
export class PortExecution implements Execution {
private active = true
private mg: MutableGame
private mg: Game
private port: MutableUnit
private random: PseudoRandom
private portPaths = new Map<MutableUnit, TileRef[]>()
@@ -22,7 +22,7 @@ export class PortExecution implements Execution {
) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.mg = mg
this.random = new PseudoRandom(mg.ticks())
}
@@ -1,5 +1,5 @@
import { consolex } from "../Consolex";
import { Execution, MutableGame, Player, PlayerID } from "../game/Game";
import { Execution, Game, Player, PlayerID } from "../game/Game";
export class SetTargetTroopRatioExecution implements Execution {
@@ -10,7 +10,7 @@ export class SetTargetTroopRatioExecution implements Execution {
constructor(private playerID: PlayerID, private targetTroopsRatio: number) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.player = mg.player(this.playerID)
}
+2 -2
View File
@@ -1,4 +1,4 @@
import { Execution, MutableGame, Player, MutableUnit, Unit, UnitType } from "../game/Game";
import { Execution, Game, Player, MutableUnit, Unit, UnitType } from "../game/Game";
import { PathFinder } from "../pathfinding/PathFinding";
import { PathFindResultType } from "../pathfinding/AStar";
import { consolex } from "../Consolex";
@@ -14,7 +14,7 @@ export class ShellExecution implements Execution {
}
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.pathFinder = PathFinder.Mini(mg, 2000, true, 10)
}
+3 -3
View File
@@ -1,4 +1,4 @@
import { Cell, Execution, MutableGame, Player, PlayerInfo, PlayerType } from "../game/Game"
import { Cell, Execution, Game, Player, PlayerInfo, PlayerType } from "../game/Game"
import { TileRef } from "../game/GameMap"
import { BotExecution } from "./BotExecution"
import { PlayerExecution } from "./PlayerExecution"
@@ -7,14 +7,14 @@ import { getSpawnTiles } from "./Util"
export class SpawnExecution implements Execution {
active: boolean = true
private mg: MutableGame
private mg: Game
constructor(
private playerInfo: PlayerInfo,
private tile: TileRef
) { }
init(mg: MutableGame, ticks: number) {
init(mg: Game, ticks: number) {
this.mg = mg
}
+2 -2
View File
@@ -1,4 +1,4 @@
import { Execution, MutableGame, Player, PlayerID } from "../game/Game";
import { Execution, Game, Player, PlayerID } from "../game/Game";
export class TargetPlayerExecution implements Execution {
@@ -10,7 +10,7 @@ export class TargetPlayerExecution implements Execution {
constructor(private requestorID: PlayerID, private targetID: PlayerID) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.requestor = mg.player(this.requestorID)
this.target = mg.player(this.targetID)
}
+3 -3
View File
@@ -1,6 +1,6 @@
import { MessageType } from '../game/Game';
import { renderNumber } from "../../client/Utils";
import { AllPlayers, Cell, Execution, MutableGame, MutableUnit, Player, PlayerID, UnitType } from "../game/Game";
import { AllPlayers, Cell, Execution, Game, MutableUnit, Player, PlayerID, UnitType } from "../game/Game";
import { PathFinder } from "../pathfinding/PathFinding";
import { PathFindResultType } from "../pathfinding/AStar";
import { distSortUnit } from "../Util";
@@ -10,7 +10,7 @@ import { TileRef } from '../game/GameMap';
export class TradeShipExecution implements Execution {
private active = true
private mg: MutableGame
private mg: Game
private origOwner: Player
private tradeShip: MutableUnit
private index = 0
@@ -26,7 +26,7 @@ export class TradeShipExecution implements Execution {
) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.mg = mg
this.origOwner = mg.player(this._owner)
}
+3 -3
View File
@@ -1,4 +1,4 @@
import { Unit, Cell, Execution, MutableUnit, MutableGame, Player, PlayerID, TerraNullius, UnitType, TerrainType } from "../game/Game";
import { Unit, Cell, Execution, MutableUnit, Game, Player, PlayerID, TerraNullius, UnitType, TerrainType } from "../game/Game";
import { AttackExecution } from "./AttackExecution";
import { MessageType } from '../game/Game';
import { PathFinder } from "../pathfinding/PathFinding";
@@ -16,7 +16,7 @@ export class TransportShipExecution implements Execution {
private active = true
private mg: MutableGame
private mg: Game
private attacker: Player
private target: Player | TerraNullius
@@ -41,7 +41,7 @@ export class TransportShipExecution implements Execution {
return false
}
init(mg: MutableGame, ticks: number) {
init(mg: Game, ticks: number) {
this.lastMove = ticks
this.mg = mg
this.pathFinder = PathFinder.Mini(mg, 10_000, false, 2)
+3 -3
View File
@@ -1,5 +1,5 @@
import { EventBus, GameEvent } from "../EventBus"
import { Execution, MutableGame, Player, PlayerID } from "../game/Game"
import { Execution, Game, Player, PlayerID } from "../game/Game"
export class WinEvent implements GameEvent {
constructor(public readonly winner: Player) { }
@@ -9,12 +9,12 @@ export class WinCheckExecution implements Execution {
private active = true
private mg: MutableGame
private mg: Game
constructor() {
}
init(mg: MutableGame, ticks: number) {
init(mg: Game, ticks: number) {
this.mg = mg
}
@@ -1,15 +1,15 @@
import { consolex } from "../../Consolex";
import {AllianceRequest, Execution, MutableGame, Player, PlayerID} from "../../game/Game";
import {AllianceRequest, Execution, Game, Player, PlayerID} from "../../game/Game";
export class AllianceRequestExecution implements Execution {
private active = true
private mg: MutableGame = null
private mg: Game = null
private requestor: Player;
private recipient: Player
constructor(private requestorID: PlayerID, private recipientID: PlayerID) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.mg = mg
this.requestor = mg.player(this.requestorID)
this.recipient = mg.player(this.recipientID)
@@ -1,15 +1,15 @@
import { consolex } from "../../Consolex";
import { AllianceRequest, Execution, MutableGame, Player, PlayerID } from "../../game/Game";
import { AllianceRequest, Execution, Game, Player, PlayerID } from "../../game/Game";
export class AllianceRequestReplyExecution implements Execution {
private active = true
private mg: MutableGame = null
private mg: Game = null
private requestor: Player;
private recipient: Player
constructor(private requestorID: PlayerID, private recipientID: PlayerID, private accept: boolean) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.mg = mg
this.requestor = mg.player(this.requestorID)
this.recipient = mg.player(this.recipientID)
@@ -1,15 +1,15 @@
import { consolex } from "../../Consolex";
import { AllianceRequest, Execution, MutableGame, Player, PlayerID } from "../../game/Game";
import { AllianceRequest, Execution, Game, Player, PlayerID } from "../../game/Game";
export class BreakAllianceExecution implements Execution {
private active = true
private requestor: Player;
private recipient: Player
private mg: MutableGame
private mg: Game
constructor(private requestorID: PlayerID, private recipientID: PlayerID) { }
init(mg: MutableGame, ticks: number): void {
init(mg: Game, ticks: number): void {
this.requestor = mg.player(this.requestorID)
this.recipient = mg.player(this.recipientID)
this.mg = mg
+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[] = []