test learning and teaching, eliminate randomness

This commit is contained in:
Enno Rehling 2010-10-08 23:40:19 -07:00
parent 21eef2159b
commit 8000b9bb2b
1 changed files with 34 additions and 30 deletions

View File

@ -4,42 +4,45 @@ module( "e2", package.seeall, lunit.testcase )
function setup()
free_game()
settings.set("nmr.timeout", "0")
settings.set("rules.economy.food", "4")
end
function test_learn()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
f.age = 20
local u = unit.create(f, r)
u:add_item("money", 1000)
u:clear_orders()
u:add_order("@LERNEN Reiten")
process_orders()
assert_equal(1, u:get_skill("riding"))
process_orders()
process_orders()
process_orders()
process_orders()
assert_true(2<=u:get_skill("riding"))
settings.set("study.random_progress", "0")
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
f.age = 20
local u = unit.create(f, r)
u:clear_orders()
u:add_order("@LERNEN Reiten")
process_orders()
assert_equal(1, u:get_skill("riding"))
process_orders()
process_orders()
assert_equal(2, u:get_skill("riding"))
process_orders()
process_orders()
process_orders()
assert_equal(3, u:get_skill("riding"))
end
function test_teach()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
f.age = 20
local u = unit.create(f, r, 10)
local u2 = unit.create(f, r)
u:add_item("money", 1000)
u:clear_orders()
u:add_order("@LERNEN reiten")
u2:clear_orders()
u2:add_order("LEHREN " .. itoa36(u.id))
u2:set_skill("riding", 4)
process_orders()
assert_equal(1, u:get_skill("riding"))
process_orders()
process_orders()
assert_true(2<=u:get_skill("riding"))
settings.set("study.random_progress", "0")
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
f.age = 20
local u = unit.create(f, r, 10)
local u2 = unit.create(f, r)
u:clear_orders()
u:add_order("@LERNEN reiten")
u2:clear_orders()
u2:add_order("LEHREN " .. itoa36(u.id))
u2:set_skill("riding", 4)
process_orders()
assert_equal(1, u:get_skill("riding"))
process_orders()
assert_equal(2, u:get_skill("riding"))
end
function test_rename()
@ -115,6 +118,7 @@ function test_ship_capacity()
u4:add_order("NACH O O")
process_orders()
-- print(s.region, u.region, r2)
assert_equal(r2.id, u1.region.id, "boat with 5 humans did not move")
assert_not_equal(r2.id, u2.region.id, "boat with too many people has moved")