From c2167c963ee204619fd821c5adb314e102d294bd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 27 Dec 2017 20:29:49 +0100 Subject: [PATCH] add a (failing) acceptance test for speedy dragonships. fix the old ship tests. --- scripts/tests/e2/init.lua | 2 +- scripts/tests/e2/ships.lua | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index d8d21a5c8..fed038628 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -11,7 +11,7 @@ require 'tests.e2.destroy' require 'tests.e2.guard' require 'tests.e2.stealth' require 'tests.e2.items' --- require 'tests.e2.ships' +require 'tests.e2.ships' require 'tests.items' require 'tests.economy' require 'tests.orders' diff --git a/scripts/tests/e2/ships.lua b/scripts/tests/e2/ships.lua index 2137f72a0..625e62f64 100644 --- a/scripts/tests/e2/ships.lua +++ b/scripts/tests/e2/ships.lua @@ -3,6 +3,8 @@ require "lunit" module("tests.e2.ships", package.seeall, lunit.testcase) function setup() + eressea.game.reset() + eressea.settings.set("rules.food.flags", "4") eressea.settings.set("rules.ship.damage.nocrewocean", "0") eressea.settings.set("rules.ship.damage.nocrew", "0") eressea.settings.set("rules.ship.drifting", "0") @@ -27,7 +29,7 @@ end function test_ship_happy_case() local r1 = region.create(0, 0, "ocean") local r2 = region.create(1, 0, "ocean") - local f = faction.create("human", "hodor@eressea.de", "de") + local f = faction.create("human") local u1 = unit.create(f, r1, 1) local u2 = unit.create(f, r1, 1) u1.ship = ship.create(r1, "longboat") @@ -42,9 +44,9 @@ function test_ship_happy_case() assert_equal(r2, u2.region) end -function test_speedy_ship() +function test_speedy_ship_slow() local r1 = region.create(0, 0, 'ocean') - local f = faction.create("human", "hodor@eressea.de", "de") + local f = faction.create("human") local u1 = unit.create(f, r1, 1) local u2 = unit.create(f, r1, 2) for x = 1, 10 do @@ -52,9 +54,29 @@ function test_speedy_ship() end u1.ship = ship.create(r1, "dragonship") u2.ship = u1.ship - u1:set_skill("sailing", 2) -- cptskill = 2 + u1:set_skill("sailing", 2) -- cptskill = 2^1 u2:set_skill("sailing", 24) -- sumskill = 50 + u1.name = "XXX" u1:add_order("NACH O O O O O O O O O O") + print(u1.region) process_orders() + print(u1.region) assert_equal(5, u1.region.x) end + +function test_speedy_ship_fast() + local r1 = region.create(0, 0, 'ocean') + local f = faction.create("human") + f.name="Vikings" + local u1 = unit.create(f, r1, 1) + u1.name = "Hagar" + for x = 1, 10 do + region.create(x, 0, 'ocean') + end + u1.ship = ship.create(r1, "dragonship") + u1:set_skill("sailing", 64) -- cptskill = 2^6 + u1:add_order("NACH O O O O O O O O O O") + process_orders() + print(f, get_turn()) + assert_equal(10, u1.region.x) +end