/
item-name.cc
3314 lines (2945 loc) · 104 KB
/
item-name.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @file
* @brief Misc functions.
**/
#include "AppHdr.h"
#include "item-name.h"
#include <cctype>
#include <cstring>
#include <iomanip>
#include <sstream>
#include "areas.h"
#include "artefact.h"
#include "art-enum.h"
#include "branch.h"
#include "cio.h"
#include "colour.h"
#include "decks.h"
#include "describe.h"
#include "dgn-overview.h"
#include "english.h"
#include "env.h" // LSTATE_STILL_WINDS
#include "errors.h" // sysfail
#include "god-item.h"
#include "god-passive.h" // passive_t::want_curses, no_haste
#include "invent.h"
#include "item-prop.h"
#include "item-status-flag-type.h"
#include "items.h"
#include "item-use.h"
#include "level-state-type.h"
#include "libutil.h"
#include "makeitem.h"
#include "notes.h"
#include "options.h"
#include "orb-type.h"
#include "player.h"
#include "prompt.h"
#include "religion.h"
#include "shopping.h"
#include "showsymb.h"
#include "skills.h"
#include "spl-book.h"
#include "spl-goditem.h"
#include "state.h"
#include "stringutil.h"
#include "tag-version.h"
#include "throw.h"
#include "transform.h"
#include "unicode.h"
#include "unwind.h"
#include "viewgeom.h"
static bool _is_consonant(char let);
static char _random_vowel();
static char _random_cons();
static string _random_consonant_set(size_t seed);
static void _maybe_identify_pack_item()
{
for (auto &item : you.inv)
if (item.defined() && !get_ident_type(item))
maybe_identify_base_type(item);
}
// quant_name is useful since it prints out a different number of items
// than the item actually contains.
string quant_name(const item_def &item, int quant,
description_level_type des, bool terse)
{
// item_name now requires a "real" item, so we'll mangle a tmp
item_def tmp = item;
tmp.quantity = quant;
return tmp.name(des, terse);
}
static const char* _interesting_origin(const item_def &item)
{
if (origin_as_god_gift(item) != GOD_NO_GOD)
return "god gift";
if (item.orig_monnum == MONS_DONALD && get_equip_desc(item)
&& item.is_type(OBJ_ARMOUR, ARM_KITE_SHIELD))
{
return "Donald";
}
return nullptr;
}
/**
* What inscription should be appended to the given item's name?
*/
static string _item_inscription(const item_def &item)
{
vector<string> insparts;
if (const char *orig = _interesting_origin(item))
{
if (Options.show_god_gift == MB_TRUE
|| Options.show_god_gift == MB_MAYBE && !fully_identified(item))
{
insparts.push_back(orig);
}
}
if (is_artefact(item))
{
const string part = artefact_inscription(item);
if (!part.empty())
insparts.push_back(part);
}
if (!item.inscription.empty())
insparts.push_back(item.inscription);
if (insparts.empty())
return "";
return make_stringf(" {%s}",
comma_separated_line(begin(insparts),
end(insparts),
", ").c_str());
}
string item_def::name(description_level_type descrip, bool terse, bool ident,
bool with_inscription, bool quantity_in_words,
iflags_t ignore_flags) const
{
if (crawl_state.game_is_arena())
ignore_flags |= ISFLAG_KNOW_PLUSES | ISFLAG_COSMETIC_MASK;
if (descrip == DESC_NONE)
return "";
ostringstream buff;
const string auxname = name_aux(descrip, terse, ident, with_inscription,
ignore_flags);
const bool startvowel = is_vowel(auxname[0]);
const bool qualname = (descrip == DESC_QUALNAME);
if (descrip == DESC_INVENTORY_EQUIP || descrip == DESC_INVENTORY)
{
if (in_inventory(*this)) // actually in inventory
{
buff << index_to_letter(link);
if (terse)
buff << ") ";
else
buff << " - ";
}
else
descrip = DESC_A;
}
if (base_type == OBJ_BOOKS && book_has_title(*this))
{
if (descrip != DESC_DBNAME)
descrip = DESC_PLAIN;
}
if (terse && descrip != DESC_DBNAME)
descrip = DESC_PLAIN;
monster_flags_t corpse_flags;
// no "a dragon scales"
const bool always_plural = armour_is_hide(*this)
&& sub_type != ARM_TROLL_LEATHER_ARMOUR;
if ((base_type == OBJ_CORPSES && is_named_corpse(*this)
&& !(((corpse_flags.flags = props[CORPSE_NAME_TYPE_KEY].get_int64())
& MF_NAME_SPECIES)
&& !(corpse_flags & MF_NAME_DEFINITE))
&& !(corpse_flags & MF_NAME_SUFFIX)
&& !starts_with(get_corpse_name(*this), "shaped "))
|| item_is_orb(*this) || item_is_horn_of_geryon(*this)
|| (ident || item_type_known(*this)) && is_artefact(*this)
&& special != UNRAND_OCTOPUS_KING_RING)
{
// Artefacts always get "the" unless we just want the plain name.
switch (descrip)
{
default:
buff << "the ";
case DESC_PLAIN:
case DESC_DBNAME:
case DESC_BASENAME:
case DESC_QUALNAME:
break;
}
}
else if (quantity > 1 || always_plural)
{
switch (descrip)
{
case DESC_THE: buff << "the "; break;
case DESC_YOUR: buff << "your "; break;
case DESC_ITS: buff << "its "; break;
case DESC_A:
case DESC_INVENTORY_EQUIP:
case DESC_INVENTORY:
case DESC_PLAIN:
default:
break;
}
if (descrip != DESC_BASENAME && descrip != DESC_QUALNAME
&& descrip != DESC_DBNAME && !always_plural)
{
if (quantity_in_words)
buff << number_in_words(quantity) << " ";
else
buff << quantity << " ";
}
}
else
{
switch (descrip)
{
case DESC_THE: buff << "the "; break;
case DESC_YOUR: buff << "your "; break;
case DESC_ITS: buff << "its "; break;
case DESC_A:
case DESC_INVENTORY_EQUIP:
case DESC_INVENTORY:
buff << (startvowel ? "an " : "a "); break;
case DESC_PLAIN:
default:
break;
}
}
buff << auxname;
if (descrip == DESC_INVENTORY_EQUIP)
{
equipment_type eq = item_equip_slot(*this);
if (eq != EQ_NONE)
{
if (you.melded[eq])
buff << " (melded)";
else
{
switch (eq)
{
case EQ_WEAPON:
if (is_weapon(*this))
buff << " (weapon)";
else if (you.has_mutation(MUT_NO_GRASPING))
buff << " (in mouth)";
else
buff << " (in " << you.hand_name(false) << ")";
break;
case EQ_CLOAK:
case EQ_HELMET:
case EQ_GLOVES:
case EQ_BOOTS:
case EQ_SHIELD:
case EQ_BODY_ARMOUR:
buff << " (worn)";
break;
case EQ_LEFT_RING:
case EQ_RIGHT_RING:
case EQ_RING_ONE:
case EQ_RING_TWO:
buff << " (";
buff << ((eq == EQ_LEFT_RING || eq == EQ_RING_ONE)
? "left" : "right");
buff << " ";
buff << you.hand_name(false);
buff << ")";
break;
case EQ_AMULET:
if (you.species == SP_OCTOPODE && form_keeps_mutations())
buff << " (around mantle)";
else
buff << " (around neck)";
break;
case EQ_RING_THREE:
case EQ_RING_FOUR:
case EQ_RING_FIVE:
case EQ_RING_SIX:
case EQ_RING_SEVEN:
case EQ_RING_EIGHT:
buff << " (on tentacle)";
break;
case EQ_RING_AMULET:
buff << " (on amulet)";
break;
default:
die("Item in an invalid slot");
}
}
}
else if (you.launcher_action.item_is_quivered(*this))
buff << " (quivered ammo)";
else if (you.quiver_action.item_is_quivered(*this))
buff << " (quivered)";
}
if (descrip != DESC_BASENAME && descrip != DESC_DBNAME && with_inscription)
buff << _item_inscription(*this);
// These didn't have "cursed " prepended; add them here so that
// it comes after the inscription.
if (terse && descrip != DESC_DBNAME && descrip != DESC_BASENAME
&& !qualname
&& is_artefact(*this) && cursed())
{
buff << " (curse)";
}
return buff.str();
}
static bool _missile_brand_is_prefix(special_missile_type brand)
{
switch (brand)
{
case SPMSL_POISONED:
case SPMSL_CURARE:
case SPMSL_BLINDING:
case SPMSL_FRENZY:
case SPMSL_EXPLODING:
#if TAG_MAJOR_VERSION == 34
case SPMSL_STEEL:
#endif
case SPMSL_SILVER:
return true;
default:
return false;
}
}
static bool _missile_brand_is_postfix(special_missile_type brand)
{
return brand != SPMSL_NORMAL && !_missile_brand_is_prefix(brand);
}
const char* missile_brand_name(const item_def &item, mbn_type t)
{
const special_missile_type brand
= static_cast<special_missile_type>(item.brand);
switch (brand)
{
#if TAG_MAJOR_VERSION == 34
case SPMSL_FLAME:
return "flame";
case SPMSL_FROST:
return "frost";
#endif
case SPMSL_POISONED:
return t == MBN_NAME ? "poisoned" : "poison";
case SPMSL_CURARE:
return t == MBN_NAME ? "curare-tipped" : "curare";
#if TAG_MAJOR_VERSION == 34
case SPMSL_EXPLODING:
return t == MBN_TERSE ? "explode" : "exploding";
case SPMSL_STEEL:
return "steel";
case SPMSL_RETURNING:
return t == MBN_TERSE ? "return" : "returning";
case SPMSL_PENETRATION:
return t == MBN_TERSE ? "penet" : "penetration";
#endif
case SPMSL_SILVER:
return "silver";
#if TAG_MAJOR_VERSION == 34
case SPMSL_PARALYSIS:
return "paralysis";
case SPMSL_SLOW:
return t == MBN_TERSE ? "slow" : "slowing";
case SPMSL_SLEEP:
return t == MBN_TERSE ? "sleep" : "sleeping";
case SPMSL_CONFUSION:
return t == MBN_TERSE ? "conf" : "confusion";
case SPMSL_SICKNESS:
return t == MBN_TERSE ? "sick" : "sickness";
#endif
case SPMSL_FRENZY:
return t == MBN_NAME ? "datura-tipped" : "datura";
case SPMSL_CHAOS:
return "chaos";
case SPMSL_DISPERSAL:
return t == MBN_TERSE ? "disperse" : "dispersal";
case SPMSL_BLINDING:
return t == MBN_NAME ? "atropa-tipped" : "atropa";
case SPMSL_NORMAL:
return "";
default:
return t == MBN_TERSE ? "buggy" : "bugginess";
}
}
static const char *weapon_brands_terse[] =
{
"", "flame", "freeze", "holy", "elec",
#if TAG_MAJOR_VERSION == 34
"obsolete", "obsolete",
#endif
"venom", "protect", "drain", "speed", "vorpal",
#if TAG_MAJOR_VERSION == 34
"obsolete", "obsolete",
#endif
"vamp", "pain", "antimagic", "distort",
#if TAG_MAJOR_VERSION == 34
"obsolete", "obsolete",
#endif
"chaos",
#if TAG_MAJOR_VERSION == 34
"evade", "confuse",
#endif
"penet", "reap", "spect", "vorpal", "acid",
#if TAG_MAJOR_VERSION > 34
"confuse",
#endif
"weak",
"vuln",
"debug",
};
static const char *weapon_brands_verbose[] =
{
"", "flaming", "freezing", "holy wrath", "electrocution",
#if TAG_MAJOR_VERSION == 34
"orc slaying", "dragon slaying",
#endif
"venom", "protection", "draining", "speed", "vorpality",
#if TAG_MAJOR_VERSION == 34
"flame", "frost",
#endif
"vampirism", "pain", "antimagic", "distortion",
#if TAG_MAJOR_VERSION == 34
"reaching", "returning",
#endif
"chaos",
#if TAG_MAJOR_VERSION == 34
"evasion", "confusion",
#endif
"penetration", "reaping", "spectralizing", "vorpal", "acid",
#if TAG_MAJOR_VERSION > 34
"confusion",
#endif
"weakness",
"vulnerability",
"debug",
};
static const char *weapon_brands_adj[] =
{
"", "flaming", "freezing", "holy", "electric",
#if TAG_MAJOR_VERSION == 34
"orc-killing", "dragon-slaying",
#endif
"venomous", "protective", "draining", "fast", "vorpal",
#if TAG_MAJOR_VERSION == 34
"flaming", "freezing",
#endif
"vampiric", "painful", "antimagic", "distorting",
#if TAG_MAJOR_VERSION == 34
"reaching", "returning",
#endif
"chaotic",
#if TAG_MAJOR_VERSION == 34
"evasive", "confusing",
#endif
"penetrating", "reaping", "spectral", "vorpal", "acidic",
#if TAG_MAJOR_VERSION > 34
"confusing",
#endif
"weakening",
"will-reducing",
"debug",
};
COMPILE_CHECK(ARRAYSZ(weapon_brands_terse) == NUM_SPECIAL_WEAPONS);
COMPILE_CHECK(ARRAYSZ(weapon_brands_verbose) == NUM_SPECIAL_WEAPONS);
COMPILE_CHECK(ARRAYSZ(weapon_brands_adj) == NUM_SPECIAL_WEAPONS);
static const set<brand_type> brand_prefers_adj =
{ SPWPN_VAMPIRISM, SPWPN_ANTIMAGIC, SPWPN_VORPAL, SPWPN_SPECTRAL };
/**
* What's the name of a type of weapon brand?
*
* @param brand The type of brand in question.
* @param bool Whether to use a terse or verbose name.
* @return The name of the given brand.
*/
const char* brand_type_name(brand_type brand, bool terse)
{
if (brand < 0 || brand >= NUM_SPECIAL_WEAPONS)
return terse ? "buggy" : "bugginess";
return (terse ? weapon_brands_terse : weapon_brands_verbose)[brand];
}
const char* brand_type_adj(brand_type brand)
{
if (brand < 0 || brand >= NUM_SPECIAL_WEAPONS)
return "buggy";
return weapon_brands_adj[brand];
}
/**
* What's the name of a given weapon's brand?
*
* @param item The weapon with the brand.
* @param bool Whether to use a terse or verbose name.
* @return The name of the given item's brand.
*/
const char* weapon_brand_name(const item_def& item, bool terse,
brand_type override_brand)
{
const brand_type brand = override_brand ? override_brand : get_weapon_brand(item);
return brand_type_name(brand, terse);
}
const char* armour_ego_name(const item_def& item, bool terse)
{
if (!terse)
{
switch (get_armour_ego_type(item))
{
case SPARM_NORMAL: return "";
#if TAG_MAJOR_VERSION == 34
case SPARM_RUNNING: return "running";
#endif
case SPARM_FIRE_RESISTANCE: return "fire resistance";
case SPARM_COLD_RESISTANCE: return "cold resistance";
case SPARM_POISON_RESISTANCE: return "poison resistance";
case SPARM_SEE_INVISIBLE: return "see invisible";
case SPARM_INVISIBILITY: return "invisibility";
case SPARM_STRENGTH: return "strength";
case SPARM_DEXTERITY: return "dexterity";
case SPARM_INTELLIGENCE: return "intelligence";
case SPARM_PONDEROUSNESS: return "ponderousness";
case SPARM_FLYING: return "flying";
case SPARM_WILLPOWER: return "willpower";
case SPARM_PROTECTION: return "protection";
case SPARM_STEALTH: return "stealth";
case SPARM_RESISTANCE: return "resistance";
case SPARM_POSITIVE_ENERGY: return "positive energy";
case SPARM_ARCHMAGI: return "the Archmagi";
#if TAG_MAJOR_VERSION == 34
case SPARM_JUMPING: return "jumping";
#endif
case SPARM_PRESERVATION: return "preservation";
case SPARM_REFLECTION: return "reflection";
case SPARM_SPIRIT_SHIELD: return "spirit shield";
case SPARM_HURLING: return "hurling";
case SPARM_REPULSION: return "repulsion";
#if TAG_MAJOR_VERSION == 34
case SPARM_CLOUD_IMMUNE: return "cloud immunity";
#endif
case SPARM_HARM: return "harm";
case SPARM_SHADOWS: return "shadows";
case SPARM_RAMPAGING: return "rampaging";
case SPARM_INFUSION: return "infusion";
case SPARM_LIGHT: return "light";
case SPARM_RAGE: return "wrath";
case SPARM_MAYHEM: return "mayhem";
case SPARM_GUILE: return "guile";
case SPARM_ENERGY: return "energy";
default: return "bugginess";
}
}
else
{
switch (get_armour_ego_type(item))
{
case SPARM_NORMAL: return "";
#if TAG_MAJOR_VERSION == 34
case SPARM_RUNNING: return "obsolete";
#endif
case SPARM_FIRE_RESISTANCE: return "rF+";
case SPARM_COLD_RESISTANCE: return "rC+";
case SPARM_POISON_RESISTANCE: return "rPois";
case SPARM_SEE_INVISIBLE: return "SInv";
case SPARM_INVISIBILITY: return "+Inv";
case SPARM_STRENGTH: return "Str+3";
case SPARM_DEXTERITY: return "Dex+3";
case SPARM_INTELLIGENCE: return "Int+3";
case SPARM_PONDEROUSNESS: return "ponderous";
case SPARM_FLYING: return "Fly";
case SPARM_WILLPOWER: return "Will+";
case SPARM_PROTECTION: return "AC+3";
case SPARM_STEALTH: return "Stlth+";
case SPARM_RESISTANCE: return "rC+ rF+";
case SPARM_POSITIVE_ENERGY: return "rN+";
case SPARM_ARCHMAGI: return "Archmagi";
#if TAG_MAJOR_VERSION == 34
case SPARM_JUMPING: return "obsolete";
#endif
case SPARM_PRESERVATION: return "rCorr";
case SPARM_REFLECTION: return "reflect";
case SPARM_SPIRIT_SHIELD: return "Spirit";
case SPARM_HURLING: return "hurl";
case SPARM_REPULSION: return "repulsion";
#if TAG_MAJOR_VERSION == 34
case SPARM_CLOUD_IMMUNE: return "obsolete";
#endif
case SPARM_HARM: return "harm";
case SPARM_SHADOWS: return "shadows";
case SPARM_RAMPAGING: return "rampage";
case SPARM_INFUSION: return "infuse";
case SPARM_LIGHT: return "light";
case SPARM_RAGE: return "*Rage";
case SPARM_MAYHEM: return "mayhem";
case SPARM_GUILE: return "guile";
case SPARM_ENERGY: return "*channel";
default: return "buggy";
}
}
}
static const char* _wand_type_name(int wandtype)
{
switch (wandtype)
{
case WAND_FLAME: return "flame";
case WAND_PARALYSIS: return "paralysis";
case WAND_DIGGING: return "digging";
case WAND_ICEBLAST: return "iceblast";
case WAND_POLYMORPH: return "polymorph";
case WAND_CHARMING: return "charming";
case WAND_ACID: return "acid";
case WAND_MINDBURST: return "mindburst";
default: return item_type_removed(OBJ_WANDS, wandtype)
? "removedness"
: "bugginess";
}
}
static const char* wand_secondary_string(uint32_t s)
{
static const char* const secondary_strings[] = {
"", "jewelled ", "curved ", "long ", "short ", "twisted ", "crooked ",
"forked ", "shiny ", "blackened ", "tapered ", "glowing ", "worn ",
"encrusted ", "runed ", "sharpened "
};
COMPILE_CHECK(ARRAYSZ(secondary_strings) == NDSC_WAND_SEC);
return secondary_strings[s % NDSC_WAND_SEC];
}
static const char* wand_primary_string(uint32_t p)
{
static const char* const primary_strings[] = {
"iron", "brass", "bone", "wooden", "copper", "gold", "silver",
"bronze", "ivory", "glass", "lead", "fluorescent"
};
COMPILE_CHECK(ARRAYSZ(primary_strings) == NDSC_WAND_PRI);
return primary_strings[p % NDSC_WAND_PRI];
}
const char* potion_type_name(int potiontype)
{
switch (static_cast<potion_type>(potiontype))
{
case POT_CURING: return "curing";
case POT_HEAL_WOUNDS: return "heal wounds";
case POT_HASTE: return "haste";
case POT_MIGHT: return "might";
case POT_ATTRACTION: return "attraction";
case POT_BRILLIANCE: return "brilliance";
case POT_FLIGHT: return "flight";
case POT_CANCELLATION: return "cancellation";
case POT_AMBROSIA: return "ambrosia";
case POT_INVISIBILITY: return "invisibility";
case POT_DEGENERATION: return "degeneration";
case POT_EXPERIENCE: return "experience";
case POT_MAGIC: return "magic";
case POT_BERSERK_RAGE: return "berserk rage";
case POT_MUTATION: return "mutation";
case POT_RESISTANCE: return "resistance";
case POT_LIGNIFY: return "lignification";
// FIXME: Remove this once known-items no longer uses this as a sentinel.
default:
return "bugginess";
CASE_REMOVED_POTIONS(potiontype); // TODO: this will crash, is that correct??
}
}
static const char* scroll_type_name(int scrolltype)
{
switch (static_cast<scroll_type>(scrolltype))
{
case SCR_IDENTIFY: return "identify";
case SCR_TELEPORTATION: return "teleportation";
case SCR_FEAR: return "fear";
case SCR_NOISE: return "noise";
case SCR_SUMMONING: return "summoning";
case SCR_ENCHANT_WEAPON: return "enchant weapon";
case SCR_ENCHANT_ARMOUR: return "enchant armour";
case SCR_TORMENT: return "torment";
case SCR_IMMOLATION: return "immolation";
case SCR_BLINKING: return "blinking";
case SCR_MAGIC_MAPPING: return "magic mapping";
case SCR_FOG: return "fog";
case SCR_ACQUIREMENT: return "acquirement";
case SCR_BRAND_WEAPON: return "brand weapon";
case SCR_HOLY_WORD: return "holy word";
case SCR_VULNERABILITY: return "vulnerability";
case SCR_SILENCE: return "silence";
case SCR_AMNESIA: return "amnesia";
#if TAG_MAJOR_VERSION == 34
case SCR_CURSE_WEAPON: return "curse weapon";
case SCR_CURSE_ARMOUR: return "curse armour";
case SCR_CURSE_JEWELLERY: return "curse jewellery";
#endif
default: return item_type_removed(OBJ_SCROLLS,
scrolltype)
? "removedness"
: "bugginess";
}
}
/**
* Get the name for the effect provided by a kind of jewellery.
*
* @param jeweltype The jewellery_type of the item in question.
* @return A string describing the effect of the given jewellery
* subtype.
*/
const char* jewellery_effect_name(int jeweltype, bool terse)
{
if (!terse)
{
switch (static_cast<jewellery_type>(jeweltype))
{
#if TAG_MAJOR_VERSION == 34
case RING_REGENERATION: return "obsoleteness";
case RING_ATTENTION: return "obsoleteness";
#endif
case RING_PROTECTION: return "protection";
case RING_PROTECTION_FROM_FIRE: return "protection from fire";
case RING_POISON_RESISTANCE: return "poison resistance";
case RING_PROTECTION_FROM_COLD: return "protection from cold";
case RING_STRENGTH: return "strength";
case RING_SLAYING: return "slaying";
case RING_SEE_INVISIBLE: return "see invisible";
case RING_RESIST_CORROSION: return "resist corrosion";
case RING_EVASION: return "evasion";
#if TAG_MAJOR_VERSION == 34
case RING_SUSTAIN_ATTRIBUTES: return "sustain attributes";
#endif
case RING_STEALTH: return "stealth";
case RING_DEXTERITY: return "dexterity";
case RING_INTELLIGENCE: return "intelligence";
case RING_WIZARDRY: return "wizardry";
case RING_MAGICAL_POWER: return "magical power";
case RING_FLIGHT: return "flight";
case RING_LIFE_PROTECTION: return "positive energy";
case RING_WILLPOWER: return "willpower";
case RING_FIRE: return "fire";
case RING_ICE: return "ice";
#if TAG_MAJOR_VERSION == 34
case RING_TELEPORTATION: return "teleportation";
case RING_TELEPORT_CONTROL: return "teleport control";
#endif
case AMU_MANA_REGENERATION: return "magic regeneration";
case AMU_ACROBAT: return "the acrobat";
#if TAG_MAJOR_VERSION == 34
case AMU_RAGE: return "rage";
case AMU_THE_GOURMAND: return "gourmand";
case AMU_HARM: return "harm";
case AMU_CONSERVATION: return "conservation";
case AMU_CONTROLLED_FLIGHT: return "controlled flight";
case AMU_INACCURACY: return "inaccuracy";
#endif
case AMU_NOTHING: return "nothing";
case AMU_GUARDIAN_SPIRIT: return "guardian spirit";
case AMU_FAITH: return "faith";
case AMU_REFLECTION: return "reflection";
case AMU_REGENERATION: return "regeneration";
default: return "buggy jewellery";
}
}
else
{
if (jewellery_base_ability_string(jeweltype)[0] != '\0')
return jewellery_base_ability_string(jeweltype);
switch (static_cast<jewellery_type>(jeweltype))
{
#if TAG_MAJOR_VERSION == 34
case RING_REGENERATION: return "obsoleteness";
case RING_ATTENTION: return "obsoleteness";
#endif
case RING_PROTECTION: return "AC";
case RING_PROTECTION_FROM_FIRE: return "rF+";
case RING_POISON_RESISTANCE: return "rPois";
case RING_PROTECTION_FROM_COLD: return "rC+";
case RING_STRENGTH: return "Str";
case RING_SLAYING: return "Slay";
case RING_SEE_INVISIBLE: return "sInv";
case RING_RESIST_CORROSION: return "rCorr";
case RING_EVASION: return "EV";
case RING_STEALTH: return "Stlth+";
case RING_DEXTERITY: return "Dex";
case RING_INTELLIGENCE: return "Int";
case RING_MAGICAL_POWER: return "MP+9";
case RING_FLIGHT: return "Fly";
case RING_LIFE_PROTECTION: return "rN+";
case RING_WILLPOWER: return "Will+";
case AMU_REGENERATION: return "Regen";
#if TAG_MAJOR_VERSION == 34
case AMU_RAGE: return "+Rage";
#endif
case AMU_ACROBAT: return "Acrobat";
case AMU_NOTHING: return "";
default: return "buggy";
}
}
}
/**
* Get the name for the category of a type of jewellery.
*
* @param jeweltype The jewellery_type of the item in question.
* @return A string describing the kind of jewellery it is.
*/
static const char* _jewellery_class_name(int jeweltype)
{
#if TAG_MAJOR_VERSION == 34
if (jeweltype == RING_REGENERATION)
return "ring of";
#endif
if (jeweltype < RING_FIRST_RING || jeweltype >= NUM_JEWELLERY
|| jeweltype >= NUM_RINGS && jeweltype < AMU_FIRST_AMULET)
{
return "buggy"; // "buggy buggy jewellery"
}
if (jeweltype < NUM_RINGS)
return "ring of";
return "amulet of";
}
/**
* Get the name for a type of jewellery.
*
* @param jeweltype The jewellery_type of the item in question.
* @return The full name of the jewellery type in question.
*/
static string jewellery_type_name(int jeweltype)
{
return make_stringf("%s %s", _jewellery_class_name(jeweltype),
jewellery_effect_name(jeweltype));
}
static const char* ring_secondary_string(uint32_t s)
{
static const char* const secondary_strings[] = {
"", "encrusted ", "glowing ", "tubular ", "runed ", "blackened ",
"scratched ", "small ", "large ", "twisted ", "shiny ", "notched ",
"knobbly "
};
COMPILE_CHECK(ARRAYSZ(secondary_strings) == NDSC_JEWEL_SEC);
return secondary_strings[s % NDSC_JEWEL_SEC];
}
static const char* ring_primary_string(uint32_t p)
{
static const char* const primary_strings[] = {
"wooden", "silver", "golden", "iron", "steel", "tourmaline", "brass",
"copper", "granite", "ivory", "ruby", "marble", "jade", "glass",
"agate", "bone", "diamond", "emerald", "peridot", "garnet", "opal",
"pearl", "coral", "sapphire", "cabochon", "gilded", "onyx", "bronze",
"moonstone"
};
COMPILE_CHECK(ARRAYSZ(primary_strings) == NDSC_JEWEL_PRI);
return primary_strings[p % NDSC_JEWEL_PRI];
}
static const char* amulet_secondary_string(uint32_t s)
{
static const char* const secondary_strings[] = {
"dented ", "square ", "thick ", "thin ", "runed ", "blackened ",
"glowing ", "small ", "large ", "twisted ", "tiny ", "triangular ",
"lumpy "
};
COMPILE_CHECK(ARRAYSZ(secondary_strings) == NDSC_JEWEL_SEC);
return secondary_strings[s % NDSC_JEWEL_SEC];
}
static const char* amulet_primary_string(uint32_t p)
{
static const char* const primary_strings[] = {
"sapphire", "zirconium", "golden", "emerald", "garnet", "bronze",
"brass", "copper", "ruby", "citrine", "bone", "platinum", "jade",
"fluorescent", "amethyst", "cameo", "pearl", "blue", "peridot",
"jasper", "diamond", "malachite", "steel", "cabochon", "silver",
"soapstone", "lapis lazuli", "filigree", "beryl"
};
COMPILE_CHECK(ARRAYSZ(primary_strings) == NDSC_JEWEL_PRI);
return primary_strings[p % NDSC_JEWEL_PRI];
}
const char* rune_type_name(short p)
{
switch (static_cast<rune_type>(p))
{
case RUNE_DIS: return "iron";
case RUNE_GEHENNA: return "obsidian";
case RUNE_COCYTUS: return "icy";
case RUNE_TARTARUS: return "bone";
case RUNE_SLIME: return "slimy";
case RUNE_VAULTS: return "silver";
case RUNE_SNAKE: return "serpentine";
case RUNE_ELF: return "elven";
case RUNE_TOMB: return "golden";
case RUNE_SWAMP: return "decaying";
case RUNE_SHOALS: return "barnacled";
case RUNE_SPIDER: return "gossamer";
case RUNE_FOREST: return "mossy";
// pandemonium and abyss runes:
case RUNE_DEMONIC: return "demonic";
case RUNE_ABYSSAL: return "abyssal";
// special pandemonium runes:
case RUNE_MNOLEG: return "glowing";
case RUNE_LOM_LOBON: return "magical";
case RUNE_CEREBOV: return "fiery";
case RUNE_GLOORX_VLOQ: return "dark";
default: return "buggy";
}
}
static string misc_type_name(int type)
{
#if TAG_MAJOR_VERSION == 34
if (is_deck_type(type))
return "removed deck";
#endif
switch (static_cast<misc_item_type>(type))
{
#if TAG_MAJOR_VERSION == 34
case MISC_CRYSTAL_BALL_OF_ENERGY: return "removed crystal ball";
#endif
case MISC_BOX_OF_BEASTS: return "box of beasts";
#if TAG_MAJOR_VERSION == 34
case MISC_BUGGY_EBONY_CASKET: return "removed ebony casket";
case MISC_FAN_OF_GALES: return "removed fan of gales";
case MISC_LAMP_OF_FIRE: return "removed lamp of fire";
case MISC_BUGGY_LANTERN_OF_SHADOWS: return "removed lantern of shadows";
#endif
case MISC_HORN_OF_GERYON: return "horn of Geryon";
case MISC_LIGHTNING_ROD: return "lightning rod";
#if TAG_MAJOR_VERSION == 34
case MISC_BOTTLED_EFREET: return "empty flask";
case MISC_RUNE_OF_ZOT: return "obsolete rune of zot";
case MISC_STONE_OF_TREMORS: return "removed stone of tremors";
#endif
case MISC_QUAD_DAMAGE: return "quad damage";
case MISC_PHIAL_OF_FLOODS: return "phial of floods";
#if TAG_MAJOR_VERSION == 34
case MISC_SACK_OF_SPIDERS: return "removed sack of spiders";
#endif
case MISC_PHANTOM_MIRROR: return "phantom mirror";
case MISC_ZIGGURAT: return "figurine of a ziggurat";
case MISC_XOMS_CHESSBOARD: return "piece from Xom's chessboard";
case MISC_TIN_OF_TREMORSTONES: return "tin of tremorstones";
case MISC_CONDENSER_VANE: return "condenser vane";
default:
return "buggy miscellaneous item";
}
}
static const char* _book_type_name(int booktype)
{
switch (static_cast<book_type>(booktype))
{
case BOOK_MINOR_MAGIC: return "Minor Magic";
case BOOK_CONJURATIONS: return "Conjurations";
case BOOK_FLAMES: return "Flames";
case BOOK_FROST: return "Frost";
case BOOK_WILDERNESS: return "the Wilderness";
case BOOK_FIRE: return "Fire";
case BOOK_ICE: return "Ice";
case BOOK_SPATIAL_TRANSLOCATIONS: return "Spatial Translocations";
case BOOK_HEXES: return "Hexes";
case BOOK_LIGHTNING: return "Lightning";
case BOOK_DEATH: return "Death";
case BOOK_MISFORTUNE: return "Misfortune";