diff --git a/src/config.pkg b/src/config.pkg index 26f67c481..5c9e1ff33 100644 --- a/src/config.pkg +++ b/src/config.pkg @@ -3,8 +3,8 @@ $#include "bind_config.h" module eressea { module config { void config_reset @ reset(void); - void config_read @ read(const char *filename); - void config_parse @ parse(const char *json); + int config_read @ read(const char *filename); + int config_parse @ parse(const char *json); } } diff --git a/src/config.pkg.c b/src/config.pkg.c index d1f3aa0c6..e9ebccd10 100644 --- a/src/config.pkg.c +++ b/src/config.pkg.c @@ -64,10 +64,11 @@ static int tolua_config_eressea_config_read00(lua_State* tolua_S) { const char* filename = ((const char*) tolua_tostring(tolua_S,1,0)); { - config_read(filename); + int tolua_ret = (int) config_read(filename); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } - return 0; + return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'read'.",&tolua_err); @@ -90,10 +91,11 @@ static int tolua_config_eressea_config_parse00(lua_State* tolua_S) { const char* json = ((const char*) tolua_tostring(tolua_S,1,0)); { - config_parse(json); + int tolua_ret = (int) config_parse(json); + tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } - return 0; + return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'parse'.",&tolua_err); 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 diff --git a/tests/ships.lua b/tests/ships.lua index 6bc92983f..4dae533b2 100644 --- a/tests/ships.lua +++ b/tests/ships.lua @@ -3,7 +3,7 @@ require "lunit" module("tests.ships", package.seeall, lunit.testcase) function setup() - eressea.free_game() + eressea.game.reset() eressea.settings.set("nmr.removenewbie", "0") eressea.settings.set("nmr.timeout", "0") eressea.settings.set("rules.ships.storms", "0") @@ -39,11 +39,16 @@ function setup() "de" : { "move" : "NACH" } + }, + "strings" : { + "de" : { + "harbour" : "Hafen" + } } }]] eressea.config.reset() - eressea.config.parse(conf) + assert(eressea.config.parse(conf)==0) end function test_sail_oceans()