Test E2 items in E2 only.

Remove eye of demon (broken item).
This commit is contained in:
Enno Rehling 2017-02-27 18:50:48 +01:00
parent 1a0992e37b
commit 1b93c14806
16 changed files with 180 additions and 254 deletions

View File

@ -61,14 +61,8 @@
<item weight="0" score="6000"/>
</resource>
<resource name="aoc" appearance="amulet">
<item weight="100" use="yes" />
</resource>
<resource name="dreameye">
<item weight="100">
<function name="use" value="use_tacticcrystal"/>
</item>
<item weight="100" use="yes" />
</resource>
<resource name="pegasus">
@ -105,16 +99,12 @@
<resource name="skillpotion" appearance="vial">
<!-- gives user one free learning attempt -->
<item weight="0">
<function name="use" value="use_skillpotion"/>
</item>
<item weight="0" use="yes" />
</resource>
<resource name="manacrystal" appearance="amulet">
<!-- gives user free aura -->
<item weight="0">
<function name="use" value="use_manacrystal"/>
</item>
<item weight="0" use="yes" />
</resource>
<!-- xmas items -->

View File

@ -1458,12 +1458,6 @@
<string name="aots_p">
<text locale="de">Amulette des wahren Sehens</text>
</string>
<string name="aoc">
<text locale="de">Katzenamulett</text>
</string>
<string name="aoc_p">
<text locale="de">Katzenamulette</text>
</string>
<string name="roi">
<text locale="de">Ring der Unsichtbarkeit</text>
</string>

View File

@ -444,12 +444,6 @@
<string name="ao_chastity_p">
<text locale="en">amulets of chastity</text>
</string>
<string name="aoc">
<text locale="en">amulet of the kitten</text>
</string>
<string name="aoc_p">
<text locale="en">amulets of the kitten</text>
</string>
<string name="aod">
<text locale="en">amulet of darkness</text>
</string>

View File

@ -458,12 +458,6 @@
<string name="ao_chastity_p">
<text locale="fr">amulettes de chasteté</text>
</string>
<string name="aoc">
<text locale="fr">amulette du chaton</text>
</string>
<string name="aoc_p">
<text locale="fr">amulettes du chaton</text>
</string>
<string name="aod">
<text locale="fr">amulette de ténčbres</text>
</string>

View File

@ -86,6 +86,10 @@
<item notlost="yes" cursed="true" weight="0"/>
</resource>
<resource name="aoc" appearance="amulet">
<item weight="100" use="yes" />
</resource>
<resource name="eyeofdragon">
<!-- the arena gate, for one-time entry -->
<item weight="0" score="0"/>

View File

@ -392,5 +392,14 @@
<text locale="de">Adamantiumrüstungen</text>
<text locale="en">adamantium plates</text>
</string>
<string name="aoc">
<text locale="de">Katzenamulett</text>
<text locale="en">amulet of the kitten</text>
<text locale="fr">amulette du chaton</text>
</string>
<string name="aoc_p">
<text locale="en">amulets of the kitten</text>
<text locale="de">Katzenamulette</text>
<text locale="fr">amulettes du chaton</text>
</string>
</strings>

View File

@ -8,6 +8,7 @@ require 'tests.e2.destroy'
require 'tests.e2.guard'
require 'tests.e2.spells'
require 'tests.e2.stealth'
require 'tests.e2.items'
require 'tests.items'
require 'tests.orders'
require 'tests.common'

109
scripts/tests/e2/items.lua Normal file
View File

