| 1 |
#!/usr/bin/env perl |
| 2 |
|
| 3 |
use warnings; |
| 4 |
|
| 5 |
my $db = grep /^-d$/, @ARGV; |
| 6 |
my %jewellery_prefixes; |
| 7 |
|
| 8 |
sub jewellery_name($$) |
| 9 |
{ |
| 10 |
my ($enum, $name) = @_; |
| 11 |
my $prefix = $jewellery_prefixes{$enum} || ""; |
| 12 |
my $type = $enum =~ /^AMU_/ ? "amulet" : "ring"; |
| 13 |
return "$type of $prefix$name"; |
| 14 |
} |
| 15 |
|
| 16 |
open IN, "util/cpp_version item-name.cc|" or die "Can't read item-name.cc\n"; |
| 17 |
{ undef local $/; $_ = <IN>; } |
| 18 |
close IN; |
| 19 |
|
| 20 |
# Remove this from the input so the main jewellery pattern doesn't match. |
| 21 |
s/^static [^\n]*_jewellery_effect_prefix\([^\n]*\).(.*?)^}//ms; |
| 22 |
my $prefixes = $1; |
| 23 |
$jewellery_prefixes{$1} = $2 |
| 24 |
while $prefixes =~ /((?:RING|AMU)_[A-Z_]+): *return "([^"]+)";/g; |
| 25 |
|
| 26 |
$items{"wand of $_"} = 1 for /WAND_[A-Z_]+: *return "([^"]+)";/g; |
| 27 |
$items{"potion of $_"} = 1 for /POT_[A-Z_]+: *return "([^"]+)";/g; |
| 28 |
$items{"scroll of $_"} = 1 for /SCR_[A-Z_]+: *return "([^"]+)";/g; |
| 29 |
my %seen_enums; |
| 30 |
while (/((?:RING|AMU)_[A-Z_]+): *return "([^"]+)";/g) |
| 31 |
{ |
| 32 |
next if $seen_enums{$1}++; |
| 33 |
$items{jewellery_name($1, $2)} = 1 |
| 34 |
} |
| 35 |
|
| 36 |
unless ($db) |
| 37 |
{ |
| 38 |
$items{"$_ rune of Zot"} = 1 for /RUNE_[A-Z_]+: *return "([^"]+)";/g; |
| 39 |
$items{"$_ deck of cards"} = 1 for /DECK_RARITY_[A-Z_]+: *return "([^"]+)";/g; |
| 40 |
} |
| 41 |
$items{$_} = 1 for /MISC_[A-Z_]+: *return "([^"]+)";/g; |
| 42 |
$items{"book of $_"} = 1 for /BOOK_[A-Z_]+: *return "([^"]+)";/g; |
| 43 |
$items{"staff of $_"} = 1 for /STAFF_[A-Z_]+: *return "([^"]+)";/g; |
| 44 |
|
| 45 |
open IN, "util/cpp_version item-prop.cc|" or die "Can't read item-prop.cc\n"; |
| 46 |
{ undef local $/; $_ = <IN>; } |
| 47 |
close IN; |
| 48 |
|
| 49 |
s/" "//g; |
| 50 |
$items{$_} = 1 for /\{ *ARM_[A-Z_]+, *"([^"]+)"/mg; |
| 51 |
$items{"$_ dragon scales"} = 1 for /^ *DRAGON_ARMOUR\([A-Z_]+, *"([^"]+)"/mg; |
| 52 |
$items{$_} = 1 for /^ *\{ *WPN_[A-Z_]+, *"([^"]+)"/mg; |
| 53 |
$items{$_} = 1 for /^ *\{ *MI_[A-Z_]+, *"([^"]+)"/mg; |
| 54 |
|
| 55 |
open IN, "util/cpp_version decks.cc|" or die "Can't read decks.cc\n"; |
| 56 |
{ undef local $/; $_ = <IN>; } |
| 57 |
close IN; |
| 58 |
my $data = $_; |
| 59 |
$data =~ s/.*all_decks =(.*?)};.*/$1/s or die "can't find all_decks\n"; |
| 60 |
$items{"deck of $_"} = 1 for $data =~ /^\s+"([^"]+)"/mg; |
| 61 |
|
| 62 |
$items{$_} = 1 for (split /\n/, <<END); |
| 63 |
corpse |
| 64 |
eggplant |
| 65 |
gold piece |
| 66 |
manual |
| 67 |
orb of Zot |
| 68 |
pair of boots |
| 69 |
pair of gloves |
| 70 |
rune of Zot |
| 71 |
Young Poisoner's Handbook |
| 72 |
Grand Grimoire |
| 73 |
Necronomicon |
| 74 |
Fen Folio |
| 75 |
Everburning Encyclopedia |
| 76 |
There-And-Back Book |
| 77 |
Great Wizards, Vol. II |
| 78 |
Great Wizards, Vol. VII |
| 79 |
Trismegistus Codex |
| 80 |
the Unrestrained Analects |
| 81 |
END |
| 82 |
|
| 83 |
$items{"decaying skeleton"} = 1 if $db; |
| 84 |
|
| 85 |
delete $items{$_} for (split /\n/, <<END); |
| 86 |
boots |
| 87 |
gloves |
| 88 |
END |
| 89 |
|
| 90 |
for (sort keys %items) |
| 91 |
{ |
| 92 |
next if /bugginess/i; |
| 93 |
# yay consistency, all other descs use proper capitalization |
| 94 |
tr/A-Z/a-z/ if $db && !/Geryon/; |
| 95 |
print "$_\n"; |
| 96 |
} |