54 #define TEST_MAP_SIZE 40 55 #define NUM_TICKS_TO_RUN 500 56 #define NUM_COMETS_TO_CAST 30 57 #define STARTING_HP 25000 84 fail_unless(
mon != NULL,
"Unable to find orc object");
95 mon->speed_left = 0.0;
111 if (x != TEST_MAP_SIZE/2) {
128 #ifdef PRINT_DEBUG_HP 129 printf(
"\nDumping debug hp for test %s\n ", test);
136 our_mon =
GET_MAP_OB(test_map, x, TEST_MAP_SIZE/2);
138 fail(
"Monster destroyed at %d, %d\n", x, TEST_MAP_SIZE/2);
141 fail_unless(
mon->name == our_mon->name,
"Could not find our monster on the space?");
143 #ifdef PRINT_DEBUG_HP 144 printf(
"%d, ", our_mon->stats.hp);
147 if (our_mon->stats.hp == hp_row[x]) {
149 }
else if (our_mon->stats.hp < hp_row[x]) {
156 fail(
"Mon (%d, %d) has hp out of range (%d != %d +/- %d, diff %d)\n", our_mon->x, our_mon->y, our_mon->stats.hp, hp_row[x],
HP_DELTA, diff);
161 #ifdef PRINT_DEBUG_HP 168 fprintf(stderr,
"Monster destroyed at %d, %d\n", x, x);
172 fail_unless(
mon->name == our_mon->name,
"Could not find our monster on the space?");
174 #ifdef PRINT_DEBUG_HP 175 printf(
"%d, ", our_mon->stats.hp);
177 if (our_mon->stats.hp == hp_diag[x]) {
179 }
else if (our_mon->stats.hp < hp_diag[x]) {
186 fail(
"Mon (%d, %d) has hp out of range (%d != %d +/- %d, diff %d)\n", our_mon->x, our_mon->y, our_mon->stats.hp, hp_diag[x],
HP_DELTA, diff);
193 int hp_row[
TEST_MAP_SIZE] = {25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 24924, 24920, 24916, 24912, 24908, 24904, 24900, 24896, 24892, 24888, 24884, 24880, 24869, 24880, 24884, 24888, 24892, 24896, 24900, 24904, 24908, 24912, 24916, 24920, 24924, 25000, 25000, 25000, 25000, 25000, 25000, 25000 },
194 hp_diag[
TEST_MAP_SIZE] = {25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 24924, 24920, 24916, 24912, 24908, 24904, 24900, 24896, 24892, 24888, 24884, 24880, 24869, 24880, 24884, 24888, 24892, 24896, 24900, 24904, 24908, 24912, 24916, 24920, 24924, 25000, 25000, 25000, 25000, 25000, 25000, 25000 };
210 check_hp(
"cast_one_comet", hp_row, hp_diag);
216 int tick, num_cast = 0;
217 int hp_row[
TEST_MAP_SIZE] = {23756, 23617, 23516, 23428, 23397, 23291, 23203, 23097, 23014, 22875, 22801, 22782, 22706, 22707, 22620, 22645, 22646, 22595, 22705, 22773, 22809, 22835, 22975, 23098, 23239, 23346, 23462, 23597, 23627, 23675, 23786, 23888, 24001, 24119, 24206, 24306, 24336, 24455, 24565, 24649 },
218 hp_diag[
TEST_MAP_SIZE] = {25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 23515, 23351, 23177, 23097, 22946, 22931, 22763, 22706, 22678, 22658, 22728, 22812, 22809, 22712, 22728, 22741, 22726, 22833, 22862, 22967, 23014, 23009, 23167, 23267, 23367, 23459, 23596, 23713, 23750, 23879, 24026, 24160 };
242 check_hp(
"cast_random_comet", hp_row, hp_diag);
249 int tick, num_cast = 0;
250 int hp_row[
TEST_MAP_SIZE] = {25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 22355, 22262, 22115, 21966, 21837, 21684, 21554, 21424, 21268, 21137, 21006, 20875, 20534, 20875, 21006, 21137, 21268, 21424, 21554, 21684, 21837, 21966, 22115, 22262, 22355, 25000, 25000, 25000, 25000, 25000, 25000, 25000 },
251 hp_diag[
TEST_MAP_SIZE] = {25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 22355, 22262, 22115, 21966, 21837, 21684, 21554, 21424, 21268, 21137, 21006, 20875, 20534, 20875, 21006, 21137, 21268, 21424, 21554, 21684, 21837, 21966, 22115, 22262, 22355, 25000, 25000, 25000, 25000, 25000, 25000, 25000 };
267 check_hp(
"cast_bunch_comet", hp_row, hp_diag);
273 Suite *s = suite_create(
"comet");
274 TCase *tc_core = tcase_create(
"Core");
281 tcase_set_timeout(tc_core, 20);
286 suite_add_tcase(s, tc_core);
287 tcase_add_test(tc_core, cast_one_comet);
288 tcase_add_test(tc_core, cast_bunch_comet);
289 tcase_add_test(tc_core, cast_random_comet);
298 SRunner *sr = srunner_create(s);
304 srunner_set_fork_status(sr, CK_NOFORK);
310 srunner_set_xml(sr, LOGDIR
"/unit/server/comet.xml");
311 srunner_set_log(sr, LOGDIR
"/unit/server/comet.out");
312 srunner_run_all(sr, CK_ENV);
313 nf = srunner_ntests_failed(sr);
316 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
struct Statistics statistics
mapstruct * get_empty_map(int sizex, int sizey)
START_TEST(cast_one_comet)
void free_map(mapstruct *m)
#define NUM_COMETS_TO_CAST
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
object * object_new(void)
object * object_insert_in_ob(object *op, object *where)
object * create_archetype(const char *name)
void init(int argc, char **argv)
void process_events(void)
static void check_hp(const char *test, int hp_row[TEST_MAP_SIZE], int hp_diag[TEST_MAP_SIZE])
static END_TEST Suite * comet_suite(void)
uint64_t spell_suppressions
#define GET_MAP_OB(M, X, Y)
void object_copy(const object *src_ob, object *dest_ob)
static void teardown(void)
void object_update_speed(object *op)
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
void object_remove(object *op)