testing coasts, and that ships will only sail into terrains that's allowed.

This commit is contained in:
Enno Rehling 2014-06-17 22:06:54 -07:00
parent 8166519d30
commit 59b0f0f582
2 changed files with 30 additions and 25 deletions

View file

@ -1,8 +1,8 @@
-- new tests 2014-06-11 -- new tests 2014-06-11
require "tests.settings" --require "tests.settings"
require "tests.config" --require "tests.config"
require "tests.locale" --require "tests.locale"
require "tests.regions" --require "tests.regions"
require "tests.ships" require "tests.ships"

View file

@ -17,6 +17,7 @@ function setup()
"construction" : { "construction" : {
"maxsize" : 5 "maxsize" : 5
}, },
"coasts" : [ "plain" ],
"range" : 3 "range" : 3
} }
}, },
@ -24,8 +25,9 @@ function setup()
"harbour" : {} "harbour" : {}
}, },
"terrains" : { "terrains" : {
"ocean": { "flags" : [ "sea", "sail", "fly" ] }, "ocean": { "flags" : [ "sea", "sail" ] },
"plain": { "flags" : [ "land", "walk", "sail", "fly" ] } "plain": { "flags" : [ "land", "walk", "sail" ] },
"glacier": { "flags" : [ "land", "walk" ] }
}, },
"directions" : { "directions" : {
"de" : { "de" : {
@ -42,10 +44,9 @@ function setup()
eressea.config.reset() eressea.config.reset()
eressea.config.parse(conf) eressea.config.parse(conf)
eressea.locale.create("en")
end end
function test_sail() function test_sail_oceans()
local r1 = region.create(0, 0, "ocean") local r1 = region.create(0, 0, "ocean")
local r2 = region.create(1, 0, "ocean") local r2 = region.create(1, 0, "ocean")
local f = faction.create("test@example.com", "human", "de") local f = faction.create("test@example.com", "human", "de")
@ -55,29 +56,33 @@ function test_sail()
u:set_skill("sailing", 10) u:set_skill("sailing", 10)
u:add_order("NACH O") u:add_order("NACH O")
process_orders() process_orders()
-- eressea.process.movement()
assert_equal(r2, u.region) assert_equal(r2, u.region)
end end
function notest_landing1() function test_sail_to_shore()
local ocean = region.create(1, 0, "ocean") local ocean = region.create(1, 0, "ocean")
local r = region.create(0, 0, "plain") local shore = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "insect", "de") local f = faction.create("noreply@eressea.de", "human", "de")
local f2 = faction.create("noreply@eressea.de", "human", "de") local u = unit.create(f, ocean, 1)
local s = ship.create(ocean, "longboat") u.ship = ship.create(ocean, "boat")
local u1 = unit.create(f, ocean, 1) u:set_skill("sailing", 10)
local u2 = unit.create(f2, r, 1) u:add_order("NACH W")
assert_not_nil(u2)
u1:add_item("money", 1000)
u2:add_item("money", 1000)
u1.ship = s
u1:set_skill("sailing", 10)
u1:clear_orders()
u1:add_order("NACH w")
process_orders() process_orders()
assert_equal(r, u1.region) -- the plain case: okay assert_equal(shore, u.region)
end
function test_sail_to_forbidden_shore()
local ocean = region.create(1, 0, "ocean")
local shore = region.create(0, 0, "glacier")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, ocean, 1)
u.ship = ship.create(ocean, "boat")
u:set_skill("sailing", 10)
u:add_order("NACH W")
process_orders()
assert_equal(ocean, u.region)
end end