forked from github/server
fix running game-specific tests for E3, add them to the test suite.
This commit is contained in:
parent
db083389c7
commit
9453aff7f5
|
@ -19,4 +19,5 @@ $ROOT/$BIN_DIR/eressea/test_eressea
|
||||||
cd $ROOT
|
cd $ROOT
|
||||||
[ -e eressea.ini ] || ln -sf conf/eressea.ini
|
[ -e eressea.ini ] || ln -sf conf/eressea.ini
|
||||||
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests.lua
|
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests.lua
|
||||||
|
$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests-e3.lua
|
||||||
cd $OLDWPD
|
cd $OLDWPD
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
-- new tests 2014-06-11
|
||||||
|
|
||||||
|
path = 'scripts'
|
||||||
|
if config.source_dir ~= nil then
|
||||||
|
path = config.source_dir .. '/' .. path
|
||||||
|
end
|
||||||
|
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
||||||
|
|
||||||
|
config.rules = 'e3'
|
||||||
|
|
||||||
|
require 'eressea'
|
||||||
|
require 'eressea.path'
|
||||||
|
require 'eressea.xmlconf'
|
||||||
|
require 'tests.e3'
|
||||||
|
require 'lunit'
|
||||||
|
|
||||||
|
eressea.settings.set("rules.alliances", "0")
|
||||||
|
rules = require('eressea.' .. config.rules)
|
||||||
|
lunit.main()
|
|
@ -3,7 +3,7 @@ require "lunit"
|
||||||
module("tests.e3.castles", package.seeall, lunit.testcase )
|
module("tests.e3.castles", package.seeall, lunit.testcase )
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.game.reset()
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_small_castles()
|
function test_small_castles()
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
require 'tests.e3.castles'
|
||||||
|
require 'tests.e3.stealth'
|
||||||
|
require 'tests.e3.spells'
|
|
@ -3,7 +3,7 @@ require "lunit"
|
||||||
module("tests.e3.spells", package.seeall, lunit.testcase)
|
module("tests.e3.spells", package.seeall, lunit.testcase)
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.game.reset()
|
||||||
eressea.settings.set("magic.fumble.enable", "0")
|
eressea.settings.set("magic.fumble.enable", "0")
|
||||||
eressea.settings.set("nmr.removenewbie", "0")
|
eressea.settings.set("nmr.removenewbie", "0")
|
||||||
eressea.settings.set("nmr.timeout", "0")
|
eressea.settings.set("nmr.timeout", "0")
|
||||||
|
@ -11,7 +11,6 @@ function setup()
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_blessedharvest_lasts_n_turn()
|
function test_blessedharvest_lasts_n_turn()
|
||||||
eressea.free_game()
|
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
local f = faction.create("noreply@eressea.de", "halfling", "de")
|
local f = faction.create("noreply@eressea.de", "halfling", "de")
|
||||||
local u = unit.create(f, r)
|
local u = unit.create(f, r)
|
||||||
|
|
|
@ -6,18 +6,18 @@ local f
|
||||||
local u
|
local u
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
eressea.free_game()
|
eressea.game.reset()
|
||||||
eressea.settings.set("rules.economy.food", "4")
|
eressea.settings.set("rules.economy.food", "4")
|
||||||
|
|
||||||
local r = region.create(0,0, "plain")
|
local r = region.create(0,0, "plain")
|
||||||
f = faction.create("stealthy@eressea.de", "human", "de")
|
f = faction.create("stealth1@eressea.de", "human", "de")
|
||||||
u = unit.create(f, r, 1)
|
u = unit.create(f, r, 1)
|
||||||
f = faction.create("stealth@eressea.de", "human", "de")
|
f = faction.create("stealth2@eressea.de", "human", "de")
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_stealth_faction_on()
|
function test_stealth_faction_on()
|
||||||
u:clear_orders()
|
u:clear_orders()
|
||||||
u:add_order("TARNEN PARTEI")
|
u:add_order("TARNE PARTEI")
|
||||||
|
|
||||||
eressea.settings.set("rules.stealth.faction", 1)
|
eressea.settings.set("rules.stealth.faction", 1)
|
||||||
process_orders()
|
process_orders()
|
||||||
|
@ -27,7 +27,7 @@ end
|
||||||
|
|
||||||
function test_stealth_faction_off()
|
function test_stealth_faction_off()
|
||||||
u:clear_orders()
|
u:clear_orders()
|
||||||
u:add_order("TARNEN PARTEI")
|
u:add_order("TARNE PARTEI")
|
||||||
|
|
||||||
eressea.settings.set("rules.stealth.faction", 0)
|
eressea.settings.set("rules.stealth.faction", 0)
|
||||||
process_orders()
|
process_orders()
|
||||||
|
|
|
@ -514,6 +514,7 @@ static void reset_game(void)
|
||||||
for (f = factions; f; f = f->next) {
|
for (f = factions; f; f = f->next) {
|
||||||
f->flags &= FFL_SAVEMASK;
|
f->flags &= FFL_SAVEMASK;
|
||||||
}
|
}
|
||||||
|
init_locales();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tolua_process_orders(lua_State * L)
|
static int tolua_process_orders(lua_State * L)
|
||||||
|
|
13
src/spy.c
13
src/spy.c
|
@ -210,12 +210,13 @@ void set_factionstealth(unit * u, faction * f)
|
||||||
|
|
||||||
int setstealth_cmd(unit * u, struct order *ord)
|
int setstealth_cmd(unit * u, struct order *ord)
|
||||||
{
|
{
|
||||||
|
char token[64];
|
||||||
const char *s;
|
const char *s;
|
||||||
int level, rule;
|
int level, rule;
|
||||||
const race *trace;
|
const race *trace;
|
||||||
|
|
||||||
init_order(ord);
|
init_order(ord);
|
||||||
s = getstrtoken();
|
s = gettoken(token, sizeof(token));
|
||||||
|
|
||||||
/* Tarne ohne Parameter: Setzt maximale Tarnung */
|
/* Tarne ohne Parameter: Setzt maximale Tarnung */
|
||||||
|
|
||||||
|
@ -286,7 +287,7 @@ int setstealth_cmd(unit * u, struct order *ord)
|
||||||
/* TARNE PARTEI is disabled */
|
/* TARNE PARTEI is disabled */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s = getstrtoken();
|
s = gettoken(token, sizeof(token));
|
||||||
if (rule & 1) {
|
if (rule & 1) {
|
||||||
if (!s || *s == 0) {
|
if (!s || *s == 0) {
|
||||||
fset(u, UFL_ANON_FACTION);
|
fset(u, UFL_ANON_FACTION);
|
||||||
|
@ -299,13 +300,13 @@ int setstealth_cmd(unit * u, struct order *ord)
|
||||||
}
|
}
|
||||||
if (rule & 2) {
|
if (rule & 2) {
|
||||||
if (get_keyword(s, u->faction->locale) == K_NUMBER) {
|
if (get_keyword(s, u->faction->locale) == K_NUMBER) {
|
||||||
const char *s2 = getstrtoken();
|
s = gettoken(token, sizeof(token));
|
||||||
int nr = -1;
|
int nr = -1;
|
||||||
|
|
||||||
if (s2) {
|
if (s) {
|
||||||
nr = atoi36(s2);
|
nr = atoi36(s);
|
||||||
}
|
}
|
||||||
if (!s2 || *s2 == 0 || nr == u->faction->no) {
|
if (!s || *s == 0 || nr == u->faction->no) {
|
||||||
a_removeall(&u->attribs, &at_otherfaction);
|
a_removeall(&u->attribs, &at_otherfaction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue