mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-18 17:53:29 +00:00
Added flags
This commit is contained in:
@@ -139,6 +139,7 @@ export const AttackIntentSchema = BaseIntentSchema.extend({
|
||||
});
|
||||
|
||||
export const SpawnIntentSchema = BaseIntentSchema.extend({
|
||||
flag: z.string().nullable(),
|
||||
type: z.literal("spawn"),
|
||||
playerID: ID,
|
||||
name: SafeString,
|
||||
|
||||
@@ -37,9 +37,9 @@ export class DevConfig extends DefaultConfig {
|
||||
// return 1
|
||||
// }
|
||||
|
||||
// populationIncreaseRate(player: Player): number {
|
||||
// return this.maxPopulation(player)
|
||||
// }
|
||||
populationIncreaseRate(player: Player): number {
|
||||
return this.maxPopulation(player)
|
||||
}
|
||||
|
||||
// boatMaxDistance(): number {
|
||||
// return 5000
|
||||
|
||||
@@ -64,6 +64,7 @@ export class Executor {
|
||||
case "spawn":
|
||||
return new SpawnExecution(
|
||||
new PlayerInfo(
|
||||
intent.flag,
|
||||
// Players see their original name, others see a sanitized version
|
||||
intent.clientID == this.clientID
|
||||
? sanitize(intent.name)
|
||||
@@ -131,6 +132,7 @@ export class Executor {
|
||||
new FakeHumanExecution(
|
||||
this.gameID,
|
||||
new PlayerInfo(
|
||||
nation.flag || "",
|
||||
nation.name,
|
||||
PlayerType.FakeHuman,
|
||||
null,
|
||||
|
||||
@@ -86,6 +86,7 @@ export enum Relation {
|
||||
|
||||
export class Nation {
|
||||
constructor(
|
||||
public readonly flag: string,
|
||||
public readonly name: string,
|
||||
public readonly cell: Cell,
|
||||
public readonly strength: number
|
||||
@@ -168,6 +169,7 @@ export interface MutableAlliance extends Alliance {
|
||||
|
||||
export class PlayerInfo {
|
||||
constructor(
|
||||
public readonly flag: string,
|
||||
public readonly name: string,
|
||||
public readonly playerType: PlayerType,
|
||||
// null if bot.
|
||||
|
||||
@@ -78,6 +78,7 @@ export class GameImpl implements Game {
|
||||
this.nations_ = nationMap.nations.map(
|
||||
(n) =>
|
||||
new Nation(
|
||||
n.flag || "",
|
||||
n.name,
|
||||
new Cell(n.coordinates[0], n.coordinates[1]),
|
||||
n.strength
|
||||
|
||||
@@ -80,6 +80,7 @@ export interface PlayerUpdate {
|
||||
type: GameUpdateType.Player;
|
||||
nameViewData?: NameViewData;
|
||||
clientID: ClientID;
|
||||
flag: string,
|
||||
name: string;
|
||||
displayName: string;
|
||||
id: PlayerID;
|
||||
|
||||
@@ -127,6 +127,9 @@ export class PlayerView {
|
||||
smallID(): number {
|
||||
return this.data.smallID;
|
||||
}
|
||||
flag(): string {
|
||||
return this.data.flag;
|
||||
}
|
||||
name(): string {
|
||||
return this.data.name;
|
||||
}
|
||||
@@ -196,7 +199,7 @@ export class PlayerView {
|
||||
return this.data.outgoingEmojis;
|
||||
}
|
||||
info(): PlayerInfo {
|
||||
return new PlayerInfo(this.name(), this.type(), this.clientID(), this.id());
|
||||
return new PlayerInfo(this.flag(), this.name(), this.type(), this.clientID(), this.id());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ export class PlayerImpl implements Player {
|
||||
public _units: UnitImpl[] = [];
|
||||
public _tiles: Set<TileRef> = new Set();
|
||||
|
||||
private _flag: string;
|
||||
private _name: string;
|
||||
private _displayName: string;
|
||||
|
||||
@@ -86,6 +87,7 @@ export class PlayerImpl implements Player {
|
||||
private readonly playerInfo: PlayerInfo,
|
||||
startPopulation: number
|
||||
) {
|
||||
this._flag = playerInfo.flag;
|
||||
this._name = playerInfo.name;
|
||||
this._targetTroopRatio = 1;
|
||||
this._troops = startPopulation * this._targetTroopRatio;
|
||||
@@ -100,6 +102,7 @@ export class PlayerImpl implements Player {
|
||||
return {
|
||||
type: GameUpdateType.Player,
|
||||
clientID: this.clientID(),
|
||||
flag: this.flag(),
|
||||
name: this.name(),
|
||||
displayName: this.displayName(),
|
||||
id: this.id(),
|
||||
@@ -139,6 +142,10 @@ export class PlayerImpl implements Player {
|
||||
return this._smallID;
|
||||
}
|
||||
|
||||
flag(): string {
|
||||
return this._flag;
|
||||
}
|
||||
|
||||
name(): string {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ export interface NationMap {
|
||||
|
||||
export interface Nation {
|
||||
coordinates: [number, number];
|
||||
flag: string;
|
||||
name: string;
|
||||
strength: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user