2010-08-08 09:40:42 +02:00
|
|
|
function use_xmastree(u, amount)
|
|
|
|
u.region:set_key("xm06", true)
|
|
|
|
u:use_pooled("xmastree", amount)
|
|
|
|
local msg = message.create("usepotion")
|
|
|
|
msg:set_unit("unit", u)
|
|
|
|
msg:set_resource("potion", "xmastree")
|
|
|
|
msg:send_region(u.region)
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
2014-07-26 22:52:25 +02:00
|
|
|
local self = {}
|
|
|
|
|
|
|
|
function self.update()
|
2010-08-08 09:40:42 +02:00
|
|
|
local turn = get_turn()
|
|
|
|
local season = get_season(turn)
|
|
|
|
if season == "calendar::winter" then
|
2014-07-26 22:52:25 +02:00
|
|
|
eressea.log.debug("it is " .. season .. ", the christmas trees do their magic")
|
2010-08-08 09:40:42 +02:00
|
|
|
local msg = message.create("xmastree_effect")
|
|
|
|
for r in regions() do
|
|
|
|
if r:get_key("xm06") then
|
|
|
|
trees = r:get_resource("tree")
|
|
|
|
if trees*0.1>=1 then
|
|
|
|
r:set_resource("tree", trees * 1.1)
|
|
|
|
msg:send_region(r)
|
|
|
|
end
|
|
|
|
if clear then
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
local prevseason = get_season(turn-1)
|
|
|
|
if prevseason == "calendar::winter" then
|
|
|
|
-- we celebrate knut and kick out the trees.
|
|
|
|
for r in regions() do
|
|
|
|
if r:get_key("xm06") then
|
|
|
|
r:set_key("xm06", false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-07-26 22:52:25 +02:00
|
|
|
function self.init()
|
2010-08-08 09:40:42 +02:00
|
|
|
if not get_key("xm06") then
|
2014-07-26 22:52:25 +02:00
|
|
|
print("Es weihnachtet sehr (2006)")
|
|
|
|
set_key("xm06", true)
|
|
|
|
for f in factions() do
|
|
|
|
f:add_item("xmastree", 1)
|
|
|
|
f:add_notice("santa2006")
|
|
|
|
end
|
2010-08-08 09:40:42 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-07-26 22:52:25 +02:00
|
|
|
return self
|