blib/lib/Games/Axmud/Obj/Phrasebook.pm untested

filter: Statementstmt 0.0% 0 / 48 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 11 totaltotal 0.0% 0 / 88 CC 2 SCAR 9.3
CC
2
Cov
0%
new
6.0
name
2.0
targetName
2.0
CRAP 2.5
1 # Copyright (C) 2011-2024 A S Lewis
2 #
3 # This program is free software: you can redistribute it and/or modify it under the terms of the GNU
4 # General Public License as published by the Free Software Foundation, either version 3 of the
5 # License, or (at your option) any later version.
6 #
7 # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 # General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License along with this program. If not,
12 # see <http://www.gnu.org/licenses/>.
13 #
14 #
15 # Games::Axmud::Obj::Phrasebook
16 # Stores a basic list of words for converting parts of a dictionary object (Games::Axmud::Obj::Dict)
17 # into another language
18  
19 { package Games::Axmud::Obj::Phrasebook;
20  
21 use strict;
22 use warnings;
23 # use diagnostics;
24  
25 use Glib qw(TRUE FALSE);
26  
27 our @ISA = qw(Games::Axmud);
28  
29 ##################
30 # Constructors
31  
32 sub new {
33  
34 # Called by GA::Client->loadPhraseBooks
35 # Creates a new instance of the phrasebook object
36 #
37 # Expected arguments
38 # $name - Language name, rendered in lower-case English (e.g. 'francais')
39 # $targetName - Language name, rendered in the target language and capitalised
40 #
41 # Return values
42 # 'undef' on improper arguments
43 # Blessed reference to the newly-created object on success
44  
45 my ($class, $name, $targetName, $check) = @_;
46  
47 # Check for improper arguments
48 if (! defined $class || ! defined $name || ! defined $targetName || defined $check) {
49  
50 return $axmud::CLIENT->writeImproper($class . '->new', @_);
51 }
52  
53 # Setup
54 my $self = {
55 _objName => $name,
56 _objClass => $class,
57 _parentFile => undef, # No parent file object
58 _parentWorld => undef,
59 _privFlag => TRUE, # All IVs are private
60  
61 # IVs
62 # ---
63  
64 # Language name, rendered in lower-case English (e.g. 'french')
65 name => $name,
66 # Language name, rendered in the target language and capitalised
67 targetName => $targetName,
68 # Noun position for this language:
69 # 'noun_adj' - typical order is noun-adjective (e.g. French)
70 # 'adj_noun' - typical order is adjective-noun (e.g. English)
71 nounPosn => 'adj_noun',
72  
73 # List of primary directions, in a standard order. If directions are not known, retain
74 # the English words
75 primaryDirList => [
76 'north',
77 'northnortheast',
78 'northeast',
79 'eastnortheast',
80 'east',
81 'eastsoutheast',
82 'southeast',
83 'southsoutheast',
84 'south',
85 'southsouthwest',
86 'southwest',
87 'westsouthwest',
88 'west',
89 'westnorthwest',
90 'northwest',
91 'northnorthwest',
92 'up',
93 'down',
94 ],
95 # List of abbreviated primary directions, in a standard order. If directions are not
96 # known, retain the English words
97 primaryAbbrevDirList => [
98 'n',
99 'nne',
100 'ne',
101 'ene',
102 'e',
103 'ese',
104 'se',
105 'sse',
106 's',
107 'ssw',
108 'sw',
109 'wsw',
110 'w',
111 'wnw',
112 'nw',
113 'nnw',
114 'u',
115 'd',
116 ],
117 # List of definite articles (can be an empty list)
118 definiteList => [
119 'the',
120 ],
121 # List of indefinite articles (can be an empty list)
122 indefiniteList => [
123 'a',
124 'an',
125 ],
126 # List of 'and' words (can be an empty list)
127 andList => [
128 'and',
129 'also',
130 ],
131 # List of 'or' words (can be an empty list)
132 orList => [
133 'or',
134 ],
135 # Basic list of number words, from 1-10
136 numberList => [
137 'one',
138 'two',
139 'three',
140 'four',
141 'five',
142 'six',
143 'seven',
144 'eight',
145 'nine',
146 'ten',
147 ],
148 };
149  
150 # Bless the object into existence
151 bless $self, $class;
152 return $self;
153 }
154  
155 ##################
156 # Methods
157  
158 ##################
159 # Accessors - set
160  
161 ##################
162 # Accessors - get
163  
164 sub name
165 { $_[0]->{name} }
166 sub targetName
167 { $_[0]->{targetName} }
168 sub nounPosn
169 { $_[0]->{nounPosn} }
170  
171 sub primaryDirList
172 { my $self = shift; return @{$self->{primaryDirList}}; }
173 sub primaryAbbrevDirList
174 { my $self = shift; return @{$self->{primaryAbbrevDirList}}; }
175 sub definiteList
176 { my $self = shift; return @{$self->{definiteList}}; }
177 sub indefiniteList
178 { my $self = shift; return @{$self->{indefiniteList}}; }
179 sub andList
180 { my $self = shift; return @{$self->{andList}}; }
181 sub orList
182 { my $self = shift; return @{$self->{orList}}; }
183 sub numberList
184 { my $self = shift; return @{$self->{numberList}}; }
185 }
186  
187 # Package must return a true value
188 1