| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package NetHack::Engravings; |
|
2
|
|
|
|
|
|
|
BEGIN { |
|
3
|
2
|
|
|
2
|
|
62913
|
$NetHack::Engravings::AUTHORITY = 'cpan:DOY'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
{ |
|
6
|
|
|
|
|
|
|
$NetHack::Engravings::VERSION = '0.02'; |
|
7
|
|
|
|
|
|
|
} |
|
8
|
2
|
|
|
2
|
|
22
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
73
|
|
|
9
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
91
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: functions related to NetHack engravings |
|
11
|
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
12
|
use Exporter 'import'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1998
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = ('is_degradation', 'is_maybe_preengraved'); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my %rubouts = ( |
|
17
|
|
|
|
|
|
|
'0' => ['(', 'C'], |
|
18
|
|
|
|
|
|
|
'1' => ['|'], |
|
19
|
|
|
|
|
|
|
'6' => ['c', 'o'], |
|
20
|
|
|
|
|
|
|
'7' => ['/'], |
|
21
|
|
|
|
|
|
|
'8' => ['3', 'c', 'o'], |
|
22
|
|
|
|
|
|
|
':' => ['.'], |
|
23
|
|
|
|
|
|
|
';' => [','], |
|
24
|
|
|
|
|
|
|
'A' => ['^'], |
|
25
|
|
|
|
|
|
|
'B' => ['-', 'F', 'P', '[', 'b', '|'], |
|
26
|
|
|
|
|
|
|
'b' => ['|'], |
|
27
|
|
|
|
|
|
|
'C' => ['('], |
|
28
|
|
|
|
|
|
|
'D' => [')', '[', '|'], |
|
29
|
|
|
|
|
|
|
'd' => ['c', '|'], |
|
30
|
|
|
|
|
|
|
'E' => ['-', 'F', 'L', '[', '_', '|'], |
|
31
|
|
|
|
|
|
|
'e' => ['c'], |
|
32
|
|
|
|
|
|
|
'F' => ['-', '|'], |
|
33
|
|
|
|
|
|
|
'G' => ['(', 'C'], |
|
34
|
|
|
|
|
|
|
'g' => ['c'], |
|
35
|
|
|
|
|
|
|
'H' => ['-', '|'], |
|
36
|
|
|
|
|
|
|
'h' => ['n', 'r'], |
|
37
|
|
|
|
|
|
|
'I' => ['|'], |
|
38
|
|
|
|
|
|
|
'j' => ['i'], |
|
39
|
|
|
|
|
|
|
'K' => ['<', '|'], |
|
40
|
|
|
|
|
|
|
'k' => ['|'], |
|
41
|
|
|
|
|
|
|
'L' => ['_', '|'], |
|
42
|
|
|
|
|
|
|
'l' => ['|'], |
|
43
|
|
|
|
|
|
|
'M' => ['|'], |
|
44
|
|
|
|
|
|
|
'm' => ['n', 'r'], |
|
45
|
|
|
|
|
|
|
'N' => ['\\', '|'], |
|
46
|
|
|
|
|
|
|
'n' => ['r'], |
|
47
|
|
|
|
|
|
|
'O' => ['(', 'C'], |
|
48
|
|
|
|
|
|
|
'o' => ['c'], |
|
49
|
|
|
|
|
|
|
'P' => ['-', 'F', '|'], |
|
50
|
|
|
|
|
|
|
'Q' => ['(', 'C'], |
|
51
|
|
|
|
|
|
|
'q' => ['c'], |
|
52
|
|
|
|
|
|
|
'R' => ['-', 'F', 'P', '|'], |
|
53
|
|
|
|
|
|
|
'T' => ['|'], |
|
54
|
|
|
|
|
|
|
'U' => ['J'], |
|
55
|
|
|
|
|
|
|
'V' => ['/', '\\'], |
|
56
|
|
|
|
|
|
|
'W' => ['/', 'V', '\\'], |
|
57
|
|
|
|
|
|
|
'w' => ['v'], |
|
58
|
|
|
|
|
|
|
'y' => ['v'], |
|
59
|
|
|
|
|
|
|
'Z' => ['/'], |
|
60
|
|
|
|
|
|
|
); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub is_degradation { |
|
64
|
9181
|
|
|
9181
|
1
|
1548041
|
my ($orig, $cur) = @_; |
|
65
|
|
|
|
|
|
|
|
|
66
|
9181
|
|
|
|
|
153895
|
my @orig = split '', $orig; |
|
67
|
9181
|
|
|
|
|
141505
|
my @cur = split '', $cur; |
|
68
|
|
|
|
|
|
|
|
|
69
|
9181
|
|
|
|
|
35876
|
C: for my $c (@cur) { |
|
70
|
89458
|
|
|
|
|
183763
|
while (@orig) { |
|
71
|
456789
|
|
|
|
|
683176
|
my $o = shift @orig; |
|
72
|
|
|
|
|
|
|
|
|
73
|
456789
|
100
|
|
|
|
913414
|
next C if $o eq $c; |
|
74
|
|
|
|
|
|
|
|
|
75
|
409079
|
100
|
|
|
|
684880
|
if ($o eq ' ') { |
|
76
|
79301
|
50
|
|
|
|
235523
|
next C if $c eq ' '; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
else { |
|
79
|
329778
|
100
|
|
|
|
333248
|
next C if grep { $_ eq $c } @{ $rubouts{$o} || [] }, '?', ' '; |
|
|
866538
|
100
|
|
|
|
2228253
|
|
|
|
329778
|
|
|
|
|
1164781
|
|
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# we ran out of characters in the original engraving |
|
84
|
7619
|
50
|
|
|
|
59443
|
return 0 if !@orig; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
1562
|
|
|
|
|
20407
|
return 1; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my @preengravings = grep { length && !/^#/ } ; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub is_maybe_preengraved { |
|
94
|
8
|
|
|
8
|
1
|
28
|
my ($engraving) = @_; |
|
95
|
|
|
|
|
|
|
|
|
96
|
8
|
|
|
|
|
49
|
return !!grep { is_degradation($_, $engraving) } @preengravings; |
|
|
6208
|
|
|
|
|
13347
|
|
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=pod |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 NAME |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
NetHack::Engravings - functions related to NetHack engravings |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 VERSION |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
version 0.02 |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
use NetHack::Engravings 'is_degradation'; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
is_degradation('Elbereth', 'F| ???'); # true |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This module implements some useful functions related to various aspects of |
|
121
|
|
|
|
|
|
|
engravings in NetHack. Currently, it only includes a predicate for checking |
|
122
|
|
|
|
|
|
|
whether an engraving can be worn away into another engraving, but more |
|
123
|
|
|
|
|
|
|
suggestions are welcome. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 is_degradation($orig, $cur) |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Returns true if C<$orig> could possibly degrade to C<$cur>. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 is_maybe_preengraved($engraving) |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Returns true if an engraving may have been created during level generation. |
|
134
|
|
|
|
|
|
|
This can be used to detect bones levels by finding engravings left by the |
|
135
|
|
|
|
|
|
|
previous player (which will likely make this function return false). |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 BUGS |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
No known bugs. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Please report any bugs through RT: email |
|
142
|
|
|
|
|
|
|
C, or browse to |
|
143
|
|
|
|
|
|
|
L. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 SUPPORT |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
You can find this documentation for this module with the perldoc command. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
perldoc NetHack::Engravings |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
You can also look for information at: |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=over 4 |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * MetaCPAN |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
L |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
L |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item * Github |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
L |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=back |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 AUTHORS |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over 4 |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Jesse Luehrs |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Shawn M Moore |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=back |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Jesse Luehrs. |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
This is free software, licensed under: |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
The NetHack General Public License |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
__DATA__ |