Yup..... So I have to use lua?
GameEvents.PlayerDoTurn.Add(function(iPlayer)
if Players[iPlayer]:GetCivilizationType() == GameInfoTypes.CIVILIZATION_INDIA then
local numBuilds = 0;
for pCity in iPlayer:Cities() do
if pCity:IsHasBuilding(GameInfoTypes.BUILDING_INDIAN_FESTIVAL) then
numBuilds = numBuilds + 1;
end
end
if numBuilds >= 3 then
--to do: disable construction BUILDING_INDIAN_FESTIVAL
else
--to do: enable construction BUILDING_INDIAN_FESTIVAL
end
end
end)
Rather than PlayerDoTurn, use:
CityCanConstruct
Player:GetBuildingClassCount(BuildingClassType)
Player:GetBuildingClassCountPlusMaking(BuildingClassType)
Player:GetBuildingClassMaking(BuildingClassType)
GameEvents.PlayerCanConstruct.Add(
function(iPlayer, buildingTypeID)
local player = Players[iPlayer]
if player:GetCivilizationType() == GameInfoTypes.CIVILIZATION_INDIA then
local buildingType = GameInfo.Buildings[buildingTypeID].Type;
local numBuilds = 0;
if buildingType == GameInfoTypes.BUILDING_INDIAN_FESTIVAL then
for pCity in iPlayer:Cities() do
if pCity:IsHasBuilding(GameInfoTypes.BUILDING_INDIAN_FESTIVAL) then
numBuilds = numBuilds + 1;
end
end
if numBuilds >= 3 then
return false
end
end
end
return true
end)
GameEvents.CityCanConstruct.Add(function(iPlayer, iCity, iBuildingType)
local pPlayer = Players[iPlayer];
if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_INDIA then
if (iBuildingType == GameInfo.Buildings["BUILDING_INDIAN_FESTIVAL"].ID) then
if (pPlayer:CountNumBuildings(iBuildingType) > 2) then
return false;
end
end
end
return true;
end);
It actually is what you want to easily figure how many of Building_x an empire has already built. Because no one empire is allowed to build more than one building from within one class, for any individual player it is actually going to return how many buildings they own from within that class.Player:GetBuildingClassCount(BuildingClassType) this is for BuildingClass but I need to count Buildings, not class.
GameEvents.CityCanConstruct.Add(function(iPlayer, iCity, iBuildingType)
local pPlayer = Players[iPlayer];
if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_INDIA then
if (iBuildingType == GameInfo.Buildings["BUILDING_INDIAN_FESTIVAL"].ID) then
if (pPlayer:GetBuildingClassCount(GameInfo.BuildingClasses.BUILDINGCLASS_CIRCUS.ID) > 2) then
return false;
end
end
end
return true;
end);