local iRequiredCivilization = GameInfoTypes.CIVILIZATION_AMERICA
local iDomainAir = GameInfoTypes.DOMAIN_AIR
local tPromotionsToGive = {[[COLOR="Green"][B]1[/B][/COLOR]]=GameInfoTypes.PROMOTION_CULTURAL_DEFENSE_[COLOR="green"][B]1[/B][/COLOR],[[COLOR="Red"][B]2[/B][/COLOR]]=GameInfoTypes.PROMOTION_CULTURAL_DEFENSE_[COLOR="Red"][B]2[/B][/COLOR]}
local tCulturePerTurnLevels = {[[COLOR="green"][B]1[/B][/COLOR]]=10,[[COLOR="red"][B]2[/B][/COLOR]]=30}
function AssignPromotionsBasedOnCulture(iPlayer)
local pPlayer = Players[iPlayer]
if pPlayer:GetCivilizationType() == iRequiredCivilization then
local iCulturePerTurn = pPlayer:GetTotalJONSCulturePerTurn()
local iCultureLevel = 0
if iCulturePerTurn >= tCulturePerTurnLevels[1] then
for i = 1, #tCulturePerTurnLevels do
if iCulturePerTurn >= tCulturePerTurnLevels[i] then
iCultureLevel = i
end
end
end
for pUnit in pPlayer:Units() do
if pUnit:IsCombatUnit() and (pUnit:GetDomainType() ~= iDomainAir) then
for k,v in pairs(tPromotionsToGive) do
if k == iCultureLevel then
pUnit:SetHasPromotion(v, true)
else
pUnit:SetHasPromotion(v, false)
end
end
end
end
end
end
GameEvents.PlayerDoTurn.Add(AssignPromotionsBasedOnCulture)