AIGameSettingControls.PopForForge = class extends AIGameSettingControlInt
{
	constructor(...args)
	{
		super(...args);
		this.defaultValue = 65;
		g_GameSettings.playerAI.watch(() => this.render(), ["values"]);
	}

	onOpenPage(playerIndex, enabled)
	{
		super.onOpenPage(playerIndex, enabled);
		this.render();
	}

	render()
	{
		const ai = g_GameSettings.playerAI.get(this.playerIndex);
		this.setHidden(!ai);
		if (ai)
		{
			const value = ai.military?.popForForge ?? this.defaultValue;
			this.setIntValue(value);
		}
	}

	onValueChange(value)
	{
		const ai = g_GameSettings.playerAI.get(this.playerIndex);
		const military = ai && ai.military ? { ...ai.military, "popForForge": value } : { "popForForge": value };
		g_GameSettings.playerAI.setMilitary(this.playerIndex, military);
		this.gameSettingsController.setNetworkInitAttributes();
	}
};

AIGameSettingControls.PopForForge.prototype.TitleCaption =
	translate("Pop For Forge");
