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
|
||||
[ -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-e3.lua
|
||||
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,25 +3,25 @@ require "lunit"
|
|||
module("tests.e3.castles", package.seeall, lunit.testcase )
|
||||
|
||||
function setup()
|
||||
eressea.free_game()
|
||||
eressea.game.reset()
|
||||
end
|
||||
|
||||
function test_small_castles()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local f1 = faction.create("noreply@eressea.de", "human", "de")
|
||||
local u1 = unit.create(f1, r, 1)
|
||||
local f2 = faction.create("noreply@eressea.de", "halfling", "de")
|
||||
local u2 = unit.create(f2, r, 1)
|
||||
u1:add_item("money", 10000)
|
||||
local r = region.create(0, 0, "plain")
|
||||
local f1 = faction.create("noreply@eressea.de", "human", "de")
|
||||
local u1 = unit.create(f1, r, 1)
|
||||
local f2 = faction.create("noreply@eressea.de", "halfling", "de")
|
||||
local u2 = unit.create(f2, r, 1)
|
||||
u1:add_item("money", 10000)
|
||||
|
||||
local b = building.create(r, "castle")
|
||||
u2.building = b
|
||||
u1.building = b
|
||||
local b = building.create(r, "castle")
|
||||
u2.building = b
|
||||
u1.building = b
|
||||
|
||||
b.owner = u2
|
||||
assert_equal("site", b:get_typename(7))
|
||||
assert_equal("fortification", b:get_typename(8))
|
||||
b.owner = u1
|
||||
assert_equal("site", b:get_typename(9))
|
||||
assert_equal("fortification", b:get_typename(10))
|
||||
b.owner = u2
|
||||
assert_equal("site", b:get_typename(7))
|
||||
assert_equal("fortification", b:get_typename(8))
|
||||
b.owner = u1
|
||||
assert_equal("site", b:get_typename(9))
|
||||
assert_equal("fortification", b:get_typename(10))
|
||||
end
|
||||
|
|
|
@ -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)
|
||||
|
||||
function setup()
|
||||
eressea.free_game()
|
||||
eressea.game.reset()
|
||||
eressea.settings.set("magic.fumble.enable", "0")
|
||||
eressea.settings.set("nmr.removenewbie", "0")
|
||||
eressea.settings.set("nmr.timeout", "0")
|
||||
|
@ -11,7 +11,6 @@ function setup()
|
|||
end
|
||||
|
||||
function test_blessedharvest_lasts_n_turn()
|
||||
eressea.free_game()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local f = faction.create("noreply@eressea.de", "halfling", "de")
|
||||
local u = unit.create(f, r)
|
||||
|
|
|
@ -6,20 +6,20 @@ local f
|
|||
local u
|
||||
|
||||
function setup()
|
||||
eressea.free_game()
|
||||
eressea.settings.set("rules.economy.food", "4")
|
||||
eressea.game.reset()
|
||||
eressea.settings.set("rules.economy.food", "4")
|
||||
|
||||
local r = region.create(0,0, "plain")
|
||||
f = faction.create("stealthy@eressea.de", "human", "de")
|
||||
u = unit.create(f, r, 1)
|
||||
f = faction.create("stealth@eressea.de", "human", "de")
|
||||
local r = region.create(0,0, "plain")
|
||||
f = faction.create("stealth1@eressea.de", "human", "de")
|
||||
u = unit.create(f, r, 1)
|
||||
f = faction.create("stealth2@eressea.de", "human", "de")
|
||||
end
|
||||
|
||||
function test_stealth_faction_on()
|
||||
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()
|
||||
assert_not_match("Partei", report.report_unit(u, f))
|
||||
assert_match("anonym", report.report_unit(u, f))
|
||||
|
@ -27,9 +27,9 @@ end
|
|||
|
||||
function test_stealth_faction_off()
|
||||
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()
|
||||
assert_match("Partei", report.report_unit(u, f))
|
||||
assert_not_match("anonym", report.report_unit(u, f))
|
||||
|
|
|
@ -514,6 +514,7 @@ static void reset_game(void)
|
|||
for (f = factions; f; f = f->next) {
|
||||
f->flags &= FFL_SAVEMASK;
|
||||
}
|
||||
init_locales();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
char token[64];
|
||||
const char *s;
|
||||
int level, rule;
|
||||
const race *trace;
|
||||
|
||||
init_order(ord);
|
||||
s = getstrtoken();
|
||||
s = gettoken(token, sizeof(token));
|
||||
|
||||
/* Tarne ohne Parameter: Setzt maximale Tarnung */
|
||||
|
||||
|
@ -286,7 +287,7 @@ int setstealth_cmd(unit * u, struct order *ord)
|
|||
/* TARNE PARTEI is disabled */
|
||||
break;
|
||||
}
|
||||
s = getstrtoken();
|
||||
s = gettoken(token, sizeof(token));
|
||||
if (rule & 1) {
|
||||
if (!s || *s == 0) {
|
||||
fset(u, UFL_ANON_FACTION);
|
||||
|
@ -299,13 +300,13 @@ int setstealth_cmd(unit * u, struct order *ord)
|
|||
}
|
||||
if (rule & 2) {
|
||||
if (get_keyword(s, u->faction->locale) == K_NUMBER) {
|
||||
const char *s2 = getstrtoken();
|
||||
s = gettoken(token, sizeof(token));
|
||||
int nr = -1;
|
||||
|
||||
if (s2) {
|
||||
nr = atoi36(s2);
|
||||
if (s) {
|
||||
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);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue