From 80e0707cb2fb5764c22b6214cbd7bb07e410e1cd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 1 Dec 2015 11:51:23 +0100 Subject: [PATCH] snowglobe transformations for several trerrains. messages still TBD --- scripts/eressea/xmasitems.lua | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/scripts/eressea/xmasitems.lua b/scripts/eressea/xmasitems.lua index 6fe3512b8..c39b648ca 100644 --- a/scripts/eressea/xmasitems.lua +++ b/scripts/eressea/xmasitems.lua @@ -7,14 +7,32 @@ local function get_direction(locale, token) end function use_snowglobe(u, amount, token) + local transform = { + ocean = "glacier", + firewall = "volcano", + volcano = "mountain", + desert = "plain" + } local direction = get_direction(u.faction.locale, token) if direction then local r = u.region:next(direction) - if r and r.terrain=="ocean" then - r.terrain = "glacier" + if r.units() then + -- 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 else - return -4 + -- message "need to specify direction" + return -1 end return 1 end