${this.renderOptionToggle(
"single_modal.disable_nations",
this.disableNations,
(val) => (this.disableNations = val),
this.gameMode === GameMode.Team &&
this.teamCount === HumansVsNations,
)}
${this.renderOptionToggle(
"single_modal.instant_build",
this.instantBuild,
(val) => (this.instantBuild = val),
)}
${this.renderOptionToggle(
"single_modal.random_spawn",
this.randomSpawn,
(val) => (this.randomSpawn = val),
)}
${this.renderOptionToggle(
"single_modal.infinite_gold",
this.infiniteGold,
(val) => (this.infiniteGold = val),
)}
${this.renderOptionToggle(
"single_modal.infinite_troops",
this.infiniteTroops,
(val) => (this.infiniteTroops = val),
)}
${this.renderOptionToggle(
"single_modal.compact_map",
this.compactMap,
(val) => {
this.compactMap = val;
if (val && this.bots === 400) {
this.bots = 100;
} else if (!val && this.bots === 100) {
this.bots = 400;
}
},
)}
${renderToggleInputCard({
labelKey: "single_modal.max_timer",
checked: this.maxTimer,
onClick: () => {
this.maxTimer = !this.maxTimer;
if (!this.maxTimer) {
this.maxTimerValue = undefined;
} else {
// Set default value when enabling if not already set or invalid
if (!this.maxTimerValue || this.maxTimerValue <= 0) {
this.maxTimerValue = 30;
}
// Focus the input after render
setTimeout(() => {
const input = this.getEndTimerInput();
if (input) {
input.focus();
input.select();
}
}, 0);
}
},
input: renderToggleInputCardInput({
id: "end-timer-value",
min: 1,
max: 120,
value: this.maxTimerValue ?? "",
ariaLabel: translateText("single_modal.max_timer"),
placeholder: translateText(
"single_modal.max_timer_placeholder",
),
onInput: this.handleMaxTimerValueChanges,
onKeyDown: this.handleMaxTimerValueKeyDown,
}),
})}
${renderToggleInputCard({
labelKey: "single_modal.gold_multiplier",
checked: this.goldMultiplier,
onClick: () => {
this.goldMultiplier = !this.goldMultiplier;
if (!this.goldMultiplier) {
this.goldMultiplierValue = undefined;
} else {
if (
!this.goldMultiplierValue ||
this.goldMultiplierValue <= 0
) {
this.goldMultiplierValue = 2;
}
setTimeout(() => {
const input = this.renderRoot.querySelector(
"#gold-multiplier-value",
) as HTMLInputElement;
if (input) {
input.focus();
input.select();
}
}, 0);
}
},
input: renderToggleInputCardInput({
id: "gold-multiplier-value",
min: 0.1,
max: 1000,
step: "any",
value: this.goldMultiplierValue ?? "",
ariaLabel: translateText("single_modal.gold_multiplier"),
placeholder: translateText(
"single_modal.gold_multiplier_placeholder",
),
onChange: this.handleGoldMultiplierValueChanges,
onKeyDown: this.handleGoldMultiplierValueKeyDown,
}),
})}
${renderToggleInputCard({
labelKey: "single_modal.starting_gold",
checked: this.startingGold,
onClick: () => {
this.startingGold = !this.startingGold;
if (!this.startingGold) {
this.startingGoldValue = undefined;
} else {
if (
!this.startingGoldValue ||
this.startingGoldValue < 0
) {
this.startingGoldValue = 5000000;
}
setTimeout(() => {
const input = this.renderRoot.querySelector(
"#starting-gold-value",
) as HTMLInputElement;
if (input) {
input.focus();
input.select();
}
}, 0);
}
},
input: renderToggleInputCardInput({
id: "starting-gold-value",
min: 0,
max: 1000000000,
step: 100000,
value: this.startingGoldValue ?? "",
ariaLabel: translateText("single_modal.starting_gold"),
placeholder: translateText(
"single_modal.starting_gold_placeholder",
),
onInput: this.handleStartingGoldValueChanges,
onKeyDown: this.handleStartingGoldValueKeyDown,
}),
})}