mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 08:38:10 +00:00
Prefer z.literal(true).optional() over z.boolean()
This commit is contained in:
@@ -531,11 +531,11 @@ export class HostLobbyModal extends LitElement {
|
||||
body: JSON.stringify({
|
||||
gameMap: this.selectedMap,
|
||||
difficulty: this.selectedDifficulty,
|
||||
disableNPCs: this.disableNPCs,
|
||||
disableNPCs: this.disableNPCs ? true : undefined,
|
||||
bots: this.bots,
|
||||
infiniteGold: this.infiniteGold,
|
||||
infiniteTroops: this.infiniteTroops,
|
||||
instantBuild: this.instantBuild,
|
||||
infiniteGold: this.infiniteGold ? true : undefined,
|
||||
infiniteTroops: this.infiniteTroops ? true : undefined,
|
||||
instantBuild: this.instantBuild ? true : undefined,
|
||||
gameMode: this.gameMode,
|
||||
disabledUnits: this.disabledUnits,
|
||||
playerTeams: this.teamCount,
|
||||
|
||||
@@ -450,11 +450,11 @@ export class SinglePlayerModal extends LitElement {
|
||||
gameMode: this.gameMode,
|
||||
playerTeams: this.teamCount,
|
||||
difficulty: this.selectedDifficulty,
|
||||
disableNPCs: this.disableNPCs,
|
||||
disableNPCs: this.disableNPCs ? true : undefined,
|
||||
bots: this.bots,
|
||||
infiniteGold: this.infiniteGold,
|
||||
infiniteTroops: this.infiniteTroops,
|
||||
instantBuild: this.instantBuild,
|
||||
infiniteGold: this.infiniteGold ? true : undefined,
|
||||
infiniteTroops: this.infiniteTroops ? true : undefined,
|
||||
instantBuild: this.instantBuild ? true : undefined,
|
||||
disabledUnits: this.disabledUnits
|
||||
.map((u) => Object.values(UnitType).find((ut) => ut === u))
|
||||
.filter((ut): ut is UnitType => ut !== undefined),
|
||||
|
||||
@@ -398,7 +398,7 @@ export class Transport {
|
||||
type: "allianceRequestReply",
|
||||
clientID: this.lobbyConfig.clientID,
|
||||
requestor: event.requestor.id(),
|
||||
accept: event.accepted,
|
||||
accept: event.accepted ? true : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -117,11 +117,11 @@ const GameConfigSchema = z.object({
|
||||
difficulty: z.nativeEnum(Difficulty),
|
||||
gameType: z.nativeEnum(GameType),
|
||||
gameMode: z.nativeEnum(GameMode),
|
||||
disableNPCs: z.boolean(),
|
||||
disableNPCs: z.literal(true).optional(),
|
||||
bots: z.number().int().min(0).max(400),
|
||||
infiniteGold: z.boolean(),
|
||||
infiniteTroops: z.boolean(),
|
||||
instantBuild: z.boolean(),
|
||||
infiniteGold: z.literal(true).optional(),
|
||||
infiniteTroops: z.literal(true).optional(),
|
||||
instantBuild: z.literal(true).optional(),
|
||||
maxPlayers: z.number().optional(),
|
||||
disabledUnits: z.array(z.nativeEnum(UnitType)).optional(),
|
||||
playerTeams: z.union([z.number().optional(), z.literal(Duos)]),
|
||||
@@ -227,7 +227,7 @@ export const AllianceRequestIntentSchema = BaseIntentSchema.extend({
|
||||
export const AllianceRequestReplyIntentSchema = BaseIntentSchema.extend({
|
||||
type: z.literal("allianceRequestReply"),
|
||||
requestor: ID, // The one who made the original alliance request
|
||||
accept: z.boolean(),
|
||||
accept: z.literal(true).optional(),
|
||||
});
|
||||
|
||||
export const BreakAllianceIntentSchema = BaseIntentSchema.extend({
|
||||
|
||||
@@ -263,13 +263,13 @@ export class DefaultConfig implements Config {
|
||||
return this._gameConfig.bots;
|
||||
}
|
||||
instantBuild(): boolean {
|
||||
return this._gameConfig.instantBuild;
|
||||
return this._gameConfig.instantBuild ?? false;
|
||||
}
|
||||
infiniteGold(): boolean {
|
||||
return this._gameConfig.infiniteGold;
|
||||
return this._gameConfig.infiniteGold ?? false;
|
||||
}
|
||||
infiniteTroops(): boolean {
|
||||
return this._gameConfig.infiniteTroops;
|
||||
return this._gameConfig.infiniteTroops ?? false;
|
||||
}
|
||||
tradeShipGold(dist: number): Gold {
|
||||
return 10000 + 150 * Math.pow(dist, 1.1);
|
||||
|
||||
@@ -87,7 +87,7 @@ export class Executor {
|
||||
return new AllianceRequestReplyExecution(
|
||||
intent.requestor,
|
||||
playerID,
|
||||
intent.accept,
|
||||
intent.accept ?? false,
|
||||
);
|
||||
case "breakAlliance":
|
||||
return new BreakAllianceExecution(playerID, intent.recipient);
|
||||
|
||||
@@ -33,10 +33,6 @@ export class GameManager {
|
||||
gameMap: GameMapType.World,
|
||||
gameType: GameType.Private,
|
||||
difficulty: Difficulty.Medium,
|
||||
disableNPCs: false,
|
||||
infiniteGold: false,
|
||||
infiniteTroops: false,
|
||||
instantBuild: false,
|
||||
gameMode: GameMode.FFA,
|
||||
bots: 400,
|
||||
disabledUnits: [],
|
||||
|
||||
@@ -54,11 +54,7 @@ export class MapPlaylist {
|
||||
maxPlayers: config.lobbyMaxPlayers(map, mode),
|
||||
gameType: GameType.Public,
|
||||
difficulty: Difficulty.Medium,
|
||||
infiniteGold: false,
|
||||
infiniteTroops: false,
|
||||
instantBuild: false,
|
||||
disableNPCs: mode === GameMode.Team,
|
||||
disableNukes: false,
|
||||
gameMode: mode,
|
||||
playerTeams: numPlayerTeams,
|
||||
bots: 400,
|
||||
|
||||
@@ -41,11 +41,7 @@ export async function setup(
|
||||
gameMode: GameMode.FFA,
|
||||
gameType: GameType.Singleplayer,
|
||||
difficulty: Difficulty.Medium,
|
||||
disableNPCs: false,
|
||||
bots: 0,
|
||||
infiniteGold: false,
|
||||
infiniteTroops: false,
|
||||
instantBuild: false,
|
||||
..._gameConfig,
|
||||
};
|
||||
const config = new TestConfig(
|
||||
|
||||
Reference in New Issue
Block a user