58 static const char *archs[] = {
69 "helmet_of_brilliance",
94 static const char *arch_results[] = {
101 "(slow movement)(wield weapon)(archer)(wear armour)(wear ring)",
103 "(dam+6)(weapon speed 10)(Attacks: physical)",
104 "(wc+1)(dam+15)(Firing delay 1.43)(Attacks: physical)",
105 "(Int+2)(Pow+2)(ac+2)(item_power +5)(magic+1)[color=#FF15CD](armour +5)[/color]",
106 "(Str+1)(Wis+2)(Cha+2)(dam+15)(item_power +25)(weapon speed 6)(Attacks: weaponmagic, blinding)[color=#930C76](resist magic +30)[/color][ul](resist drain +100)[/ul]",
107 "(dam+8)(weapon speed 8)(Attacks: physical)",
108 "(ac+1)[color=#FF15CD](armour +5)[/color]",
110 "(food+65)(slay vial_poison:poison)",
112 "(extremely fast movement)(undead)(spellcaster)(Spell abilities:)(paralyze)(fear ability)(cause black death)(cause red death)(face of death)(meteor swarm)(hellfire)(burning hands)(large fireball)(mass confusion)(negative energy bolt)(negative energy ball)(slow ability)(Attacks: physical, cold)(armour +75)(resist magic +100)(resist fire +100)(resist electricity +90)(resist cold +100)(resist confusion +100)(resist acid +90)(resist drain +100)(resist weaponmagic +80)(resist ghosthit +100)(resist poison +100)(resist slow +100)(resist paralyzation +100)(resist fear +100)(resist cancellation +65)(resist depletion +100)(resist death +100)(resist chaos +100)(resist counterspell +65)(resist god power +80)(resist blindness +100)",
113 "(slow movement)(undead)(Attacks: physical)(resist cold +50)(resist fear +100)",
116 "(normal movement)(see invisible)(spellcaster)(Spell abilities:)(breath flame)(medium fireball ability)(fear ability)(Attacks: physical)(resist fire +100)(resist cold -100)(resist confusion -100)(resist fear +100)(resist blindness +50)",
117 "(fast movement)(see invisible)(wield weapon)(archer)(wear armour)(wear ring)(read scroll)(fires wand/rod/horn)(spellcaster)(Spell abilities:)(paralyze)(fear ability)(small lightning)(large lightning)(slow ability)(resist magic +50)(resist electricity +100)(resist fear +100)",
118 "(speed +6)(item_power +6)[color=#FF15CD](armour +3)[/color]",
119 "(dam+3)(weapon speed 2)(Attacks: physical)",
120 "(Con+2)(item_power +1)",
121 "(Str+2)(Dex-1)(dam+3)(item_power +2)[color=#FF15CD](armour +5)[/color]",
122 "(Str+2)(dam+3)(item_power +1)[color=#FF15CD](armour +5)[/color]",
123 "(Cha+1)(ac+1)(Spell regen penalty 4)[color=#FF15CD](armour +4)[/color](resist blindness +1)",
124 "(ac+5)(Max speed 0.70)(Spell regen penalty 30)[color=#FF15CD](armour +40)[/color]",
125 "(ac+1)(Max speed 1.20)",
126 "(ac+3)(Max speed 0.90)(Spell regen penalty 10)[color=#FF15CD](armour +20)[/color]",
127 "(Cha-5)(ac+7)(item_power +10)(reflect spells)(reflect missiles)[color=#FF15CD](armour +15)[/color][color=red](resist fire +30)[/color][ul](resist drain +100)[/ul](resist ghosthit +80)",
128 "(ac+4)(item_power +6)[color=#FF15CD](armour +10)[/color][ul](resist drain +100)[/ul](resist ghosthit +50)",
134 static const char *treasures[] = {
149 static const char *treasure_results[] = {
151 "(wc+2)(dam+3)(Attacks: physical)",
153 "(dam+11)(weapon speed 9)(Attacks: physical)",
155 "(item_power +3)(lifesaving)",
158 "(Con+2)(Cha-1)(dam+10)(item_power +15)(weapon speed 5)(regeneration+1)(Attacks: weaponmagic)[ul](resist drain +100)[/ul][color=green](resist poison +30)[/color]",
160 "(dam+5)(item_power +4)(weapon speed 4)(slay troll)(Attacks: physical)",
161 "(dam+1)(weapon speed 5)(Attacks: physical)",
189 FAIL_IF(test == NULL,
"couldn't create item from treasure list %s", treasures[
check]);
208 #define DESCRIBE_PATH_SAFE(retbuf, variable, name, len, maxlen) \
211 safe_strcat(retbuf, "(" name ": ", len, maxlen); \
212 for (i = 0; i < NRSPELLPATHS; i++) \
213 if (variable&(1<<i)) { \
215 safe_strcat(retbuf, ", ", len, maxlen); \
218 safe_strcat(retbuf, spellpathnames[i], len, maxlen); \
220 safe_strcat(retbuf, ")", len, maxlen); \
223 #define DESCRIBE_ABILITY_SAFE(retbuf, variable, name, len, maxlen) \
226 safe_strcat(retbuf, "(" name ": ", len, maxlen); \
227 for (i = 0; i < NROFATTACKS; i++) \
228 if (variable&(1<<i)) { \
230 safe_strcat(retbuf, ", ", len, maxlen); \
233 safe_strcat(retbuf, attacks[i], len, maxlen); \
235 safe_strcat(retbuf, ")", len, maxlen); \
249 switch ((
int)((
FABS(
op->speed))*15)) {
251 snprintf(retbuf, size,
"(very slow movement)");
255 snprintf(retbuf, size,
"(slow movement)");
259 snprintf(retbuf, size,
"(normal movement)");
264 snprintf(retbuf, size,
"(fast movement)");
269 snprintf(retbuf, size,
"(very fast movement)");
276 snprintf(retbuf, size,
"(extremely fast movement)");
280 snprintf(retbuf, size,
"(lightning fast movement)");
285 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(undead)");
287 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(see invisible)");
289 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(wield weapon)");
291 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(archer)");
293 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(wear armour)");
295 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(wear ring)");
297 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(read scroll)");
299 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(fires wand/rod/horn)");
301 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(skill user)");
303 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(spellcaster)");
305 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(friendly)");
307 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(unaggressive)");
309 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(hitback)");
311 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(stealthy)");
312 if (
op->randomitems != NULL) {
316 for (
t =
op->randomitems->items;
t != NULL;
t =
t->next)
317 if (
t->item && (
t->item->clone.type ==
SPELL)) {
320 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(Spell abilities:)");
322 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(%s)",
t->item->clone.name);
326 if (
op->contr->digestion) {
327 if (
op->contr->digestion != 0)
328 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(sustenance%+d)",
op->contr->digestion);
330 if (
op->contr->gen_grace) {
331 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(grace%+d)",
op->contr->gen_grace);
333 if (
op->contr->gen_sp) {
334 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(magic%+d)",
op->contr->gen_sp);
336 if (
op->contr->gen_hp) {
337 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(regeneration%+d)",
op->contr->gen_hp);
339 if (
op->stats.luck) {
340 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(luck%+d)",
op->stats.luck);
345 len = strlen(retbuf);
354 if (
tmp &&
tmp->attacktype != 0) {
367 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(%s %+d)",
resist_plus[i],
op->resist[i]);
377 memset(&
pl, 0,
sizeof(
pl));
389 FAIL_UNLESS(strcmp(
buf, compat) == 0,
"(compat) description change:\n%s\n === vs ===\n%s",
buf, compat);
394 FAIL_UNLESS(strcmp(
buf,
final) == 0,
"description change: \"%s\" vs \"%s\"",
buf,
final);
402 Suite *s = suite_create(
"item");
403 TCase *tc_core = tcase_create(
"Core");
408 suite_add_tcase(s, tc_core);
409 tcase_add_test(tc_core, test_describe_item);
410 tcase_add_test(tc_core, test_describe_monster_rewrite);
424 printf(
"Skipping item test - need glibc to get same results to check against\n");
429 SRunner *sr = srunner_create(s);
432 srunner_set_fork_status(sr, CK_NOFORK);
434 srunner_set_xml(sr, LOGDIR
"/unit/common/item.xml");
435 srunner_set_log(sr, LOGDIR
"/unit/common/item.out");
436 srunner_run_all(sr, CK_ENV);
437 nf = srunner_ntests_failed(sr);
439 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;