function DetermineContinents()
print("Determining continents for art purposes (MapGenerator.Lua)");
-- Command for setting the art type for a plot is: <plot object>:SetContinentArtType(<art_set_number>)
-- CONTINENTAL ART SETS
-- 0) Ocean
-- 1) America
-- 2) Asia
-- 3) Africa
-- 4) Europe
Map.DefaultContinentStamper();
--If option is no Orange Trees, reiterate and replace any American tiles.
local allowAmerica = Map.GetCustomOption(7);
if allowAmerica == 2 then
--Replace Orange Trees
local coin = Map.Rand(2, "Flip Coin to break ties");
local artType
local numAsia, numAfri, numEuro, numAmer = 0, 0, 0, 0;
local rankAsia, rankAfri, rankEuro = 0, 0, 0;
local newType = 0
--get number of tiles of each cont art type
for i, plot in Plots() do
artType = plot:GetContinentArtType();
if artType == 1 then numAmer = numAmer + 1;
elseif artType == 2 then numAsia = numAsia + 1;
elseif artType == 3 then numAfri = numAfri + 1;
elseif artType == 4 then numEuro = numEuro + 1;
else --is 0, so is water tile do nothing
end
end
print("____________Remove Orange Trees")
print("Number of Asian Tiles", numAsia)
print("Number of African Tiles", numAfri)
print("Number of European Tiles", numEuro)
print("Number of American Tiles", numAmer)
if numAmer ~= 0 then --if there are American tiles, this will be greater than 0
--which Continent is least represented on the map?
if numAsia > numAfri then rankAsia = rankAsia + 1;
elseif numAsia == numAfri then -- break tie with coin
if coin == 0 then rankAsia = rankAsia + 1;
else rankAfri = rankAfri + 1;
end
else
rankAfri = rankAfri + 1;
end
if numAfri > numEuro then rankAfri = rankAfri + 1;
elseif numAfri == numEuro then -- break tie with coin
if coin == 0 then rankAfri = rankAfri + 1;
else rankEuro = rankEuro + 1;
end
else
rankEuro = rankEuro + 1;
end
if numEuro > numAsia then rankEuro = rankEuro + 1;
elseif numEuro == numAsia then -- break tie with coin
if coin == 0 then rankEuro = rankEuro + 1;
else rankAsia = rankAsia + 1;
end
else
rankAsia = rankAsia + 1;
end
--Now set artType to whatever scored 0 (lowest count)
if rankAsia == 0 then newArt = 2;
elseif rankAfri == 0 then newArt = 3;
elseif rankEuro == 0 then newArt = 4;
else --something went horribly wrong
print("Nothing scored lowest rank! - Remove Orange Trees")
end
print("_____Continent Rank Scores")
print("Asian", rankAsia)
print("African", rankAfri)
print("European", rankEuro)
--Replace America with lowest ranked continent art.
for i, plot in Plots() do
artType = plot:GetContinentArtType();
if artType == 1 then
plot:SetContinentArtType(newArt);
end