blib/lib/Lingua/Alphabet/Phonetic/NetHack.pm

filter: Statementstmt 95.8% 23 / 24 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 93.3% 28 / 30 CC 2 SCAR 3.5
CC
2
Cov
92%
_name_of_letter
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
↑ Summary
1  
2 package Lingua::Alphabet::Phonetic::NetHack;
3  
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 Lingua::Alphabet::Phonetic::NetHack - map ASCII characters to names of NetHack items
10  
11 =head1 SYNOPSIS
12  
13 This is a specialization of L<Lingua::Alphabet::Phonetic>.
14 You should not use this module directly;
15 all interaction should be done with an object of type Lingua::Alphabet::Phonetic.
16  
17 my $oSpeaker = new Lingua::Alphabet::Phonetic('NetHack');
18  
19 =head1 NOTES
20  
21 The only ASCII characters which do not have NetHack names are comma and digits 1 through 9!
22  
23 =head1 SEE ALSO
24  
25 http://www.nethack.org
26  
27 =head1 BUGS
28  
29 Please tell the author if you find any!
30  
31 =head1 AUTHOR
32  
33 Martin Thurn (mthurn@cpan.org).
34  
35 =head1 LICENSE
36  
37 This software is released under the same license as Perl itself.
38  
39 =cut
40  
41 #####################################################################
42  
43 2 ▶use base 'Lingua::Alphabet::Phonetic';
Subroutine BEGIN: called CC=1 SCAR=0.0
44 our
45 2 $VERSION = 1.801;
46  
47 # First, the punctuation:
48 2 my %hash = (
49 ' ' => 'ghost',
50 '!' => 'potion',
51 '"' => 'amulet',
52 '#' => 'corridor',
53 '$' => 'gold',
54 '%' => 'food',
55 '&' => 'demon',
56 "'" => 'golem',
57 '(' => 'tool',
58 ')' => 'weapon',
59 '*' => 'gem',
60 '+' => 'door',
61 # ',' => 'unused',
62 '-' => 'wall',
63 '.' => 'floor',
64 '/' => 'wand',
65 '0' => 'iron ball',
66 # 1-9 here
67 ':' => 'lizard',
68 ';' => 'eel',
69 '<' => 'staircase up',
70 '=' => 'ring',
71 '>' => 'staircase down',
72 '?' => 'scroll',
73 '@' => 'human',
74 # A-Z here
75 '[' => 'armor',
76 '\\' => 'throne',
77 ']' => 'mimic',
78 '^' => 'trap',
79 '_' => 'altar',
80 '`' => 'boulder',
81 # a-z here
82 '{' => 'fountain',
83 '|' => 'grave',
84 '}' => 'pool',
85 '~' => 'tail',
86 );
87  
88 2 my @asLowercase = (
89 "ant",
90 "blob",
91 "cockatrice",
92 "dog",
93 "eye",
94 "cat",
95 "gremlin",
96 "humanoid",
97 "imp",
98 "jelly",
99 "kobold",
100 "leprechaun",
101 "mimic",
102 "nymph",
103 "orc",
104 "piercer",
105 "quadruped",
106 "rodent",
107 "spider",
108 "trapper",
109 "unicorn",
110 "vortex",
111 "worm",
112 "xan",
113 "light",
114 "zruty",
115 );
116 2 my @asUppercase = (
117 "angel",
118 "bat",
119 "centaur",
120 "dragon",
121 "elemental",
122 "fungus",
123 "gnome",
124 "giant",
125 "invisible monster",
126 "jabberwock",
127 "Kop",
128 "lich",
129 "mummy",
130 "naga",
131 "ogre",
132 "pudding",
133 "quantum mechanic",
134 "rust monster",
135 "snake",
136 "troll",
137 "umber hulk",
138 "vampire",
139 "wraith",
140 "xorn",
141 "ape",
142 "zombie",
143 );
144 2 map { $hash{$_} = shift @asLowercase } ('a'..'z');
145 2 map { $hash{$_} = shift @asUppercase } ('A'..'Z');
146 # Special cases / recover lost entries:
147  
148 sub _name_of_letter
149 26 ▶ {
Subroutine _name_of_letter: called CC=2 SCAR=7.2
150 26 my $self = shift;
151 26 my $s = shift;
152 # print STDERR " + L::A::P::NetHack::_name_of_letter($s)\n";
153 # If we get more than one character, ignore the rest:
154 26 my $c = substr($s, 0, 1);
155 26 ▶ if (exists($hash{$c}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hash{$c}) 26 0 26
156 {
157 26 return $hash{$c};
158 } # if
159 0 return $self->SUPER::_name_of_letter($s);
160 } # _name_of_letter
161  
162 2 1;
163  
164 __END__
↑ Summary