53 #define TEST_MAP_SIZE 40
54 #define NUM_TICKS_TO_RUN 500
55 #define NUM_COMETS_TO_CAST 30
56 #define STARTING_HP 25000
83 fail_unless(mon != NULL,
"Unable to find orc object");
109 mon1->
y = TEST_MAP_SIZE/2;
113 if (x != TEST_MAP_SIZE/2) {
133 #ifdef PRINT_DEBUG_HP
134 printf(
"\nDumping debug hp for test %s\n ", test);
141 our_mon =
GET_MAP_OB(test_map, x, TEST_MAP_SIZE/2);
143 fail(
"Monster destroyed at %d, %d\n", x, TEST_MAP_SIZE/2);
146 fail_unless(mon->
name == our_mon->
name,
"Could not find our monster on the space?");
148 #ifdef PRINT_DEBUG_HP
149 printf(
"%d, ", our_mon->
stats.
hp);
152 if (our_mon->
stats.
hp == hp_row[x]) {
154 }
else if (our_mon->
stats.
hp < hp_row[x]) {
161 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);
166 #ifdef PRINT_DEBUG_HP
173 fprintf(stderr,
"Monster destroyed at %d, %d\n", x, x);
177 fail_unless(mon->
name == our_mon->
name,
"Could not find our monster on the space?");
179 #ifdef PRINT_DEBUG_HP
180 printf(
"%d, ", our_mon->
stats.
hp);
182 if (our_mon->
stats.
hp == hp_diag[x]) {
184 }
else if (our_mon->
stats.
hp < hp_diag[x]) {
191 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);
198 int hp_row[
TEST_MAP_SIZE] = {25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 24895, 24890, 24885, 24880, 24875, 24870, 24865, 24860, 24855, 24850, 24845, 24840, 24827, 24840, 24845, 24850, 24855, 24860, 24865, 24870, 24875, 24880, 24885, 24890, 24895, 25000, 25000, 25000, 25000, 25000, 25000, 25000 },
199 hp_diag[
TEST_MAP_SIZE] = {25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 24895, 24890, 24885, 24880, 24875, 24870, 24865, 24860, 24855, 24850, 24845, 24840, 24827, 24840, 24845, 24850, 24855, 24860, 24865, 24870, 24875, 24880, 24885, 24890, 24895, 25000, 25000, 25000, 25000, 25000, 25000, 25000 };
219 check_hp(
"cast_one_comet", hp_row, hp_diag);
225 int tick, num_cast = 0;
226 int hp_row[
TEST_MAP_SIZE] = {23522, 23380, 23217, 23172, 23137, 23007, 22882, 22762, 22655, 22527, 22412, 22407, 22307, 22312, 22217, 22235, 22235, 22217, 22312, 22412, 22412, 22470, 22620, 22770, 22915, 23060, 23200, 23335, 23365, 23400, 23535, 23670, 23800, 23930, 24055, 24180, 24200, 24325, 24445, 24565 },
227 hp_diag[
TEST_MAP_SIZE] = {25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 23215, 23025, 22830, 22745, 22570, 22510, 22360, 22315, 22280, 22255, 22340, 22425, 22412, 22312, 22317, 22330, 22317, 22417, 22522, 22632, 22647, 22672, 22815, 22945, 23062, 23192, 23327, 23467, 23512, 23675, 23825, 23970 };
248 rod->
x = (tick*59)%37;
258 check_hp(
"cast_random_comet", hp_row, hp_diag);
265 int tick, num_cast = 0;
266 int hp_row[
TEST_MAP_SIZE] = {25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 21850, 21700, 21550, 21400, 21250, 21100, 20950, 20800, 20650, 20500, 20350, 20200, 19810, 20200, 20350, 20500, 20650, 20800, 20950, 21100, 21250, 21400, 21550, 21700, 21850, 25000, 25000, 25000, 25000, 25000, 25000, 25000 },
267 hp_diag[
TEST_MAP_SIZE] = {25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 21850, 21700, 21550, 21400, 21250, 21100, 20950, 20800, 20650, 20500, 20350, 20200, 19810, 20200, 20350, 20500, 20650, 20800, 20950, 21100, 21250, 21400, 21550, 21700, 21850, 25000, 25000, 25000, 25000, 25000, 25000, 25000 };
287 check_hp(
"cast_bunch_comet", hp_row, hp_diag);
293 Suite *s = suite_create(
"comet");
294 TCase *tc_core = tcase_create(
"Core");
301 tcase_set_timeout(tc_core, 20);
306 suite_add_tcase(s, tc_core);
307 tcase_add_test(tc_core, cast_one_comet);
308 tcase_add_test(tc_core, cast_bunch_comet);
309 tcase_add_test(tc_core, cast_random_comet);
318 SRunner *sr = srunner_create(s);
324 srunner_set_fork_status(sr, CK_NOFORK);
329 srunner_set_xml(sr, LOGDIR
"/unit/server/comet.xml");
330 srunner_set_log(sr, LOGDIR
"/unit/server/comet.out");
331 srunner_run_all(sr, CK_ENV);
332 nf = srunner_ntests_failed(sr);
335 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
END_TEST Suite * comet_suite(void)
struct Statistics statistics
mapstruct * get_empty_map(int sizex, int sizey)
uint64 spell_suppressions
START_TEST(cast_one_comet)
void free_map(mapstruct *m)
#define NUM_COMETS_TO_CAST
void remove_ob(object *op)
object * create_archetype(const char *name)
void init(int argc, char **argv)
void process_events(void)
object * insert_ob_in_ob(object *op, object *where)
object * get_object(void)
object * insert_ob_in_map(object *op, mapstruct *m, object *originator, int flag)
sint16 resist[NROFATTACKS]
void update_ob_speed(object *op)
#define GET_MAP_OB(M, X, Y)
void copy_object(object *op2, object *op)
void check_hp(const char *test, int hp_row[TEST_MAP_SIZE], int hp_diag[TEST_MAP_SIZE])
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)