Created
July 30, 2018 18:17
-
-
Save ennorehling/5c78fe51196a581c2861c0f53efe11cf to your computer and use it in GitHub Desktop.
Fix peasants in new player area
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'config' | |
filename = get_turn() .. '.dat' | |
eressea.read_game(filename) | |
maxps = { | |
['plain'] = 10000, | |
['mountain'] = 1000, | |
['glacier'] = 100, | |
['highland'] = 4000, | |
['swamp'] = 2000, | |
['desert'] = 500, | |
['volcano'] = 500, | |
['ocean'] = 0, | |
['firewall'] = 0 | |
} | |
function fixit(r) | |
maxp = maxps[r.terrain] or 500 | |
minp = maxp / 10 | |
if r.peasants < minp then | |
r.peasants = math.random(minp, maxp) | |
print(tostring(r) .. ', ' .. r.terrain .. ': ' .. r.peasants .. ' peasants') | |
end | |
end | |
function fix() | |
for f in factions() do | |
if f.age<30 then | |
for u in f.units do | |
fixit(u.region) | |
for _, r in ipairs(u.region.adj) do | |
fixit(r) | |
end | |
end | |
end | |
end | |
end | |
fix() | |
eressea.write_game(filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment