mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-30 16:12:26 +00:00
Option to disable alliances + 2 new modifiers for variety 😄 (#3392)
## Description:
Rex had this idea: "It would be funny to have an option in private
lobbies to disable alliances."
I added it as an option.
Now people can choose to live in constant fear of their neighbors 😆
Also added two new public game modifiers for variety (only for the
special rotation):
- Alliances disabled (low probability)
- x2 gold multiplier (low probability)
Would be nice to squeeze this into v30, last minute?
## Please complete the following:
- [X] I have added screenshots for all UI updates
- [X] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [X] I have added relevant tests to the test directory
- [X] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
## Please put your Discord username so you can be contacted if a bug or
regression is found:
FloPinguin
This commit is contained in:
@@ -71,6 +71,7 @@ export class HostLobbyModal extends BaseModal {
|
||||
@state() private goldMultiplierValue: number | undefined = undefined;
|
||||
@state() private startingGold: boolean = false;
|
||||
@state() private startingGoldValue: number | undefined = undefined;
|
||||
@state() private disableAlliances: boolean = false;
|
||||
@state() private lobbyId = "";
|
||||
@state() private lobbyUrlSuffix = "";
|
||||
@state() private clients: ClientInfo[] = [];
|
||||
@@ -174,16 +175,16 @@ export class HostLobbyModal extends BaseModal {
|
||||
.onKeyDown=${this.handleSpawnImmunityDurationKeyDown}
|
||||
></toggle-input-card>`,
|
||||
html`<toggle-input-card
|
||||
.labelKey=${"single_modal.gold_multiplier"}
|
||||
.labelKey=${"host_modal.gold_multiplier"}
|
||||
.checked=${this.goldMultiplier}
|
||||
.inputId=${"gold-multiplier-value"}
|
||||
.inputMin=${0.1}
|
||||
.inputMax=${1000}
|
||||
.inputStep=${"any"}
|
||||
.inputValue=${this.goldMultiplierValue}
|
||||
.inputAriaLabel=${translateText("single_modal.gold_multiplier")}
|
||||
.inputAriaLabel=${translateText("host_modal.gold_multiplier")}
|
||||
.inputPlaceholder=${translateText(
|
||||
"single_modal.gold_multiplier_placeholder",
|
||||
"host_modal.gold_multiplier_placeholder",
|
||||
)}
|
||||
.defaultInputValue=${2}
|
||||
.minValidOnEnable=${0.1}
|
||||
@@ -192,16 +193,16 @@ export class HostLobbyModal extends BaseModal {
|
||||
.onKeyDown=${this.handleGoldMultiplierValueKeyDown}
|
||||
></toggle-input-card>`,
|
||||
html`<toggle-input-card
|
||||
.labelKey=${"single_modal.starting_gold"}
|
||||
.labelKey=${"host_modal.starting_gold"}
|
||||
.checked=${this.startingGold}
|
||||
.inputId=${"starting-gold-value"}
|
||||
.inputMin=${0.1}
|
||||
.inputMax=${1000}
|
||||
.inputStep=${"any"}
|
||||
.inputValue=${this.startingGoldValue}
|
||||
.inputAriaLabel=${translateText("single_modal.starting_gold")}
|
||||
.inputAriaLabel=${translateText("host_modal.starting_gold")}
|
||||
.inputPlaceholder=${translateText(
|
||||
"single_modal.starting_gold_placeholder",
|
||||
"host_modal.starting_gold_placeholder",
|
||||
)}
|
||||
.defaultInputValue=${5}
|
||||
.minValidOnEnable=${0.1}
|
||||
@@ -294,6 +295,10 @@ export class HostLobbyModal extends BaseModal {
|
||||
labelKey: "host_modal.compact_map",
|
||||
checked: this.compactMap,
|
||||
},
|
||||
{
|
||||
labelKey: "host_modal.disable_alliances",
|
||||
checked: this.disableAlliances,
|
||||
},
|
||||
],
|
||||
inputCards,
|
||||
},
|
||||
@@ -457,6 +462,7 @@ export class HostLobbyModal extends BaseModal {
|
||||
this.goldMultiplierValue = undefined;
|
||||
this.startingGold = false;
|
||||
this.startingGoldValue = undefined;
|
||||
this.disableAlliances = false;
|
||||
|
||||
this.leaveLobbyOnClose = true;
|
||||
}
|
||||
@@ -533,6 +539,10 @@ export class HostLobbyModal extends BaseModal {
|
||||
case "host_modal.compact_map":
|
||||
this.handleCompactMapChange(checked);
|
||||
break;
|
||||
case "host_modal.disable_alliances":
|
||||
this.disableAlliances = checked;
|
||||
this.putGameConfig();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -795,6 +805,7 @@ export class HostLobbyModal extends BaseModal {
|
||||
this.startingGold === true && this.startingGoldValue !== undefined
|
||||
? Math.round(this.startingGoldValue * 1_000_000)
|
||||
: undefined,
|
||||
disableAlliances: this.disableAlliances || undefined,
|
||||
} satisfies Partial<GameConfig>,
|
||||
},
|
||||
bubbles: true,
|
||||
|
||||
@@ -56,6 +56,7 @@ const DEFAULT_OPTIONS = {
|
||||
startingGold: false,
|
||||
startingGoldValue: undefined as number | undefined,
|
||||
disabledUnits: [] as UnitType[],
|
||||
disableAlliances: false,
|
||||
} as const;
|
||||
|
||||
@customElement("single-player-modal")
|
||||
@@ -90,6 +91,7 @@ export class SinglePlayerModal extends BaseModal {
|
||||
@state() private disabledUnits: UnitType[] = [
|
||||
...DEFAULT_OPTIONS.disabledUnits,
|
||||
];
|
||||
@state() private disableAlliances: boolean = DEFAULT_OPTIONS.disableAlliances;
|
||||
|
||||
private mapLoader = terrainMapFileLoader;
|
||||
|
||||
@@ -313,6 +315,10 @@ export class SinglePlayerModal extends BaseModal {
|
||||
labelKey: "single_modal.compact_map",
|
||||
checked: this.compactMap,
|
||||
},
|
||||
{
|
||||
labelKey: "single_modal.disable_alliances",
|
||||
checked: this.disableAlliances,
|
||||
},
|
||||
],
|
||||
inputCards,
|
||||
},
|
||||
@@ -383,6 +389,7 @@ export class SinglePlayerModal extends BaseModal {
|
||||
this.gameMode !== DEFAULT_OPTIONS.gameMode ||
|
||||
this.goldMultiplier !== DEFAULT_OPTIONS.goldMultiplier ||
|
||||
this.startingGold !== DEFAULT_OPTIONS.startingGold ||
|
||||
this.disableAlliances !== DEFAULT_OPTIONS.disableAlliances ||
|
||||
this.disabledUnits.length > 0
|
||||
);
|
||||
}
|
||||
@@ -409,6 +416,7 @@ export class SinglePlayerModal extends BaseModal {
|
||||
this.goldMultiplierValue = DEFAULT_OPTIONS.goldMultiplierValue;
|
||||
this.startingGold = DEFAULT_OPTIONS.startingGold;
|
||||
this.startingGoldValue = DEFAULT_OPTIONS.startingGoldValue;
|
||||
this.disableAlliances = DEFAULT_OPTIONS.disableAlliances;
|
||||
}
|
||||
|
||||
protected onOpen(): void {
|
||||
@@ -488,6 +496,9 @@ export class SinglePlayerModal extends BaseModal {
|
||||
case "single_modal.compact_map":
|
||||
this.handleCompactMapChange(checked);
|
||||
break;
|
||||
case "single_modal.disable_alliances":
|
||||
this.disableAlliances = checked;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -696,6 +707,7 @@ export class SinglePlayerModal extends BaseModal {
|
||||
),
|
||||
}
|
||||
: {}),
|
||||
...(this.disableAlliances ? { disableAlliances: true } : {}),
|
||||
},
|
||||
lobbyCreatedAt: Date.now(), // ms; server should be authoritative in MP
|
||||
},
|
||||
|
||||
@@ -168,6 +168,23 @@ export function getActiveModifiers(
|
||||
formattedValue: `${millions}M`,
|
||||
});
|
||||
}
|
||||
if (modifiers.goldMultiplier) {
|
||||
result.push({
|
||||
labelKey: "host_modal.gold_multiplier",
|
||||
badgeKey: "public_game_modifier.gold_multiplier",
|
||||
badgeParams: {
|
||||
amount: modifiers.goldMultiplier,
|
||||
},
|
||||
value: modifiers.goldMultiplier,
|
||||
formattedValue: `x${modifiers.goldMultiplier}`,
|
||||
});
|
||||
}
|
||||
if (modifiers.isAlliancesDisabled) {
|
||||
result.push({
|
||||
labelKey: "host_modal.disable_alliances",
|
||||
badgeKey: "public_game_modifier.disable_alliances",
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user