if Game_IsUsingMod(CBPmodID) then
function GetBuildingIDfromClassID( buildingclassID )
local buildingclass = GameInfo.BuildingClasses[ buildingclassID ]
for row in DB.Query("SELECT a.ID buildingID, b.ID classID FROM Buildings a, BuildingClasses b WHERE a.Type = b.DefaultBuilding AND b.ID = '" .. buildingclassID .. "'") do
return row.buildingID
end
end
function IsWonderBuilding( buildingID )
for row in GameInfo.Buildings("ID = '" .. buildingID .. "'") do
if row.WonderSplashImage ~= 'NULL' then
return true
else
return false
end
end
end
local BuildingClassGardenID = GameInfo.BuildingClasses.BUILDINGCLASS_GARDEN.ID
local NepalUB = GameInfoTypes["BUILDING_DJSH_DURBAR_SQUARE"]
function Trait_BuildingPurchaseActuallyCompletesThem(iPlayer, iCity, iBuildingClass, bValue)
local pPlayer = Players[iPlayer]
local pCity = pPlayer:GetCityByID(iCity)
local iBuilding = GetBuildingIDfromClassID( iBuildingClass )
local productionCost = pPlayer:GetBuildingProductionNeeded( iBuilding )
local GPpoints = 25*productionCost
if (pPlayer:IsAlive() and pPlayer:GetCivilizationType() == iCiv) then
if iBuildingClass == BuildingClassGardenID then
pCity:SetNumRealBuilding(NepalUB, 1)
elseif not IsWonderBuilding( iBuilding ) then
pCity:SetNumRealBuilding(iBuilding, 1)
else
end
local x = JFD_GetRandom(1,99)
if x<34 then
pCity:ChangeSpecialistGreatPersonProgressTimes100(GameInfoTypes["SPECIALIST_WRITER"], GPpoints)
Events.AddPopupTextEvent(HexToWorld(ToHexFromGrid(Vector2(pCity:Plot():GetX(), pCity:Plot():GetY()))), "[COLOR_GREAT_PEOPLE_STORED]+".. GPpoints .."[ENDCOLOR] [ICON_GREAT_WRITER]", 1)
elseif x>33 and x<67 then
pCity:ChangeSpecialistGreatPersonProgressTimes100(GameInfoTypes["SPECIALIST_ARTIST"], GPpoints)
Events.AddPopupTextEvent(HexToWorld(ToHexFromGrid(Vector2(pCity:Plot():GetX(), pCity:Plot():GetY()))), "[COLOR_GREAT_PEOPLE_STORED]+".. GPpoints .."[ENDCOLOR] [ICON_GREAT_WRITER]", 1)
else
pCity:ChangeSpecialistGreatPersonProgressTimes100(GameInfoTypes["SPECIALIST_MUSICIAN"], GPpoints)
Events.AddPopupTextEvent(HexToWorld(ToHexFromGrid(Vector2(pCity:Plot():GetX(), pCity:Plot():GetY()))), "[COLOR_GREAT_PEOPLE_STORED]+".. GPpoints .."[ENDCOLOR] [ICON_GREAT_WRITER]", 1)
end
end
end
GameEvents.CityInvestedBuilding.Add(Trait_BuildingPurchaseActuallyCompletesThem)
end