Merge branch 'master' of github.com:eressea/server

This commit is contained in:
Enno Rehling 2014-06-27 07:50:08 -07:00
commit 9e21f1d05e
4 changed files with 47 additions and 15 deletions

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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

View File

@ -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()