@ -0,0 +1,109 @@
require "lunit"
module("tests.items", package.seeall, lunit.testcase )
function setup()
eressea.free_game()
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.ship.storms", "0")
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("magic.regeneration.enable", "0")
end
function test_meow()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("aoc", 1)
u:clear_orders()
u:add_order("BENUTZEN 1 Katzenamulett")
process_orders()
assert_equal(1, u:get_item("aoc"))
assert_equal(1, r:count_msg_type('meow'))
end
function test_aurapotion50()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("aurapotion50", 1)
u:set_skill('magic', 10);
u.magic = 'gwyrrd'
u.aura = 0
u:clear_orders()
u:add_order("BENUTZEN 1 Auratrank")
process_orders()
assert_equal(0, u:get_item("aurapotion50"))
assert_equal(1, f:count_msg_type('aurapotion50'))
assert_equal(50, u.aura)
end
function test_bagpipe()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("bagpipeoffear", 1)
u:clear_orders()
u:add_order("BENUTZEN 1 Dudelsack")
process_orders()
assert_equal(1, u:get_item("bagpipeoffear"))
assert_equal(1, f:count_msg_type('bagpipeoffear_faction'))
assert_equal(1, r:count_msg_type('bagpipeoffear_region'))
end
function test_speedsail()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.ship = ship.create(r, "boat")
u:add_item("speedsail", 2)
u:clear_orders()
u:add_order("BENUTZEN 1 Sonnensegel")
process_orders()
assert_equal(1, u:get_item("speedsail"))
assert_equal(1, f:count_msg_type('use_speedsail'))
end
function test_foolpotion()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("p7", 1)
u:clear_orders()
u:add_order("BENUTZEN 1 Dumpfbackenbrot 4242")
process_orders()
assert_equal(1, u:get_item("p7"))
assert_equal(1, f:count_msg_type('feedback_unit_not_found'))
local u2 = unit.create(f, r, 1)
u:clear_orders()
u:add_order("BENUTZEN 1 Dumpfbackenbrot " .. itoa36(u2.id))
process_orders()
assert_equal(1, u:get_item("p7"))
assert_equal(1, f:count_msg_type('error64'))
u:set_skill("stealth", 1);
process_orders()
assert_equal(0, u:get_item("p7"))
assert_equal(1, f:count_msg_type('givedumb'))
end
function test_snowman()
local r = region.create(0, 0, "glacier")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("snowman", 1)
u:clear_orders()
u:add_order("BENUTZEN 1 Schneemann")
process_orders()
for u2 in r.units do
if u2.id~=u.id then
assert_equal("snowman", u2.race)
assert_equal(1000, u2.hp)
u = nil
break
end
end
assert_equal(nil, u)
end

View File

@ -6,6 +6,7 @@ require 'tests.e3.parser'
require 'tests.e3.morale'
require 'tests.orders'
require 'tests.common'
require 'tests.items'
-- require 'tests.report'
require 'tests.magicbag'
require 'tests.process'

View File

