static void test_monsters_attack_ocean(CuTest * tc) { faction *f, *f2; region *r; unit *u, *m; create_monsters(&f, &f2, &u, &m); r = findregion(-1, 0); // ocean u = test_create_unit(u->faction, r); unit_setid(u, 2); m = test_create_unit(m->faction, r); assert(!m->region->land); config_set("rules.monsters.attack_chance", "1"); plan_monsters(f2); CuAssertPtrNotNull(tc, find_order("attack 2", m)); test_cleanup(); }
static void test_seaserpent_piracy(CuTest * tc) { faction *f, *f2; region *r; unit *u, *m; race *rc; create_monsters(&f, &f2, &u, &m); r = findregion(-1, 0); // ocean u = test_create_unit(u->faction, r); unit_setid(u, 2); m = test_create_unit(m->faction, r); u_setrace(m, rc = test_create_race("seaserpent")); assert(!m->region->land); fset(m, UFL_MOVED); fset(rc, RCF_ATTACK_MOVED); config_set("rules.monsters.attack_chance", "1"); plan_monsters(f2); CuAssertPtrNotNull(tc, find_order("piracy", m)); CuAssertPtrNotNull(tc, find_order("attack 2", m)); test_cleanup(); }
static void create_monsters(faction **player, faction **monsters, unit **u, unit **m) { race* rc; region *r; test_cleanup(); test_create_horse(); default_locale = test_create_locale(); *player = test_create_faction(NULL); *monsters = get_or_create_monsters(); assert(rc_find((*monsters)->race->_name)); rc = rc_get_or_create((*monsters)->race->_name); fset(rc, RCF_UNARMEDGUARD|RCF_NPC|RCF_DRAGON); fset(*monsters, FFL_NOIDLEOUT); assert(fval(*monsters, FFL_NPC) && fval((*monsters)->race, RCF_UNARMEDGUARD) && fval((*monsters)->race, RCF_NPC) && fval(*monsters, FFL_NOIDLEOUT)); test_create_region(-1, 0, test_create_terrain("ocean", SEA_REGION | SWIM_INTO | FLY_INTO)); test_create_region(1, 0, 0); r = test_create_region(0, 0, 0); *u = test_create_unit(*player, r); unit_setid(*u, 1); *m = test_create_unit(*monsters, r); }
static void create_monsters(faction **player, faction **monsters, region **r, unit **u, unit **m) { race* rc; test_cleanup(); init_language(); test_create_world(); *player = test_create_faction(NULL); *monsters = get_or_create_monsters(); assert(rc_find((*monsters)->race->_name)); rc = rc_get_or_create((*monsters)->race->_name); fset(rc, RCF_UNARMEDGUARD); fset(rc, RCF_NPC); fset(*monsters, FFL_NOIDLEOUT); assert(fval(*monsters, FFL_NPC) && fval((*monsters)->race, RCF_UNARMEDGUARD) && fval((*monsters)->race, RCF_NPC) && fval(*monsters, FFL_NOIDLEOUT)); (*monsters)->locale = default_locale; *r = findregion(0, 0); *u = test_create_unit(*player, *r); unit_setid(*u, 1); *m = test_create_unit(*monsters, *r); }