print ("loaded Hoshi Dragon Clan UA Lua")
include( "SaveUtils" ); MY_MOD_NAME = "TogashiHoshi";
function TogashiUA (iPlayer)
-- Putmalk: Initialize pointer for PlayerID iPlayer
local pPlayer = Players[iPlayer];
-- Ignore Minors and Barbarians
if( pPlayer:IsMinorCiv() or pPlayer:IsBarbarian() ) then
--print("Player is minor or barbarian, not executing code.");
return;
end
-- for testing purposes --print these out to verify they are equal / not equal
----print( tostring(pPlayer:GetCivilizationType()) );
----print( tostring(GameInfoTypes["CIVILIZATION_TOUHOU_HV"] ) );
if ( pPlayer:GetCivilizationType() ~= GameInfoTypes["CIVILIZATION_TOGASHI"] ) then
--print("Player " .. tostring(iPlayer) .. " is not the Human Village");
return;
end
--local pCity = pPlayer:GetCapitalCity();
--local iBuildingType = GameInfo.Buildings()
leaderType = GameInfo.Leaders[pPlayer:GetLeaderType()].Type
traitType = GameInfo.Leader_Traits("LeaderType ='" .. leaderType .. "'")().TraitType
trait = GameInfo.Traits[traitType]
--print("Player has trait " .. trait.Type);
for pCity in pPlayer:Cities() do
for building in GameInfo.Buildings() do
strName = GameInfo.Buildings[building.ID].Description
strType = GameInfo.Buildings[building.ID].Type
strCityName = pCity:GetName()
if pCity:IsHasBuilding(building.ID) then
if load( pPlayer, building.ID .. "and" .. iPlayer) ~= true then
strBuildingClass = GameInfo.Buildings[building.ID].BuildingClass
if GameInfo.BuildingClasses[strBuildingClass].MaxPlayerInstances > (-1)then
save( pPlayer, building.ID .. "and" .. iPlayer, true );
----print(strName .. " inserted from: " .. strCityName .. " but not applicable for UA")
else if GameInfo.BuildingClasses[strBuildingClass].MaxGlobalInstances > (-1) then
--print(strType .. " completed.");
local iUnitID = GameInfo.Units.UNIT_WORKER.ID
pPlayer:InitUnit (iUnitID, pCity:GetX(), pCity:GetY() );
else
--print("is not a Wonder");
end
end
else
--print (strName .. " not new construction in city: " .. strCityName)
end
else
--print("Building: " .. strName .. " does not exist in city: " .. strCityName)
end
end
end
end
GameEvents.PlayerDoTurn.Add(TogashiUA)
GameEvents.PlayerAdoptPolicy.Add(TogashiUA)
function CityScreenTogashiUA()
local iPlayer = Game.GetActivePlayer()
TogashiUA(iPlayer)
end
Events.SerialEventExitCityScreen.Add(CityScreenTogashiUA)