mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-21 11:58:42 +00:00
test
This commit is contained in:
@@ -38,6 +38,7 @@ export async function createGameRunner(
|
||||
gameStart.players.map(
|
||||
(p) =>
|
||||
new PlayerInfo(
|
||||
p.pattern,
|
||||
p.flag,
|
||||
p.clientID == clientID
|
||||
? sanitize(p.username)
|
||||
|
||||
@@ -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([
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ export class Executor {
|
||||
new FakeHumanExecution(
|
||||
this.gameID,
|
||||
new PlayerInfo(
|
||||
null,
|
||||
nation.flag || "",
|
||||
nation.name,
|
||||
PlayerType.FakeHuman,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -88,6 +88,7 @@ export interface PlayerUpdate {
|
||||
type: GameUpdateType.Player;
|
||||
nameViewData?: NameViewData;
|
||||
clientID: ClientID;
|
||||
pattern: string;
|
||||
flag: string;
|
||||
name: string;
|
||||
displayName: string;
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user