mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 11:50:42 +00:00
move Game updates to GameUpdate.ts
This commit is contained in:
@@ -8,11 +8,12 @@ import { loadTerrainFromFile, loadTerrainMap } from "../core/game/TerrainMapLoad
|
||||
import { SendAttackIntentEvent, SendSpawnIntentEvent, Transport } from "./Transport";
|
||||
import { createCanvas } from "./Utils";
|
||||
import { MessageType } from '../core/game/Game';
|
||||
import { DisplayMessageUpdate } from '../core/game/Game';
|
||||
import { DisplayMessageUpdate } from "../core/game/GameUpdates";
|
||||
import { WorkerClient } from "../core/worker/WorkerClient";
|
||||
import { consolex, initRemoteSender } from "../core/Consolex";
|
||||
import { getConfig, getServerConfig } from "../core/configuration/Config";
|
||||
import { GameUpdateViewData, GameView, PlayerView } from "../core/GameView";
|
||||
import { GameView, PlayerView } from "../core/game/GameView";
|
||||
import { GameUpdateViewData } from '../core/game/GameUpdates';
|
||||
|
||||
export interface LobbyConfig {
|
||||
playerName: () => string
|
||||
|
||||
@@ -9,7 +9,7 @@ import { UsernameInput } from "./UsernameInput";
|
||||
import { HostLobbyModal as HostPrivateLobbyModal } from "./HostLobbyModal";
|
||||
import { JoinPrivateLobbyModal } from "./JoinPrivateLobbyModal";
|
||||
import { SinglePlayerModal } from "./SinglePlayerModal";
|
||||
import { PlayerView } from "../core/GameView"
|
||||
import { PlayerView } from "../core/game/GameView"
|
||||
|
||||
export class PauseGameEvent implements GameEvent {
|
||||
constructor(public readonly paused: boolean) { }
|
||||
|
||||
@@ -19,7 +19,7 @@ import { StructureLayer } from "./layers/StructureLayer";
|
||||
import { PlayerInfoOverlay } from "./layers/PlayerInfoOverlay";
|
||||
import { consolex } from "../../core/Consolex";
|
||||
import { RefreshGraphicsEvent as RedrawGraphicsEvent } from "../InputHandler";
|
||||
import { GameView } from "../../core/GameView";
|
||||
import { GameView } from "../../core/game/GameView";
|
||||
|
||||
|
||||
export function createRenderer(canvas: HTMLCanvasElement, game: GameView, eventBus: EventBus, clientID: ClientID): GameRenderer {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Game, Player, Cell, NameViewData } from '../../core/game/Game';
|
||||
import { Game, Player, Cell } from '../../core/game/Game';
|
||||
import { NameViewData } from '../../core/game/Game';
|
||||
import { calculateBoundingBox, within } from '../../core/Util';
|
||||
|
||||
export interface Point {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { calculateBoundingBox, calculateBoundingBoxCenter } from "../../core/Uti
|
||||
import { ZoomEvent, DragEvent } from "../InputHandler";
|
||||
import { GoToPlayerEvent } from "./layers/Leaderboard";
|
||||
import { placeName } from "./NameBoxCalculator";
|
||||
import { GameView } from "../../core/GameView";
|
||||
import { GameView } from "../../core/game/GameView";
|
||||
|
||||
export class TransformHandler {
|
||||
public scale: number = 1.8
|
||||
|
||||
@@ -7,7 +7,7 @@ import { renderNumber, renderTroops } from '../../Utils';
|
||||
import { EventBus } from '../../../core/EventBus';
|
||||
import { UIState } from '../UIState';
|
||||
import { SendSetTargetTroopRatioEvent } from '../../Transport';
|
||||
import { GameView } from '../../../core/GameView';
|
||||
import { GameView } from '../../../core/game/GameView';
|
||||
|
||||
@customElement('control-panel')
|
||||
export class ControlPanel extends LitElement implements Layer {
|
||||
|
||||
@@ -2,23 +2,23 @@ import { LitElement, html, css } from 'lit';
|
||||
import { customElement, property, state } from 'lit/decorators.js';
|
||||
import { EventBus } from "../../../core/EventBus";
|
||||
import {
|
||||
AllianceExpiredUpdate,
|
||||
AllianceRequestReplyUpdate,
|
||||
AllianceRequestUpdate,
|
||||
AllPlayers,
|
||||
BrokeAllianceUpdate,
|
||||
DisplayMessageUpdate,
|
||||
EmojiUpdate,
|
||||
GameUpdateType,
|
||||
MessageType,
|
||||
TargetPlayerUpdate,
|
||||
} from "../../../core/game/Game";
|
||||
import { DisplayMessageUpdate } from "../../../core/game/GameUpdates";
|
||||
import { EmojiUpdate } from "../../../core/game/GameUpdates";
|
||||
import { TargetPlayerUpdate } from "../../../core/game/GameUpdates";
|
||||
import { AllianceExpiredUpdate } from "../../../core/game/GameUpdates";
|
||||
import { BrokeAllianceUpdate } from "../../../core/game/GameUpdates";
|
||||
import { AllianceRequestReplyUpdate } from "../../../core/game/GameUpdates";
|
||||
import { AllianceRequestUpdate } from "../../../core/game/GameUpdates";
|
||||
import { GameUpdateType } from "../../../core/game/GameUpdates";
|
||||
import { ClientID } from "../../../core/Schemas";
|
||||
import { Layer } from "./Layer";
|
||||
import { SendAllianceReplyIntentEvent } from "../../Transport";
|
||||
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
||||
import { onlyImages, sanitize } from '../../../core/Util';
|
||||
import { GameView, PlayerView } from '../../../core/GameView';
|
||||
import { GameView, PlayerView } from '../../../core/game/GameView';
|
||||
|
||||
interface Event {
|
||||
description: string;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ClientID } from '../../../core/Schemas';
|
||||
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
||||
import { EventBus, GameEvent } from '../../../core/EventBus';
|
||||
import { renderNumber } from '../../Utils';
|
||||
import { GameView, PlayerView } from '../../../core/GameView';
|
||||
import { GameView, PlayerView } from '../../../core/game/GameView';
|
||||
|
||||
interface Entry {
|
||||
name: string
|
||||
|
||||
@@ -8,7 +8,7 @@ import allianceIcon from '../../../../resources/images/AllianceIcon.png';
|
||||
import crownIcon from '../../../../resources/images/CrownIcon.png';
|
||||
import targetIcon from '../../../../resources/images/TargetIcon.png';
|
||||
import { ClientID } from "../../../core/Schemas"
|
||||
import { GameView, PlayerView } from "../../../core/GameView"
|
||||
import { GameView, PlayerView } from "../../../core/game/GameView"
|
||||
import { createCanvas, renderTroops } from "../../Utils"
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ClientID } from '../../../core/Schemas';
|
||||
import { EventBus } from '../../../core/EventBus';
|
||||
import { TransformHandler } from '../TransformHandler';
|
||||
import { MouseMoveEvent } from '../../InputHandler';
|
||||
import { GameView, PlayerView, UnitView } from '../../../core/GameView';
|
||||
import { GameView, PlayerView, UnitView } from '../../../core/game/GameView';
|
||||
import { TileRef } from '../../../core/game/GameMap';
|
||||
import { PauseGameEvent } from '../../Transport';
|
||||
import { renderNumber, renderTroops } from '../../Utils';
|
||||
|
||||
@@ -7,8 +7,9 @@ import anchorIcon from '../../../../resources/images/AnchorIcon.png';
|
||||
import missileSiloIcon from '../../../../resources/images/MissileSiloUnit.png';
|
||||
import shieldIcon from '../../../../resources/images/ShieldIcon.png';
|
||||
import cityIcon from '../../../../resources/images/CityIcon.png';
|
||||
import { GameView, UnitView } from "../../../core/GameView";
|
||||
import { Cell, GameUpdateType, Unit, UnitType } from "../../../core/game/Game";
|
||||
import { GameView, UnitView } from "../../../core/game/GameView";
|
||||
import { Cell, Unit, UnitType } from "../../../core/game/Game";
|
||||
import { GameUpdateType } from "../../../core/game/GameUpdates";
|
||||
import { euclDistFN } from "../../../core/game/GameMap";
|
||||
|
||||
interface UnitRenderConfig {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Layer } from "./Layer";
|
||||
import { GameView } from "../../../core/GameView";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
|
||||
export class TerrainLayer implements Layer {
|
||||
private canvas: HTMLCanvasElement
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { PriorityQueue } from "@datastructures-js/priority-queue";
|
||||
import { Cell, Game, Player, PlayerType, Unit, UnitType, UnitUpdate } from "../../../core/game/Game";
|
||||
import { Cell, Game, Player, PlayerType, Unit, UnitType } from "../../../core/game/Game";
|
||||
import { UnitUpdate } from "../../../core/game/GameUpdates";
|
||||
import { PseudoRandom } from "../../../core/PseudoRandom";
|
||||
import { colord, Colord } from "colord";
|
||||
import { Theme } from "../../../core/configuration/Config";
|
||||
import { Layer } from "./Layer";
|
||||
import { EventBus } from "../../../core/EventBus";
|
||||
import { AlternateViewEvent, DragEvent, MouseDownEvent } from "../../InputHandler";
|
||||
import { GameView, PlayerView } from "../../../core/GameView";
|
||||
import { GameView, PlayerView } from "../../../core/game/GameView";
|
||||
import { euclDistFN, TileRef } from "../../../core/game/GameMap";
|
||||
|
||||
export class TerritoryLayer implements Layer {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ClientID } from "../../../core/Schemas";
|
||||
import { Layer } from "./Layer";
|
||||
import { TransformHandler } from "../TransformHandler";
|
||||
import { consolex } from "../../../core/Consolex";
|
||||
import { GameView } from "../../../core/GameView";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
|
||||
interface MenuOption {
|
||||
label: string;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { Colord } from "colord";
|
||||
import { Theme } from "../../../core/configuration/Config";
|
||||
import { Unit, UnitType, Player, UnitUpdate } from "../../../core/game/Game";
|
||||
import { Unit, UnitType, Player } from "../../../core/game/Game";
|
||||
import { UnitUpdate } from "../../../core/game/GameUpdates";
|
||||
import { Layer } from "./Layer";
|
||||
import { EventBus } from "../../../core/EventBus";
|
||||
import { AlternateViewEvent } from "../../InputHandler";
|
||||
import { ClientID } from "../../../core/Schemas";
|
||||
import { GameView, PlayerView, UnitView } from "../../../core/GameView";
|
||||
import { GameView, PlayerView, UnitView } from "../../../core/game/GameView";
|
||||
import { euclDistFN, manhattanDistFN, TileRef } from "../../../core/game/GameMap";
|
||||
|
||||
enum Relationship {
|
||||
|
||||
@@ -14,7 +14,7 @@ import shieldIcon from '../../../../../resources/images/ShieldIconWhite.svg';
|
||||
import cityIcon from '../../../../../resources/images/CityIconWhite.svg';
|
||||
import { renderNumber } from '../../../Utils';
|
||||
import { ContextMenuEvent } from '../../../InputHandler';
|
||||
import { GameView, PlayerView } from '../../../../core/GameView';
|
||||
import { GameView, PlayerView } from '../../../../core/game/GameView';
|
||||
|
||||
interface BuildItemDisplay {
|
||||
unitType: UnitType
|
||||
|
||||
@@ -19,7 +19,7 @@ import { EmojiTable } from "./EmojiTable";
|
||||
import { UIState } from "../../UIState";
|
||||
import { BuildMenu } from "./BuildMenu";
|
||||
import { consolex } from "../../../../core/Consolex";
|
||||
import { GameView, PlayerView } from "../../../../core/GameView";
|
||||
import { GameView, PlayerView } from "../../../../core/game/GameView";
|
||||
import { TileRef } from "../../../../core/game/GameMap";
|
||||
|
||||
|
||||
|
||||
@@ -4,11 +4,14 @@ 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, NameViewData, Player, PlayerActions, PlayerID, PlayerProfile, PlayerType, UnitType } from "./game/Game";
|
||||
import { AllPlayers, Cell, Game, MessageType, Player, PlayerActions, PlayerID, PlayerProfile, PlayerType, UnitType } from "./game/Game";
|
||||
import { DisplayMessageUpdate } from "./game/GameUpdates";
|
||||
import { NameViewData } from './game/Game';
|
||||
import { GameUpdateType } from "./game/GameUpdates";
|
||||
import { createGame } from "./game/GameImpl";
|
||||
import { loadTerrainMap as loadGameMap } from "./game/TerrainMapLoader";
|
||||
import { GameConfig, Turn } from "./Schemas";
|
||||
import { GameUpdateViewData } from "./GameView";
|
||||
import { GameUpdateViewData } from './game/GameUpdates';
|
||||
import { andFN, manhattanDistFN, TileRef } from "./game/GameMap";
|
||||
import { targetTransportTile } from "./Util";
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { GameConfig } from "../Schemas";
|
||||
import { DefaultConfig } from "./DefaultConfig";
|
||||
import { DevConfig, DevServerConfig } from "./DevConfig";
|
||||
import { GameMap, TileRef } from "../game/GameMap";
|
||||
import { PlayerView } from "../GameView";
|
||||
import { PlayerView } from "../game/GameView";
|
||||
|
||||
export enum GameEnv {
|
||||
Dev,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Difficulty, GameType, Gold, Player, PlayerInfo, PlayerType, TerrainType, TerraNullius, Tick, UnitInfo, UnitType } from "../game/Game";
|
||||
import { GameMap, TileRef } from "../game/GameMap";
|
||||
import { PlayerView } from "../GameView";
|
||||
import { PlayerView } from "../game/GameView";
|
||||
import { GameConfig } from "../Schemas";
|
||||
import { assertNever, within } from "../Util";
|
||||
import { Config, ServerConfig, Theme } from "./Config";
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { AllianceRequestUpdate, GameUpdateType, AllianceRequest, Player, Tick } from "./Game";
|
||||
import { AllianceRequest, Player, Tick } from "./Game";
|
||||
import { AllianceRequestUpdate } from "./GameUpdates";
|
||||
import { GameUpdateType } from "./GameUpdates";
|
||||
import { GameImpl } from "./GameImpl";
|
||||
|
||||
|
||||
|
||||
+9
-122
@@ -1,8 +1,9 @@
|
||||
import { Config } from "../configuration/Config"
|
||||
import { GameEvent } from "../EventBus"
|
||||
import { PlayerView } from "../GameView"
|
||||
import { PlayerView } from "./GameView"
|
||||
import { ClientID, GameConfig, GameID } from "../Schemas"
|
||||
import { GameMap, GameMapImpl, TileRef, TileUpdate } from "./GameMap"
|
||||
import { GameMap, GameMapImpl, TileRef } from "./GameMap"
|
||||
import { GameUpdate, GameUpdateType, PlayerUpdate, UnitUpdate } from "./GameUpdates"
|
||||
|
||||
export type PlayerID = string
|
||||
export type Tick = number
|
||||
@@ -326,26 +327,6 @@ export interface Game extends GameMap {
|
||||
nations(): Nation[]
|
||||
}
|
||||
|
||||
export enum GameUpdateType {
|
||||
Tile,
|
||||
Unit,
|
||||
Player,
|
||||
DisplayEvent,
|
||||
AllianceRequest,
|
||||
AllianceRequestReply,
|
||||
BrokeAlliance,
|
||||
AllianceExpired,
|
||||
TargetPlayer,
|
||||
EmojiUpdate,
|
||||
WinUpdate
|
||||
}
|
||||
|
||||
export interface NameViewData {
|
||||
x: number,
|
||||
y: number,
|
||||
size: number,
|
||||
}
|
||||
|
||||
export interface PlayerActions {
|
||||
canBoat: boolean
|
||||
canAttack: boolean
|
||||
@@ -368,89 +349,6 @@ export interface PlayerInteraction {
|
||||
canDonate: boolean
|
||||
}
|
||||
|
||||
export type GameUpdate = TileUpdateWrapper
|
||||
| UnitUpdate
|
||||
| PlayerUpdate
|
||||
| AllianceRequestUpdate
|
||||
| AllianceRequestReplyUpdate
|
||||
| BrokeAllianceUpdate
|
||||
| AllianceExpiredUpdate
|
||||
| DisplayMessageUpdate
|
||||
| TargetPlayerUpdate
|
||||
| EmojiUpdate
|
||||
| WinUpdate
|
||||
|
||||
export interface TileUpdateWrapper {
|
||||
type: GameUpdateType.Tile,
|
||||
update: TileUpdate
|
||||
}
|
||||
|
||||
export interface UnitUpdate {
|
||||
type: GameUpdateType.Unit
|
||||
unitType: UnitType
|
||||
troops: number
|
||||
id: number
|
||||
ownerID: number
|
||||
pos: MapPos
|
||||
lastPos: MapPos
|
||||
isActive: boolean
|
||||
health?: number
|
||||
}
|
||||
|
||||
export interface PlayerUpdate {
|
||||
type: GameUpdateType.Player
|
||||
nameViewData?: NameViewData,
|
||||
clientID: ClientID,
|
||||
name: string,
|
||||
displayName: string,
|
||||
id: PlayerID,
|
||||
smallID: number,
|
||||
playerType: PlayerType,
|
||||
isAlive: boolean,
|
||||
tilesOwned: number,
|
||||
gold: number,
|
||||
population: number,
|
||||
workers: number,
|
||||
troops: number,
|
||||
targetTroopRatio: number
|
||||
allies: number[]
|
||||
isTraitor: boolean
|
||||
targets: number[]
|
||||
outgoingEmojis: EmojiMessage[]
|
||||
}
|
||||
|
||||
|
||||
export interface AllianceRequestUpdate {
|
||||
type: GameUpdateType.AllianceRequest
|
||||
requestorID: number,
|
||||
recipientID: number,
|
||||
createdAt: Tick,
|
||||
}
|
||||
|
||||
export interface AllianceRequestReplyUpdate {
|
||||
type: GameUpdateType.AllianceRequestReply
|
||||
request: AllianceRequestUpdate
|
||||
accepted: boolean
|
||||
}
|
||||
|
||||
export interface BrokeAllianceUpdate {
|
||||
type: GameUpdateType.BrokeAlliance
|
||||
traitorID: number
|
||||
betrayedID: number
|
||||
}
|
||||
|
||||
export interface AllianceExpiredUpdate {
|
||||
type: GameUpdateType.AllianceExpired
|
||||
player1ID: number
|
||||
player2ID: number
|
||||
}
|
||||
|
||||
export interface TargetPlayerUpdate {
|
||||
type: GameUpdateType.TargetPlayer
|
||||
playerID: number
|
||||
targetID: number
|
||||
}
|
||||
|
||||
export interface EmojiMessage {
|
||||
message: string
|
||||
senderID: number
|
||||
@@ -458,23 +356,6 @@ export interface EmojiMessage {
|
||||
createdAt: Tick
|
||||
}
|
||||
|
||||
export interface EmojiUpdate {
|
||||
type: GameUpdateType.EmojiUpdate
|
||||
emoji: EmojiMessage
|
||||
}
|
||||
|
||||
export interface DisplayMessageUpdate {
|
||||
type: GameUpdateType.DisplayEvent
|
||||
message: string
|
||||
messageType: MessageType
|
||||
playerID: number | null
|
||||
}
|
||||
|
||||
export interface WinUpdate {
|
||||
type: GameUpdateType.WinUpdate
|
||||
winnerID: number,
|
||||
}
|
||||
|
||||
export enum MessageType {
|
||||
SUCCESS,
|
||||
INFO,
|
||||
@@ -482,3 +363,9 @@ export enum MessageType {
|
||||
ERROR
|
||||
}
|
||||
|
||||
export interface NameViewData {
|
||||
x: number;
|
||||
y: number;
|
||||
size: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Config } from "../configuration/Config";
|
||||
import { Cell, Execution, Game, PlayerID, PlayerInfo, Player, TerraNullius, Unit, AllianceRequest, Alliance, Nation, UnitType, UnitInfo, DefenseBonus, GameUpdate, GameUpdateType, AllPlayers, GameUpdates, TerrainType, EmojiMessage } from "./Game";
|
||||
import { Cell, Execution, Game, PlayerID, PlayerInfo, Player, TerraNullius, Unit, AllianceRequest, Alliance, Nation, UnitType, UnitInfo, DefenseBonus, AllPlayers, GameUpdates, TerrainType, EmojiMessage } from "./Game";
|
||||
import { GameUpdate } from "./GameUpdates";
|
||||
import { GameUpdateType } from "./GameUpdates";
|
||||
import { NationMap } from "./TerrainMapLoader";
|
||||
import { PlayerImpl } from "./PlayerImpl";
|
||||
import { TerraNulliusImpl } from "./TerraNulliusImpl";
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
import { ClientID } from '../Schemas';
|
||||
import { EmojiMessage, GameUpdates, MapPos, MessageType, NameViewData, PlayerID, PlayerType, Tick, UnitType } from './Game';
|
||||
import { TileUpdate } from './GameMap';
|
||||
|
||||
|
||||
export interface GameUpdateViewData {
|
||||
tick: number;
|
||||
updates: GameUpdates;
|
||||
packedTileUpdates: BigUint64Array;
|
||||
playerNameViewData: Record<number, NameViewData>;
|
||||
}
|
||||
|
||||
export enum GameUpdateType {
|
||||
Tile,
|
||||
Unit,
|
||||
Player,
|
||||
DisplayEvent,
|
||||
AllianceRequest,
|
||||
AllianceRequestReply,
|
||||
BrokeAlliance,
|
||||
AllianceExpired,
|
||||
TargetPlayer,
|
||||
EmojiUpdate,
|
||||
WinUpdate
|
||||
}
|
||||
|
||||
export type GameUpdate = TileUpdateWrapper |
|
||||
UnitUpdate |
|
||||
PlayerUpdate |
|
||||
AllianceRequestUpdate |
|
||||
AllianceRequestReplyUpdate |
|
||||
BrokeAllianceUpdate |
|
||||
AllianceExpiredUpdate |
|
||||
DisplayMessageUpdate |
|
||||
TargetPlayerUpdate |
|
||||
EmojiUpdate |
|
||||
WinUpdate
|
||||
|
||||
export interface TileUpdateWrapper {
|
||||
type: GameUpdateType.Tile
|
||||
update: TileUpdate
|
||||
}
|
||||
|
||||
export interface UnitUpdate {
|
||||
type: GameUpdateType.Unit
|
||||
unitType: UnitType
|
||||
troops: number
|
||||
id: number
|
||||
ownerID: number
|
||||
pos: MapPos
|
||||
lastPos: MapPos
|
||||
isActive: boolean
|
||||
health?: number
|
||||
}
|
||||
|
||||
export interface PlayerUpdate {
|
||||
type: GameUpdateType.Player
|
||||
nameViewData?: NameViewData
|
||||
clientID: ClientID
|
||||
name: string
|
||||
displayName: string
|
||||
id: PlayerID
|
||||
smallID: number
|
||||
playerType: PlayerType
|
||||
isAlive: boolean
|
||||
tilesOwned: number
|
||||
gold: number
|
||||
population: number
|
||||
workers: number
|
||||
troops: number
|
||||
targetTroopRatio: number
|
||||
allies: number[]
|
||||
isTraitor: boolean
|
||||
targets: number[]
|
||||
outgoingEmojis: EmojiMessage[]
|
||||
}
|
||||
|
||||
export interface AllianceRequestUpdate {
|
||||
type: GameUpdateType.AllianceRequest
|
||||
requestorID: number
|
||||
recipientID: number
|
||||
createdAt: Tick
|
||||
}
|
||||
|
||||
export interface AllianceRequestReplyUpdate {
|
||||
type: GameUpdateType.AllianceRequestReply
|
||||
request: AllianceRequestUpdate
|
||||
accepted: boolean
|
||||
}
|
||||
|
||||
export interface BrokeAllianceUpdate {
|
||||
type: GameUpdateType.BrokeAlliance
|
||||
traitorID: number
|
||||
betrayedID: number
|
||||
}
|
||||
|
||||
export interface AllianceExpiredUpdate {
|
||||
type: GameUpdateType.AllianceExpired
|
||||
player1ID: number
|
||||
player2ID: number
|
||||
}
|
||||
|
||||
export interface TargetPlayerUpdate {
|
||||
type: GameUpdateType.TargetPlayer
|
||||
playerID: number
|
||||
targetID: number
|
||||
}
|
||||
|
||||
export interface EmojiUpdate {
|
||||
type: GameUpdateType.EmojiUpdate
|
||||
emoji: EmojiMessage
|
||||
}
|
||||
|
||||
export interface DisplayMessageUpdate {
|
||||
type: GameUpdateType.DisplayEvent
|
||||
message: string
|
||||
messageType: MessageType
|
||||
playerID: number | null
|
||||
}
|
||||
|
||||
export interface WinUpdate {
|
||||
type: GameUpdateType.WinUpdate
|
||||
winnerID: number
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import { GameUpdates, GameUpdateType, MapPos, MessageType, NameViewData, Player, PlayerActions, PlayerProfile, PlayerUpdate, Unit, UnitUpdate } from './game/Game';
|
||||
import { Config } from "./configuration/Config";
|
||||
import { Alliance, AllianceRequest, AllPlayers, Cell, DefenseBonus, EmojiMessage, Game, Gold, Nation, PlayerID, PlayerInfo, PlayerType, Relation, TerrainType, TerraNullius, Tick, UnitInfo, UnitType } from "./game/Game";
|
||||
import { ClientID } from "./Schemas";
|
||||
import { TerraNulliusImpl } from './game/TerraNulliusImpl';
|
||||
import { WorkerClient } from './worker/WorkerClient';
|
||||
import { GameMap, GameMapImpl, TileRef, TileUpdate } from './game/GameMap';
|
||||
import { GameUpdates, MapPos, MessageType, Player, PlayerActions, PlayerProfile, Unit } from './Game';
|
||||
import { PlayerUpdate } from "./GameUpdates";
|
||||
import { UnitUpdate } from "./GameUpdates";
|
||||
import { NameViewData } from './Game';
|
||||
import { GameUpdateType } from "./GameUpdates";
|
||||
import { Config } from "../configuration/Config";
|
||||
import { Alliance, AllianceRequest, AllPlayers, Cell, DefenseBonus, EmojiMessage, Game, Gold, Nation, PlayerID, PlayerInfo, PlayerType, Relation, TerrainType, TerraNullius, Tick, UnitInfo, UnitType } from "./Game";
|
||||
import { ClientID } from "../Schemas";
|
||||
import { TerraNulliusImpl } from './TerraNulliusImpl';
|
||||
import { WorkerClient } from '../worker/WorkerClient';
|
||||
import { GameMap, GameMapImpl, TileRef, TileUpdate } from './GameMap';
|
||||
import { GameUpdateViewData } from './GameUpdates';
|
||||
|
||||
export class UnitView {
|
||||
public _wasUpdated = true
|
||||
@@ -150,13 +155,6 @@ export class PlayerView {
|
||||
}
|
||||
}
|
||||
|
||||
export interface GameUpdateViewData {
|
||||
tick: number
|
||||
updates: GameUpdates
|
||||
packedTileUpdates: BigUint64Array
|
||||
playerNameViewData: Record<number, NameViewData>
|
||||
}
|
||||
|
||||
export class GameView implements GameMap {
|
||||
private lastUpdate: GameUpdateViewData
|
||||
private smallIDToID = new Map<number, PlayerID>()
|
||||
@@ -1,4 +1,6 @@
|
||||
import { Player, PlayerInfo, PlayerID, PlayerType, TerraNullius, Cell, Execution, AllianceRequest, MutableAlliance, Alliance, Tick, AllPlayers, Gold, UnitType, Unit, Relation, PlayerUpdate, GameUpdateType, EmojiMessage } from "./Game";
|
||||
import { Player, PlayerInfo, PlayerID, PlayerType, TerraNullius, Cell, Execution, AllianceRequest, MutableAlliance, Alliance, Tick, AllPlayers, Gold, UnitType, Unit, Relation, EmojiMessage } from "./Game";
|
||||
import { PlayerUpdate } from "./GameUpdates";
|
||||
import { GameUpdateType } from "./GameUpdates";
|
||||
import { ClientID } from "../Schemas";
|
||||
import { assertNever, closestOceanShoreFromPlayer, distSortUnit, simpleHash, sourceDstOceanShore, within } from "../Util";
|
||||
import { CellString, GameImpl } from "./GameImpl";
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { GameUpdateType, MessageType, UnitUpdate } from './Game';
|
||||
import { MessageType } from './Game';
|
||||
import { UnitUpdate } from "./GameUpdates";
|
||||
import { GameUpdateType } from "./GameUpdates";
|
||||
import { simpleHash, within } from "../Util";
|
||||
import { Unit, TerraNullius, UnitType, Player, UnitInfo } from "./Game";
|
||||
import { GameImpl } from "./GameImpl";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createGameRunner, GameRunner } from "../GameRunner";
|
||||
import { GameUpdateViewData } from "../GameView";
|
||||
import { GameUpdateViewData } from '../game/GameUpdates';
|
||||
import {
|
||||
MainThreadMessage,
|
||||
WorkerMessage,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PlayerActions, PlayerID, PlayerInfo, PlayerProfile } from "../game/Game";
|
||||
import { GameUpdateViewData } from "../GameView";
|
||||
import { GameUpdateViewData } from '../game/GameUpdates';
|
||||
import { GameConfig, GameID, Turn } from "../Schemas";
|
||||
import { generateID } from "../Util";
|
||||
import { WorkerMessage } from "./WorkerMessages";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { GameUpdateViewData } from "../GameView";
|
||||
import { GameUpdateViewData } from '../game/GameUpdates';
|
||||
import { GameConfig, GameID, Turn } from "../Schemas";
|
||||
import { PlayerActions, PlayerID, PlayerProfile } from "../game/Game";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user