forked from github/server
- fixed blessedharvest tests
- new ship capacity tests
This commit is contained in:
parent
e5cee39963
commit
5fc0ed8631
3 changed files with 45 additions and 5 deletions
|
@ -73,13 +73,13 @@ end
|
||||||
function test_blessedharvest_lasts_n_turn()
|
function test_blessedharvest_lasts_n_turn()
|
||||||
free_game()
|
free_game()
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
local f = faction.create("noreply@eressea.de", "halfling", "de")
|
||||||
local u = unit.create(f, r)
|
local u = unit.create(f, r)
|
||||||
r:set_resource("peasant", 100)
|
r:set_resource("peasant", 100)
|
||||||
r:set_resource("money", 0)
|
r:set_resource("money", 0)
|
||||||
u:add_item("money", 1000)
|
u:add_item("money", 1000)
|
||||||
u.magic = "gwyrrd"
|
u.magic = "gwyrrd"
|
||||||
u.race = "elf"
|
u.race = "dwarf"
|
||||||
u:set_skill("magic", 20)
|
u:set_skill("magic", 20)
|
||||||
u.aura = 200
|
u.aura = 200
|
||||||
u:add_spell("raindance")
|
u:add_spell("raindance")
|
||||||
|
@ -344,6 +344,7 @@ function test_guard()
|
||||||
f1.age = 20
|
f1.age = 20
|
||||||
local u1 = unit.create(f1, r, 1)
|
local u1 = unit.create(f1, r, 1)
|
||||||
u1:add_item("sword", 10)
|
u1:add_item("sword", 10)
|
||||||
|
u1:add_item("money", 10)
|
||||||
u1:set_skill("melee", 10)
|
u1:set_skill("melee", 10)
|
||||||
u1:clear_orders()
|
u1:clear_orders()
|
||||||
u1:add_order("NACH O")
|
u1:add_order("NACH O")
|
||||||
|
@ -362,7 +363,7 @@ function test_guard()
|
||||||
u2:add_item("money", 100)
|
u2:add_item("money", 100)
|
||||||
u3:add_item("money", 100)
|
u3:add_item("money", 100)
|
||||||
process_orders()
|
process_orders()
|
||||||
assert(u1.region==r)
|
assert_equal(r.id, u1.region.id, "unit may not move after combat")
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_recruit()
|
function test_recruit()
|
||||||
|
|
|
@ -60,7 +60,7 @@ function test_fishing()
|
||||||
assert_equal(60, u1:get_item("money"))
|
assert_equal(60, u1:get_item("money"))
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_capacity()
|
function test_ship_capacity()
|
||||||
local r = region.create(0,0, "ocean")
|
local r = region.create(0,0, "ocean")
|
||||||
region.create(1,0, "ocean")
|
region.create(1,0, "ocean")
|
||||||
local r2 = region.create(2,0, "ocean")
|
local r2 = region.create(2,0, "ocean")
|
||||||
|
|
|
@ -7,7 +7,6 @@ function setup()
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_unit_limit_is_1500()
|
function test_unit_limit_is_1500()
|
||||||
free_game()
|
|
||||||
local r = region.create(0,0, "plain")
|
local r = region.create(0,0, "plain")
|
||||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||||
for i = 1,1500 do
|
for i = 1,1500 do
|
||||||
|
@ -20,3 +19,43 @@ function test_unit_limit_is_1500()
|
||||||
process_orders()
|
process_orders()
|
||||||
assert_equal(1, u.number)
|
assert_equal(1, u.number)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function test_ship_capacity()
|
||||||
|
local r = region.create(0,0, "ocean")
|
||||||
|
region.create(1,0, "ocean")
|
||||||
|
local r2 = region.create(2,0, "ocean")
|
||||||
|
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||||
|
|
||||||
|
-- u1 is at the limit and moves
|
||||||
|
local s1 = ship.create(r, "boat")
|
||||||
|
local u1 = unit.create(f, r, 5)
|
||||||
|
u1.ship = s1
|
||||||
|
u1:set_skill("sailing", 10)
|
||||||
|
u1:clear_orders()
|
||||||
|
u1:add_order("NACH O O")
|
||||||
|
|
||||||
|
-- u2 has too many people
|
||||||
|
local s2 = ship.create(r, "boat")
|
||||||
|
local u2 = unit.create(f, r, 6)
|
||||||
|
u2.ship = s2
|
||||||
|
u2:set_skill("sailing", 10)
|
||||||
|
u2:clear_orders()
|
||||||
|
u2:add_order("NACH O O")
|
||||||
|
|
||||||
|
-- u4 has too much stuff
|
||||||
|
local s4 = ship.create(r, "boat")
|
||||||
|
local u4 = unit.create(f, r, 5)
|
||||||
|
u4.ship = s4
|
||||||
|
u4:set_skill("sailing", 10)
|
||||||
|
u4:add_item("sword", 1)
|
||||||
|
u4:clear_orders()
|
||||||
|
u4:add_order("NACH O O")
|
||||||
|
|
||||||
|
update_owners()
|
||||||
|
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")
|
||||||
|
assert_not_equal(r2.id, u4.region.id, "boat with too much cargo has moved")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue