----------------------------------------------------
-- Plot Bonus: Production (Satellite)
----------------------------------------------------
local PlotBonus = {};
local PlotBonusInfo = GameInfo.PlotBonuses["PLOT_BONUS_PRODUCTION"];
local iResearchMod = GameInfo.GameSpeeds[Game.GetGameSpeedType()].ResearchPercent / 100
local ProductionChange = 80 * iResearchMod;
local MinChange = 5;
local MaxChange = 9;
local ChangeFactor = 10;
function PlotBonus.IsValidForPlayerAtPlot(player, plot)
local city = player:GetCapitalCity();
if (city == nil) then
return false;
end
return true;
end
function PlotBonus.DoBonus(plot, player, fromExpedition)
local roll = Game.Rand(MaxChange + 1 - MinChange, "Choosing amount of production to give from plot bonus");
local ProductionChange = math.ceil((MinChange + roll) * iResearchMod * ChangeFactor)
print("Production plot bonus for player " .. player:GetID());
-- Which city?
local city = PickACity(player)
print("- Food changed by (" .. ProductionChange .. ") in " .. city:GetName() .. ".")
-- Give the bonus
city:ChangeOverflowProduction(ProductionChange);
-- Notify the player
local summary = Locale.ConvertTextKey(PlotBonusInfo.Description);
local message = Locale.ConvertTextKey(PlotBonusInfo.Help, city:GetName(), ProductionChange);
ShowMessage(player, plot, summary, message, fromExpedition);
end
-- Picks a Random City from all of the Cities that the Player owns
function PickACity(player)
-- print("Choosing a Random City now.")
local iCity = math.random(player:GetNumCities())
local CityNumber = 0
for pCity in player:Cities() do
CityNumber = CityNumber + 1
if (CityNumber == iCity) then
-- print("City " .. pCity:GetName() .. " was chosen.")
return pCity
end
end
end
return PlotBonus;