Added flags

This commit is contained in:
NewHappyRabbit
2025-02-11 23:34:19 +02:00
parent b8a743e745
commit 949f68287e
17 changed files with 255 additions and 352 deletions
+1
View File
@@ -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,
+3 -3
View File
@@ -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
+2
View File
@@ -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,
+2
View File
@@ -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.
+1
View File
@@ -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
+1
View File
@@ -80,6 +80,7 @@ export interface PlayerUpdate {
type: GameUpdateType.Player;
nameViewData?: NameViewData;
clientID: ClientID;
flag: string,
name: string;
displayName: string;
id: PlayerID;
+4 -1
View File
@@ -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());
}
}
+7
View File
@@ -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;
}
+1
View File
@@ -17,6 +17,7 @@ export interface NationMap {
export interface Nation {
coordinates: [number, number];
flag: string;
name: string;
strength: number;
}