summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/util/gather_items
blob: 6d4cb70671e7f14559e6c8d7be2b579edae14227 (plain) (blame)
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
#!/usr/bin/perl -w

my $db = grep /^-d$/, @ARGV;
my %jewellery_prefixes;

sub jewellery_name($$)
{
    my ($enum, $name) = @_;
    my $prefix = $jewellery_prefixes{$enum} || "";
    my $type = $enum =~ /^AMU_/ ? "amulet" : "ring";
    return "$type of $prefix$name";
}

open IN, "util/cpp_version itemname.cc|" or die "Can't read itemname.cc\n";
{ undef local $/; $_ = <IN>; }
close IN;

# Remove this from the input so the main jewellery pattern doesn't match.
s/^static [^\n]*_jewellery_effect_prefix\([^\n]*\)\n(.*?)^}//ms;
my $prefixes = $1;
$jewellery_prefixes{$1} = $2
    while $prefixes =~ /((?:RING|AMU)_[A-Z_]+): *return "([^"]+)";/g;

$items{"wand of $_"} = 1 for /WAND_[A-Z_]+: *return "([^"]+)";/g;
$items{"potion of $_"} = 1 for /POT_[A-Z_]+: *return "([^"]+)";/g;
$items{"scroll of $_"} = 1 for /SCR_[A-Z_]+: *return "([^"]+)";/g;
$items{jewellery_name($1, $2)} = 1
    while /((?:RING|AMU)_[A-Z_]+): *return "([^"]+)";/g;

unless ($db)
{
    $items{"$_ rune of Zot"} = 1 for /RUNE_[A-Z_]+: *return "([^"]+)";/g;
    $items{"$_ deck of cards"} = 1 for /DECK_RARITY_[A-Z_]+: *return "([^"]+)";/g;
}
$items{$_} = 1 for /MISC_[A-Z_]+: *return "([^"]+)";/g;
$items{"book of $_"} = 1 for /BOOK_[A-Z_]+: *return "([^"]+)";/g;
$items{"staff of $_"} = 1 for /STAFF_[A-Z_]+: *return "([^"]+)";/g;
$items{"rod of $_"} = 1 for /ROD_[A-Z_]+: *return "([^"]+)";/g;
$items{$_} = 1 for /FOOD_[A-Z_]+: buff << "([^"]+)";/g;

open IN, "util/cpp_version itemprop.cc|" or die "Can't read itemprop.cc\n";
{ undef local $/; $_ = <IN>; }
close IN;

$items{$_} = 1 for /^ *\{ *ARM_[A-Z_]+, *"([^"]+)"/mg;
$items{$_} = 1 for /^ *\{ *WPN_[A-Z_]+, *"([^"]+)"/mg;
$items{$_} = 1 for /^ *\{ *MI_[A-Z_]+, *"([^"]+)"/mg;
#"
# food is redundant -- fixme!

$items{$_} = 1 for (split /\n/, <<END);
chunk of flesh
corpse
eggplant
gold piece
Grand Grimoire
lightning rod
manual
Necronomicon
orb of Zot
pair of boots
pair of gloves
rod of destruction
rune of Zot
tome of Destruction
Young Poisoner's Handbook
END

$items{"decaying skeleton"} = 1 if $db;

delete $items{$_} for (split /\n/, <<END);
boots
gloves
rod of lightning
END

for (sort keys %items)
{
    next if /bugginess/i;
    # yay consistency, all other descs use proper capitalization
    tr/A-Z/a-z/ if $db && !/Geryon/;
    print "$_\n";
}