iRequiredCiv = GameInfoTypes.[color="blue"]CIVILIZATION_ROME[/color]
iIndustrialEra = GameInfoTypes.ERA_INDUSTRIAL
iFreedomIdeology = GameInfoTypes.POLICY_BRANCH_FREEDOM
iHappinessPolicyForFreedom = GameInfoTypes.POLICY_FREEDOM_EXTRA_HAPPYMOD
iUnhappinessPolicyForOther = GameInfoTypes.POLICY_NOTFREEDOM_EXTRA_UNHAPPYMOD
function PlayerFreedomIdeologyChoice(iPlayer, iPolicyID)
local pPlayer = Players[iPlayer]
if pPlayer:GetNumFreePolicies() > 0 then
--print("player has outstanding free policies to select, exiting the AdoptPolicyListener function to avoid conflicts")
return
end
if pPlayer:GetCivilizationType() == iRequiredCiv and pPlayer:GetCurrentEra() >= iIndustrialEra then
if pPlayer:GetLateGamePolicyTree() ~= -1 then
print("pPlayer:GetLateGamePolicyTree() returns " .. tostring(pPlayer:GetLateGamePolicyTree()))
if pPlayer:GetLateGamePolicyTree() == iFreedomIdeology then
print("player has chosen Freedom as their Ideology")
if pPlayer:HasPolicy(iUnhappinessPolicyForOther) then
pPlayer:SetHasPolicy(iUnhappinessPolicyForOther, false)
pPlayer:SetHasPolicy(iHappinessPolicyForFreedom, true)
else
if not pPlayer:HasPolicy(iHappinessPolicyForFreedom) then
pPlayer:SetNumFreePolicies(1)
pPlayer:SetNumFreePolicies(0)
pPlayer:SetHasPolicy(iHappinessPolicyForFreedom, true)
end
end
else
print("player has NOT chosen Freedom as their Ideology")
if pPlayer:HasPolicy(iHappinessPolicyForFreedom) then
pPlayer:SetHasPolicy(iHappinessPolicyForFreedom, false)
pPlayer:SetHasPolicy(iUnhappinessPolicyForOther, true)
else
if not pPlayer:HasPolicy(iUnhappinessPolicyForOther) then
pPlayer:SetNumFreePolicies(1)
pPlayer:SetNumFreePolicies(0)
pPlayer:SetHasPolicy(iUnhappinessPolicyForOther, true)
end
end
end
else
print("pPlayer:GetLateGamePolicyTree() returns " .. tostring(pPlayer:GetLateGamePolicyTree()))
print("player has not yet adopted an Ideology")
end
end
end
GameEvents.PlayerAdoptPolicy.Add(PlayerFreedomIdeologyChoice)
print("The PlayerFreedomIdeologyChoice PlayerAdoptPolicy loaded")