mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-22 12:30:22 +00:00
* deleted old maps
* fixed bug where NPC and Bots had same id * NPCs spawn near IRL location * NPCs have different strength (starting troops) * game has more NPCs than before * Needs more balancing
This commit is contained in:
@@ -11,6 +11,14 @@ export type Tick = number
|
||||
|
||||
export const AllPlayers = "AllPlayers" as const;
|
||||
|
||||
export class Nation {
|
||||
constructor(
|
||||
public readonly name: string,
|
||||
public readonly cell: Cell,
|
||||
public readonly strength: number,
|
||||
) { }
|
||||
}
|
||||
|
||||
export class EmojiMessage {
|
||||
constructor(
|
||||
public readonly sender: Player,
|
||||
@@ -217,6 +225,7 @@ export interface Game {
|
||||
ticks(): Tick
|
||||
inSpawnPhase(): boolean
|
||||
addExecution(...exec: Execution[]): void
|
||||
nations(): Nation[]
|
||||
config(): Config
|
||||
displayMessage(message: string, type: MessageType, playerID: PlayerID | null): void
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {info} from "console";
|
||||
import {Config} from "../configuration/Config";
|
||||
import {EventBus} from "../EventBus";
|
||||
import {Cell, Execution, MutableGame, Game, MutablePlayer, PlayerEvent, PlayerID, PlayerInfo, Player, TerraNullius, Tile, TileEvent, Boat, BoatEvent, PlayerType, MutableAllianceRequest, AllianceRequestReplyEvent, AllianceRequestEvent, BrokeAllianceEvent, MutableAlliance, Alliance, AllianceExpiredEvent} from "./Game";
|
||||
import {Cell, Execution, MutableGame, Game, MutablePlayer, PlayerEvent, PlayerID, PlayerInfo, Player, TerraNullius, Tile, TileEvent, Boat, BoatEvent, PlayerType, MutableAllianceRequest, AllianceRequestReplyEvent, AllianceRequestEvent, BrokeAllianceEvent, MutableAlliance, Alliance, AllianceExpiredEvent, Nation} from "./Game";
|
||||
import {TerrainMap} from "./TerrainMapLoader";
|
||||
import {PlayerImpl} from "./PlayerImpl";
|
||||
import {TerraNulliusImpl} from "./TerraNulliusImpl";
|
||||
@@ -24,6 +24,9 @@ export class GameImpl implements MutableGame {
|
||||
|
||||
// idCounter: PlayerID = 1; // Zero reserved for TerraNullius
|
||||
map: TileImpl[][]
|
||||
|
||||
private nations_: Nation[] = []
|
||||
|
||||
_players: Map<PlayerID, PlayerImpl> = new Map<PlayerID, PlayerImpl>
|
||||
private execs: Execution[] = []
|
||||
private _width: number
|
||||
@@ -47,6 +50,15 @@ export class GameImpl implements MutableGame {
|
||||
this.map[x][y] = new TileImpl(this, this._terraNullius, cell, terrainMap.terrain(cell));
|
||||
}
|
||||
}
|
||||
this.nations_ = terrainMap.nationMap.nations
|
||||
.map(n => new Nation(
|
||||
n.name,
|
||||
new Cell(n.coordinates[0], n.coordinates[1]),
|
||||
n.strength
|
||||
))
|
||||
}
|
||||
nations(): Nation[] {
|
||||
return this.nations_
|
||||
}
|
||||
|
||||
createAllianceRequest(requestor: MutablePlayer, recipient: Player): MutableAllianceRequest {
|
||||
|
||||
@@ -1,8 +1,27 @@
|
||||
import {Cell, TerrainType} from './Game';
|
||||
import binAsString from "!!binary-loader!../../../resources/maps/WorldMap.bin";
|
||||
import worldMapInfo from "../../../resources/maps/WorldMap.json"
|
||||
|
||||
export interface NationMap {
|
||||
name: string;
|
||||
width: number;
|
||||
height: number;
|
||||
nations: Nation[];
|
||||
}
|
||||
|
||||
export interface Nation {
|
||||
coordinates: [number, number];
|
||||
name: string;
|
||||
strength: number;
|
||||
}
|
||||
|
||||
|
||||
export class TerrainMap {
|
||||
constructor(public readonly tiles: Terrain[][], public readonly numLandTiles: number) { }
|
||||
constructor(
|
||||
public readonly tiles: Terrain[][],
|
||||
public readonly numLandTiles: number,
|
||||
public readonly nationMap: NationMap
|
||||
) { }
|
||||
|
||||
terrain(cell: Cell): Terrain {
|
||||
return this.tiles[cell.x][cell.y]
|
||||
@@ -84,7 +103,7 @@ export async function loadTerrainMap(): Promise<TerrainMap> {
|
||||
}
|
||||
}
|
||||
|
||||
return new TerrainMap(terrain, numLand);
|
||||
return new TerrainMap(terrain, numLand, worldMapInfo);
|
||||
}
|
||||
|
||||
function logBinaryAsAscii(data: string, length: number = 8) {
|
||||
|
||||
Reference in New Issue
Block a user