File Coverage

blib/lib/Lingua/Alphabet/Phonetic/NetHack.pm
Criterion Covered Total %
statement 14 15 93.3
branch 1 2 50.0
condition n/a
subroutine 4 4 100.0
pod n/a
total 19 21 90.4


line stmt bran cond sub pod time code
1              
2             package Lingua::Alphabet::Phonetic::NetHack;
3              
4 2     2   26593 use strict;
  2         4  
  2         51  
5 2     2   9 use warnings;
  2         6  
  2         55  
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.
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     2   8 use base 'Lingua::Alphabet::Phonetic';
  2         12  
  2         762  
44             our
45             $VERSION = 1.801;
46              
47             # First, the punctuation:
48             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             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             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             map { $hash{$_} = shift @asLowercase } ('a'..'z');
145             map { $hash{$_} = shift @asUppercase } ('A'..'Z');
146             # Special cases / recover lost entries:
147              
148             sub _name_of_letter
149             {
150 26     26   2342 my $self = shift;
151 26         43 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         41 my $c = substr($s, 0, 1);
155 26 50       63 if (exists($hash{$c}))
156             {
157 26         70 return $hash{$c};
158             } # if
159 0           return $self->SUPER::_name_of_letter($s);
160             } # _name_of_letter
161              
162             1;
163              
164             __END__