@ -8,61 +8,35 @@ function setup()
eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.ship.storms", "0")
eressea.settings.set("rules.encounters", "0")
end
function test_meow()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("aoc", 1)
u:clear_orders()
u:add_order("BENUTZEN 1 Katzenamulett")
process_orders()
assert_equal(1, u:get_item("aoc"))
assert_equal(1, r:count_msg_type('meow'))
end
function test_aurapotion50()
eressea.settings.set("magic.regeneration.enable", "0")
end
function test_dreameye()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("aurapotion50", 1)
u:set_skill('magic', 10);
u.magic = 'gwyrrd'
u:add_item("dreameye", 2)
u:clear_orders()
u:add_order("BENUTZEN 1 Traumauge")
process_orders()
assert_equal(1, u:get_item("dreameye"))
assert_equal(1, f:count_msg_type('use_tacticcrystal'))
end
function test_manacrystal()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("manacrystal", 2)
u:clear_orders()
u.magic = "gwyrrd"
u:set_skill('magic', 1)
u.aura = 0
u:clear_orders()
u:add_order("BENUTZEN 1 Auratrank")
u:add_order("BENUTZEN 1 Astralkristall")
process_orders()
assert_equal(0, u:get_item("aurapotion50"))
assert_equal(1, f:count_msg_type('aurapotion50'))
assert_equal(50, u.aura)
end
function test_bagpipe()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("bagpipeoffear", 1)
u:clear_orders()
u:add_order("BENUTZEN 1 Dudelsack")
process_orders()
assert_equal(1, u:get_item("bagpipeoffear"))
assert_equal(1, f:count_msg_type('bagpipeoffear_faction'))
assert_equal(1, r:count_msg_type('bagpipeoffear_region'))
end
function test_speedsail()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u.ship = ship.create(r, "boat")
u:add_item("speedsail", 2)
u:clear_orders()
u:add_order("BENUTZEN 1 Sonnensegel")
process_orders()
assert_equal(1, u:get_item("speedsail"))
assert_equal(1, f:count_msg_type('use_speedsail'))
assert_equal(1, u:get_item("manacrystal"))
assert_equal(25, u.aura)
assert_equal(1, f:count_msg_type('manacrystal_use'))
end
function test_skillpotion()
@ -141,46 +115,3 @@ function test_bloodpotion_other()
assert_equal(1, f:count_msg_type('usepotion'))
assert_equal("smurf", u.race)
end
function test_foolpotion()
local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("p7", 1)
u:clear_orders()
u:add_order("BENUTZEN 1 Dumpfbackenbrot 4242")
process_orders()
assert_equal(1, u:get_item("p7"))
assert_equal(1, f:count_msg_type('feedback_unit_not_found'))
local u2 = unit.create(f, r, 1)
u:clear_orders()
u:add_order("BENUTZEN 1 Dumpfbackenbrot " .. itoa36(u2.id))
process_orders()
assert_equal(1, u:get_item("p7"))
assert_equal(1, f:count_msg_type('error64'))
u:set_skill("stealth", 1);
process_orders()
assert_equal(0, u:get_item("p7"))
assert_equal(1, f:count_msg_type('givedumb'))
end
function test_snowman()
local r = region.create(0, 0, "glacier")
local f = faction.create("noreply@eressea.de", "human", "de")
local u = unit.create(f, r, 1)
u:add_item("snowman", 1)
u:clear_orders()
u:add_order("BENUTZEN 1 Schneemann")
process_orders()
for u2 in r.units do
if u2.id~=u.id then
assert_equal("snowman", u2.race)
assert_equal(1000, u2.hp)
u = nil
break
end
end
assert_equal(nil, u)
end

View File

@ -21,8 +21,6 @@
#include <kernel/spell.h>
#include <kernel/unit.h>
#include <items/demonseye.h>
/* triggers includes */
#include <triggers/changerace.h>
#include <triggers/timeout.h>
@ -340,11 +338,38 @@ struct order *ord)
return 0;
}
/* ------------------------------------------------------------- */
/* Kann auch von Nichtmagier benutzt werden, modifiziert Taktik fuer diese
* Runde um -1 - 4 Punkte. */
static int
use_tacticcrystal(unit * u, const struct item_type *itype, int amount,
struct order *ord)
{
int i;
for (i = 0; i != amount; ++i) {
int duration = 1; /* wirkt nur eine Runde */
curse *c;
float effect;
float power = 5; /* Widerstand gegen Antimagiesprueche, ist in diesem
Fall egal, da der curse fuer den Kampf gelten soll,
der vor den Antimagiezaubern passiert */
effect = (float)(rng_int() % 6 - 1);
c = create_curse(u, &u->attribs, ct_find("skillmod"), power,
duration, effect, u->number);
c->data.i = SK_TACTICS;
UNUSED_ARG(ord);
}
use_pooled(u, itype->rtype, GET_DEFAULT, amount);
ADDMSG(&u->faction->msgs, msg_message("use_tacticcrystal",
"unit region", u, u->region));
return 0;
}
void register_itemfunctions(void)
{
register_demonseye();
/* have tests: */
register_item_use(use_tacticcrystal, "use_dreameye");
register_item_use(use_studypotion, "use_studypotion");
register_item_use(use_antimagiccrystal, "use_antimagic");
register_item_use(use_speedsail, "use_speedsail");

View File

@ -5,7 +5,6 @@ xerewards.test.c
)
SET(_FILES
demonseye.c
speedsail.c
weapons.c
xerewards.c

View File

@ -1,65 +0,0 @@
/*
Copyright (c) 1998-2015, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/
#include <platform.h>
#include "demonseye.h"
/* kernel includes */
#include <kernel/faction.h>
#include <kernel/item.h>
#include <kernel/messages.h>
#include <kernel/plane.h>
#include <kernel/region.h>
#include <kernel/unit.h>
/* util includes */
#include <util/functions.h>
/* libc includes */
#include <assert.h>
static int
summon_igjarjuk(struct unit *u, const struct item_type *itype, int amount,
struct order *ord)
{
struct plane *p = rplane(u->region);
UNUSED_ARG(amount);
UNUSED_ARG(itype);
if (p != NULL) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "use_realworld_only", ""));
return EUNUSABLE;
}
else {
assert(!"not implemented");
return EUNUSABLE;
}
}
static int
give_igjarjuk(struct unit *src, struct unit *d, const struct item_type *itype,
int n, struct order *ord)
{
ADDMSG(&src->faction->msgs, msg_feedback(src, ord, "error_giveeye", ""));
return 0;
}
void register_demonseye(void)
{
register_item_use(summon_igjarjuk, "useigjarjuk");
register_item_give(give_igjarjuk, "giveigjarjuk");
}

View File

@ -1,30 +0,0 @@
/*
Copyright (c) 1998-2015, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/
#ifndef H_ITM_DEMONSEYE
#define H_ITM_DEMONSEYE
#ifdef __cplusplus
extern "C" {
#endif
void register_demonseye(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -677,34 +677,6 @@ int set_item(unit * u, const item_type *itype, int value)
#define FL_ITEM_ANIMAL (1<<3) /* ist ein Tier */
#define FL_ITEM_MOUNT ((1<<4) | FL_ITEM_ANIMAL) /* ist ein Reittier */
/* ------------------------------------------------------------- */
/* Kann auch von Nichtmagier benutzt werden, modifiziert Taktik fuer diese
* Runde um -1 - 4 Punkte. */
static int
use_tacticcrystal(unit * u, const struct item_type *itype, int amount,
struct order *ord)
{
int i;
for (i = 0; i != amount; ++i) {
int duration = 1; /* wirkt nur eine Runde */
curse *c;
float effect;
float power = 5; /* Widerstand gegen Antimagiesprueche, ist in diesem
Fall egal, da der curse fuer den Kampf gelten soll,
der vor den Antimagiezaubern passiert */
effect = (float)(rng_int() % 6 - 1);
c = create_curse(u, &u->attribs, ct_find("skillmod"), power,
duration, effect, u->number);
c->data.i = SK_TACTICS;
UNUSED_ARG(ord);
}
use_pooled(u, itype->rtype, GET_DEFAULT, amount);
ADDMSG(&u->faction->msgs, msg_message("use_tacticcrystal",
"unit region", u, u->region));
return 0;
}
typedef struct t_item {
const char *name;
/* [0]: Einzahl fuer eigene; [1]: Mehrzahl fuer eigene;
@ -1165,7 +1137,6 @@ void register_resources(void)
register_item_use(use_potion_delayed, "use_p2");
register_item_use(use_warmthpotion, "use_nestwarmth");
register_item_use(use_tacticcrystal, "use_tacticcrystal");
register_item_use(use_mistletoe, "usemistletoe");
register_item_use(use_magicboost, "usemagicboost");
register_item_use(use_snowball, "usesnowball");

View File

@ -16,7 +16,6 @@
#include <kernel/command.h>
/* misc includes */
#include <items/demonseye.h>
#include <attributes/key.h>
#include <triggers/gate.h>