This commit is contained in:
Aotumuri
2025-04-26 13:50:02 +09:00
parent 1f890396ab
commit fab63c73bf
20 changed files with 128 additions and 8 deletions
+1
View File
@@ -38,6 +38,7 @@ export async function createGameRunner(
gameStart.players.map(
(p) =>
new PlayerInfo(
p.pattern,
p.flag,
p.clientID == clientID
? sanitize(p.username)
+3
View File
@@ -185,6 +185,7 @@ export const AttackIntentSchema = BaseIntentSchema.extend({
export const SpawnIntentSchema = BaseIntentSchema.extend({
flag: z.string().nullable(),
pattern: z.string().nullable(),
type: z.literal("spawn"),
name: SafeString,
playerType: PlayerTypeSchema,
@@ -321,6 +322,7 @@ export const PlayerSchema = z.object({
clientID: ID,
username: SafeString,
flag: SafeString.optional(),
pattern: SafeString.optional(),
});
export const GameStartInfoSchema = z.object({
@@ -397,6 +399,7 @@ export const ClientJoinMessageSchema = ClientBaseMessageSchema.extend({
lastTurn: z.number(), // The last turn the client saw.
username: SafeString,
flag: SafeString.nullable().optional(),
pattern: SafeString.nullable().optional(),
});
export const ClientMessageSchema = z.union([
+8 -1
View File
@@ -47,7 +47,14 @@ export class BotSpawner {
}
}
return new SpawnExecution(
new PlayerInfo("", botName, PlayerType.Bot, null, this.random.nextID()),
new PlayerInfo(
null,
"",
botName,
PlayerType.Bot,
null,
this.random.nextID(),
),
tile,
);
}
+1
View File
@@ -124,6 +124,7 @@ export class Executor {
new FakeHumanExecution(
this.gameID,
new PlayerInfo(
null,
nation.flag || "",
nation.name,
PlayerType.FakeHuman,
+1
View File
@@ -242,6 +242,7 @@ export class PlayerInfo {
public readonly clan: string | null;
constructor(
public readonly pattern: string,
public readonly flag: string,
public readonly name: string,
public readonly playerType: PlayerType,
+1
View File
@@ -88,6 +88,7 @@ export interface PlayerUpdate {
type: GameUpdateType.Player;
nameViewData?: NameViewData;
clientID: ClientID;
pattern: string;
flag: string;
name: string;
displayName: string;
+6
View File
@@ -177,6 +177,11 @@ export class PlayerView {
flag(): string {
return this.data.flag;
}
pattern(): string {
return this.data.pattern;
}
name(): string {
return userSettings.anonymousNames() && this.anonymousName !== null
? this.anonymousName
@@ -275,6 +280,7 @@ export class PlayerView {
}
info(): PlayerInfo {
return new PlayerInfo(
this.pattern(),
this.flag(),
this.name(),
this.type(),
+7
View File
@@ -80,6 +80,7 @@ export class PlayerImpl implements Player {
public _units: UnitImpl[] = [];
public _tiles: Set<TileRef> = new Set();
private _pattern: string;
private _flag: string;
private _name: string;
private _displayName: string;
@@ -107,6 +108,7 @@ export class PlayerImpl implements Player {
startTroops: number,
private readonly _team: Team | null,
) {
this._pattern = playerInfo.pattern;
this._flag = playerInfo.flag;
this._name = sanitizeUsername(playerInfo.name);
this._targetTroopRatio = 95n;
@@ -127,6 +129,7 @@ export class PlayerImpl implements Player {
return {
type: GameUpdateType.Player,
clientID: this.clientID(),
pattern: this.pattern(),
flag: this.flag(),
name: this.name(),
displayName: this.displayName(),
@@ -176,6 +179,10 @@ export class PlayerImpl implements Player {
return this._smallID;
}
pattern(): string {
return this._pattern;
}
flag(): string {
return this._flag;
}