forked from github/server
add a test for the vortex special direction before touching that code.
This commit is contained in:
parent
a9a0455207
commit
ecaeba3058
|
@ -1,9 +1,16 @@
|
|||
#include <platform.h>
|
||||
#include "kernel/types.h"
|
||||
#include <kernel/types.h>
|
||||
|
||||
#include "direction.h"
|
||||
#include "util/language.h"
|
||||
#include "tests.h"
|
||||
|
||||
#include <kernel/config.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/terrain.h>
|
||||
|
||||
#include <CuTest.h>
|
||||
|
||||
static void test_init_directions(CuTest *tc) {
|
||||
|
@ -56,6 +63,27 @@ static void test_get_direction_default(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, D_EAST, get_direction("east", lang));
|
||||
}
|
||||
|
||||
static void test_move_to_vortex(CuTest *tc) {
|
||||
region *r1, *r2, *r = 0;
|
||||
terrain_type *t_plain;
|
||||
unit *u;
|
||||
struct locale *lang;
|
||||
|
||||
test_cleanup();
|
||||
lang = get_or_create_locale("en");
|
||||
locale_setstring(lang, "vortex", "wirbel");
|
||||
init_locale(lang);
|
||||
register_special_direction("vortex");
|
||||
t_plain = test_create_terrain("plain", LAND_REGION | FOREST_REGION | WALK_INTO | CAVALRY_REGION);
|
||||
r1 = test_create_region(0, 0, t_plain);
|
||||
r2 = test_create_region(5, 0, t_plain);
|
||||
CuAssertPtrNotNull(tc, create_special_direction(r1, r2, 10, "", "vortex", true));
|
||||
u = test_create_unit(test_create_faction(rc_get_or_create("hodor")), r1);
|
||||
CuAssertIntEquals(tc, E_MOVE_NOREGION, movewhere(u, "barf", r1, &r));
|
||||
CuAssertIntEquals(tc, E_MOVE_OK, movewhere(u, "wirbel", r1, &r));
|
||||
CuAssertPtrEquals(tc, r2, r);
|
||||
}
|
||||
|
||||
#define SUITE_DISABLE_TEST(suite, test) (void)test
|
||||
|
||||
CuSuite *get_direction_suite(void)
|
||||
|
@ -64,6 +92,7 @@ CuSuite *get_direction_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_init_direction);
|
||||
SUITE_ADD_TEST(suite, test_init_directions);
|
||||
SUITE_ADD_TEST(suite, test_finddirection);
|
||||
SUITE_ADD_TEST(suite, test_move_to_vortex);
|
||||
SUITE_DISABLE_TEST(suite, test_get_direction_default);
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -331,12 +331,12 @@ region *find_special_direction(const region * r, const char *token,
|
|||
}
|
||||
|
||||
attrib *create_special_direction(region * r, region * rt, int duration,
|
||||
const char *desc, const char *keyword)
|
||||
const char *desc, const char *keyword, bool active)
|
||||
{
|
||||
attrib *a = a_add(&r->attribs, a_new(&at_direction));
|
||||
spec_direction *d = (spec_direction *) (a->data.v);
|
||||
|
||||
d->active = false;
|
||||
d->active = active;
|
||||
d->x = rt->x;
|
||||
d->y = rt->y;
|
||||
d->duration = duration;
|
||||
|
|
|
@ -195,7 +195,7 @@ extern "C" {
|
|||
struct spec_direction *special_direction(const region * from,
|
||||
const region * to);
|
||||
struct attrib *create_special_direction(struct region *r, struct region *rt,
|
||||
int duration, const char *desc, const char *keyword);
|
||||
int duration, const char *desc, const char *keyword, bool active);
|
||||
|
||||
int deathcount(const struct region *r);
|
||||
int chaoscount(const struct region *r);
|
||||
|
|
|
@ -3138,8 +3138,8 @@ static int sp_chaossuction(castorder * co)
|
|||
}
|
||||
|
||||
/* TODO: implement with a building */
|
||||
create_special_direction(r, rt, 2, "vortex_desc", "vortex");
|
||||
create_special_direction(rt, r, 2, "vortex_desc", "vortex");
|
||||
create_special_direction(r, rt, 2, "vortex_desc", "vortex", false);
|
||||
create_special_direction(rt, r, 2, "vortex_desc", "vortex", false);
|
||||
new_border(&bt_chaosgate, r, rt);
|
||||
|
||||
add_message(&r->msgs, msg_message("chaosgate_effect_1", "mage", mage));
|
||||
|
|
Loading…
Reference in New Issue