forked from github/server
testing christmas items, removing old xmas scripts
This commit is contained in:
parent
e678c1bcce
commit
b66b6f7f4c
|
@ -4,9 +4,8 @@ eressea.log.debug("rules for game E2")
|
|||
return {
|
||||
require('eressea'),
|
||||
require('eressea.autoseed'),
|
||||
require('eressea.xmas2004'),
|
||||
require('eressea.xmas2005'),
|
||||
require('eressea.xmas2006'),
|
||||
require('eressea.xmas'),
|
||||
require('eressea.xmasitems'),
|
||||
require('eressea.wedding'),
|
||||
require('eressea.embassy'),
|
||||
require('eressea.eternath'),
|
||||
|
|
|
@ -5,7 +5,7 @@ eressea.log.debug("rules for game E3")
|
|||
|
||||
return {
|
||||
require('eressea'),
|
||||
require('eressea.xmas2009'),
|
||||
require('eressea.xmasitems'),
|
||||
require('eressea.markets'),
|
||||
require('eressea.frost'),
|
||||
require('eressea.ents')
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
function use_snowman(u, amount)
|
||||
if amount>0 and u.region.terrain == "glacier" then
|
||||
local man = unit.create(u.faction, u.region)
|
||||
man.race = "snowman"
|
||||
man.number = amount
|
||||
return amount
|
||||
end
|
||||
return -4
|
||||
end
|
||||
|
||||
local self = {}
|
||||
|
||||
function self.update()
|
||||
if not get_key("xm04") then
|
||||
eressea.log.debug("Es weihnachtet sehr (2004)")
|
||||
set_key("xm04", true)
|
||||
for f in factions() do
|
||||
f:add_item("speedsail", 1)
|
||||
f:add_notice("santa2004")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return self
|
|
@ -1,30 +0,0 @@
|
|||
function usepotion_message(u, potion)
|
||||
msg = message.create("usepotion")
|
||||
msg:set_unit("unit", u)
|
||||
msg:set_resource("potion", potion)
|
||||
return msg
|
||||
end
|
||||
|
||||
function use_stardust(u, amount)
|
||||
local p = u.region:get_resource("peasant")
|
||||
p = math.ceil(1.5 * p)
|
||||
u.region:set_resource("peasant", p)
|
||||
local msg = usepotion_message(u, "stardust")
|
||||
msg:send_region(u.region)
|
||||
return amount
|
||||
end
|
||||
|
||||
local self = {}
|
||||
|
||||
function self.update()
|
||||
if not get_key("xm05") then
|
||||
print("Es weihnachtet sehr (2005)")
|
||||
set_key("xm05", true)
|
||||
for f in factions() do
|
||||
f:add_item("stardust", 1)
|
||||
f:add_notice("santa2005")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return self
|
|
@ -1,53 +0,0 @@
|
|||
function use_xmastree(u, amount)
|
||||
u.region:set_key("xm06", true)
|
||||
local msg = message.create("usepotion")
|
||||
msg:set_unit("unit", u)
|
||||
msg:set_resource("potion", "xmastree")
|
||||
msg:send_region(u.region)
|
||||
return amount
|
||||
end
|
||||
|
||||
local self = {}
|
||||
|
||||
function self.update()
|
||||
local turn = get_turn()
|
||||
local season = get_season(turn)
|
||||
if season == "calendar::winter" then
|
||||
eressea.log.debug("it is " .. season .. ", the christmas trees do their magic")
|
||||
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
|
||||
|
||||
function self.init()
|
||||
if not get_key("xm06") then
|
||||
print("Es weihnachtet sehr (2006)")
|
||||
set_key("xm06", true)
|
||||
for f in factions() do
|
||||
f:add_item("xmastree", 1)
|
||||
f:add_notice("santa2006")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return self
|
|
@ -1,30 +0,0 @@
|
|||
function use_xmastree(u, amount)
|
||||
if u.region.herb~=nil then
|
||||
-- TODO: else?
|
||||
local trees = u.region:get_resource("tree")
|
||||
u.region:set_resource("tree", 10+trees)
|
||||
local msg = message.create("usepotion")
|
||||
msg:set_unit("unit", u)
|
||||
msg:set_resource("potion", "xmastree")
|
||||
msg:send_region(u.region)
|
||||
return amount
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
local xmas = {}
|
||||
|
||||
function xmas.update()
|
||||
if not get_key("xm09") then
|
||||
print("Es weihnachtet sehr (2009)")
|
||||
set_key("xm09", true)
|
||||
for f in factions() do
|
||||
f:add_item("xmastree", 1)
|
||||
local msg = message.create("msg_event")
|
||||
msg:set_string("string", translate("santa2006"))
|
||||
msg:send_faction(f)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return xmas
|
|
@ -24,6 +24,7 @@ function use_snowglobe(u, amount, token)
|
|||
local trans = transform[r.terrain]
|
||||
if trans then
|
||||
r.terrain = trans
|
||||
return 1
|
||||
else
|
||||
-- message "invalid terrain"
|
||||
end
|
||||
|
@ -32,9 +33,8 @@ function use_snowglobe(u, amount, token)
|
|||
end
|
||||
else
|
||||
-- message "need to specify direction"
|
||||
return -1
|
||||
end
|
||||
return 1
|
||||
return -1
|
||||
end
|
||||
|
||||
function use_snowman(u, amount)
|
||||
|
|
|
@ -201,18 +201,6 @@ function test_no_uruk()
|
|||
assert_equal(f1.race, "orc")
|
||||
end
|
||||
|
||||
function disable_test_snowglobe()
|
||||
local r1 = region.create(0, 0, "glacier")
|
||||
local r2 = region.create(1, 0, "ocean")
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
local u = unit.create(f, r1, 1)
|
||||
u:add_item("snowglobe", 1)
|
||||
u:clear_orders()
|
||||
u:add_order("BENUTZEN 1 Schneekugel Ost")
|
||||
process_orders()
|
||||
assert_equal("glacier", r2.terrain)
|
||||
end
|
||||
|
||||
function test_snowman()
|
||||
local r = region.create(0, 0, "glacier")
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
|
|
|
@ -11,3 +11,4 @@ require 'tests.common'
|
|||
require 'tests.storage'
|
||||
require 'tests.magicbag'
|
||||
require 'tests.process'
|
||||
require 'tests.xmas'
|
||||
|
|
|
@ -1,3 +1,45 @@
|
|||
require "lunit"
|
||||
|
||||
module("tests.xmas", package.seeall, lunit.testcase )
|
||||
|
||||
function setup()
|
||||
eressea.free_game()
|
||||
eressea.settings.set("nmr.timeout", "0")
|
||||
eressea.settings.set("rules.grow.formula", "0")
|
||||
end
|
||||
|
||||
function test_snowglobe_fail()
|
||||
local r1 = region.create(0, 0, "glacier")
|
||||
local r2 = region.create(1, 0, "ocean")
|
||||
local f = faction.create("snowglobe1@eressea.de", "human", "de")
|
||||
local u = unit.create(f, r1, 1)
|
||||
u:add_item("snowglobe", 1)
|
||||
u:clear_orders()
|
||||
u:add_order("BENUTZEN 1 Schneekugel Ost")
|
||||
unit.create(f, r2, 1) -- unit in target region => fail
|
||||
process_orders()
|
||||
assert_equal('ocean', r2.terrain)
|
||||
end
|
||||
|
||||
function test_snowglobe()
|
||||
local r1 = region.create(0, 0, "glacier")
|
||||
local r2 = region.create(1, 0, "ocean")
|
||||
local f = faction.create("snowglobe2@eressea.de", "human", "de")
|
||||
local u = unit.create(f, r1, 1)
|
||||
local have = 6
|
||||
u:add_item("snowglobe", have)
|
||||
local xform = { ocean = "glacier", glacier = "glacier", firewall = "volcano", volcano = "mountain", desert = "plain", plain = "plain" }
|
||||
u:clear_orders()
|
||||
u:add_order("BENUTZEN 1 Schneekugel Ost")
|
||||
for k, v in pairs(xform) do
|
||||
r2.terrain = k
|
||||
process_orders()
|
||||
assert_equal(v, r2.terrain)
|
||||
if k~=v then have=have - 1 end
|
||||
assert_equal(have, u:get_item("snowglobe"))
|
||||
end
|
||||
end
|
||||
|
||||
local function use_tree(terrain)
|
||||
local r = region.create(0, 0, terrain)
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
|
|
11
src/laws.c
11
src/laws.c
|
@ -791,12 +791,7 @@ void demographics(void)
|
|||
/* die Nachfrage nach Produkten steigt. */
|
||||
struct demand *dmd;
|
||||
if (r->land) {
|
||||
static int plant_rules = -1;
|
||||
|
||||
if (plant_rules < 0) {
|
||||
plant_rules =
|
||||
get_param_int(global.parameters, "rules.grow.formula", 0);
|
||||
}
|
||||
int plant_rules = get_param_int(global.parameters, "rules.grow.formula", 2);
|
||||
for (dmd = r->land->demands; dmd; dmd = dmd->next) {
|
||||
if (dmd->value > 0 && dmd->value < MAXDEMAND) {
|
||||
float rise = DMRISE;
|
||||
|
@ -822,11 +817,11 @@ void demographics(void)
|
|||
}
|
||||
}
|
||||
horses(r);
|
||||
if (plant_rules == 0) { /* E1 */
|
||||
if (plant_rules == 2) { /* E2 */
|
||||
growing_trees(r, current_season, last_weeks_season);
|
||||
growing_herbs(r, current_season, last_weeks_season);
|
||||
}
|
||||
else { /* E3 */
|
||||
else if (plant_rules==1) { /* E3 */
|
||||
growing_trees_e3(r, current_season, last_weeks_season);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue