diff --git a/tests/movement.lua b/tests/movement.lua index d5a270088..e27831cc8 100644 --- a/tests/movement.lua +++ b/tests/movement.lua @@ -56,7 +56,7 @@ function test_walk_to_land() assert_equal(r2, u.region) end -function test_walk_to_ocean() +function test_walk_into_ocean_fails() local r1 = region.create(0, 0, "plain") local r2 = region.create(1, 0, "ocean") local f = faction.create("test@example.com", "human", "de") @@ -69,7 +69,7 @@ end function test_walk_distance() local r1 = region.create(0, 0, "plain") local r2 = region.create(1, 0, "plain") - local r3 = region.create(2, 0, "plain") + region.create(2, 0, "plain") local f = faction.create("test@example.com", "human", "de") local u = unit.create(f, r1, 1) u:add_order("NACH O O") @@ -77,16 +77,41 @@ function test_walk_distance() assert_equal(r2, u.region) end -function test_ride_distance() +function test_ride_max_distance() local r1 = region.create(0, 0, "plain") - local r2 = region.create(1, 0, "plain") - local r3 = region.create(2, 0, "plain") + local r2 = region.create(2, 0, "plain") + region.create(1, 0, "plain") + region.create(3, 0, "plain") local f = faction.create("test@example.com", "human", "de") local u = unit.create(f, r1, 1) u:add_item("horse", 1) u:set_skill("riding", 2) - u:add_order("NACH O O") + u:add_order("NACH O O O") process_orders() - assert_equal(r3, u.region) + assert_equal(r2, u.region, "should ride exactly two hexes") end +function test_ride_over_capacity_leads_horse() + local r1 = region.create(0, 0, "plain") + local r2 = region.create(1, 0, "plain") + region.create(2, 0, "plain") + local f = faction.create("test@example.com", "human", "de") + local u = unit.create(f, r1, 3) + u:add_item("horse", 1) + u:set_skill("riding", 2) + u:add_order("NACH O O") + process_orders() + assert_equal(r2, u.region) +end + +function test_ride_no_skill_leads_horse() + local r1 = region.create(0, 0, "plain") + local r2 = region.create(1, 0, "plain") + region.create(2, 0, "plain") + local f = faction.create("test@example.com", "human", "de") + local u = unit.create(f, r1, 1) + u:add_item("horse", 1) + u:add_order("NACH O O") + process_orders() + assert_equal(r2, u.region) +end