From fa6192daf943316cbb311657736986f484da7360 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 27 May 2007 21:48:29 +0000 Subject: [PATCH] Christmas update: we celebrate Knut. --- src/eressea/lua/eressea.cpp | 4 ++-- src/scripts/eressea/xmas2006.lua | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/eressea/lua/eressea.cpp b/src/eressea/lua/eressea.cpp index 0d309602c..04a22a00a 100644 --- a/src/eressea/lua/eressea.cpp +++ b/src/eressea/lua/eressea.cpp @@ -226,10 +226,10 @@ is_function(struct lua_State * luaState, const char * fname) } static const char * -get_season(void) +get_season(int turnno) { gamedate gd; - get_gamedate(turn, &gd); + get_gamedate(turnno, &gd); return seasonnames[gd.season]; } diff --git a/src/scripts/eressea/xmas2006.lua b/src/scripts/eressea/xmas2006.lua index 2b105790e..6125483d9 100644 --- a/src/scripts/eressea/xmas2006.lua +++ b/src/scripts/eressea/xmas2006.lua @@ -1,7 +1,7 @@ function use_xmastree(u, amount) u.region:set_key("xm06", true) u:use_pooled("xmastree", amount) - msg = message("usepotion") + local msg = message("usepotion") msg:set_unit("unit", u) msg:set_resource("potion", "xmastree") msg:send_region(u.region) @@ -9,10 +9,13 @@ function use_xmastree(u, amount) end function update_xmas2006() - season = get_season() + local turn = get_turn() + local season = get_season(turn) if season == "calendar::winter" then print("it is " .. season .. ", the christmas trees do their magic") - msg = message("xmastree_effect") + local msg = message("xmastree_effect") + local nextseason = get_season(turn-1) + local clear = (nextseason ~= "calendar::winter") for r in regions() do if r:get_key("xm06") then trees = r:get_resource("tree") @@ -20,6 +23,10 @@ function update_xmas2006() r:set_resource("tree", trees * 1.1) msg:send_region(r) end + if clear then + -- we celebrate knut and kick out the trees. + r:set_key("xm06", false) + end end end end