snowglobe transformations for several trerrains. messages still TBD

This commit is contained in:
Enno Rehling 2015-12-01 11:51:23 +01:00
parent 3fd4884584
commit 80e0707cb2
1 changed files with 21 additions and 3 deletions

View File

@ -7,14 +7,32 @@ local function get_direction(locale, token)
end end
function use_snowglobe(u, amount, token) function use_snowglobe(u, amount, token)
local transform = {
ocean = "glacier",
firewall = "volcano",
volcano = "mountain",
desert = "plain"
}
local direction = get_direction(u.faction.locale, token) local direction = get_direction(u.faction.locale, token)
if direction then if direction then
local r = u.region:next(direction) local r = u.region:next(direction)
if r and r.terrain=="ocean" then if r.units() then
r.terrain = "glacier" -- message "target region not empty"
return -1
end
if r then
local trans = transform[r.terrain]
if trans then
r.terrain = trans
else
-- message "invalid terrain"
end
else
-- message "invalid terrain"
end end
else else
return -4 -- message "need to specify direction"
return -1
end end
return 1 return 1
end end