| 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::Component | ||
| 16 | # Handles room statement components | ||
| 17 | |||
| 18 | { package Games::Axmud::Obj::Component; | ||
| 19 | |||
| 20 | use strict; | ||
| 21 | use warnings; | ||
| 22 | # use diagnostics; | ||
| 23 | |||
| 24 | use Glib qw(TRUE FALSE); | ||
| 25 | |||
| 26 | our @ISA = qw(Games::Axmud); | ||
| 27 | |||
| 28 | ################## | ||
| 29 | # Constructors | ||
| 30 | |||
| 31 | sub new { | ||
| 32 | |||
| 33 | # Prepare a new instance of the room statement component object | ||
| 34 | # | ||
| 35 | # Expected arguments | ||
| 36 | # $session - The parent GA::Session (not stored as an IV) | ||
| 37 | # $worldObj - The world profile object to which this component belongs | ||
| 38 | # $name - Unique name for this component (can match the component type) (max | ||
| 39 | # 16 chars) | ||
| 40 | # $type - One of 'verb_title', 'verb_descrip', 'verb_exit', 'verb_content', | ||
| 41 | # 'verb_special', 'brief_title', 'brief_exit', 'brief_title_exit', | ||
| 42 | # 'brief_exit_title', 'brief_content', 'room_cmd', 'mudlib_path', | ||
| 43 | # 'weather', 'ignore_line', 'custom' | ||
| 44 | # | ||
| 45 | # Optional arguments | ||
| 46 | # $tempFlag - If set to TRUE, this is a temporary component created for use with an | ||
| 47 | # 'edit' window; $name is not checked for validity. Otherwise set to FALSE | ||
| 48 | # (or 'undef') | ||
| 49 | # | ||
| 50 | # Return values | ||
| 51 | # 'undef' on improper arguments, or if $name or $type are invalid | ||
| 52 | # Blessed reference to the newly-created object on success | ||
| 53 | |||
| 54 | my ($class, $session, $worldObj, $name, $type, $tempFlag, $check) = @_; | ||
| 55 | |||
| 56 | # Local variables | ||
| 57 | my $matchFlag; | ||
| 58 | |||
| 59 | # Check for improper arguments | ||
| 60 | if ( | ||
| 61 | ! defined $class || ! defined $session || ! defined $worldObj || ! defined $name | ||
| 62 | || ! defined $type || defined $check | ||
| 63 | ) { | ||
| 64 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 65 | } | ||
| 66 | |||
| 67 | if (! $tempFlag) { | ||
| 68 | |||
| 69 | # Check that $name is valid and not already in use by another component | ||
| 70 | if (! $axmud::CLIENT->nameCheck($name, 16)) { | ||
| 71 | |||
| 72 | return $axmud::CLIENT->writeError( | ||
| 73 | 'Registry naming error: invalid name \'' . $name . '\'', | ||
| 74 | $class . '->new', | ||
| 75 | ); | ||
| 76 | |||
| 77 | } elsif ($worldObj->ivExists('componentHash', $name)) { | ||
| 78 | |||
| 79 | return $axmud::CLIENT->writeError( | ||
| 80 | 'Registry naming error: profile \'' . $worldObj->name . '\' already has a' | ||
| 81 | . ' component called \'' . $name . '\'', | ||
| 82 | $class . '->new', | ||
| 83 | ); | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | # Check $type is valid | ||
| 88 | OUTER: foreach my $standardType ($axmud::CLIENT->constComponentTypeList) { | ||
| 89 | |||
| 90 | if ($type eq $standardType) { | ||
| 91 | |||
| 92 | $matchFlag = TRUE; | ||
| 93 | last OUTER; | ||
| 94 | } | ||
| 95 | } | ||
| 96 | |||
| 97 | if (! $matchFlag) { | ||
| 98 | |||
| 99 | return $session->writeError( | ||
| 100 | 'Invalid room statement component type \'' . $type . '\'', | ||
| 101 | $class . '->new', | ||
| 102 | ); | ||
| 103 | } | ||
| 104 | |||
| 105 | # Setup | ||
| 106 | my $self = { | ||
| 107 | _objName => $name, | ||
| 108 | _objClass => $class, | ||
| 109 | _parentFile => $worldObj->name, | ||
| 110 | _parentWorld => undef, | ||
| 111 | _privFlag => FALSE, # All IVs are public | ||
| 112 | |||
| 113 | # Object IVs | ||
| 114 | # ---------- | ||
| 115 | |||
| 116 | # Unique name for this component | ||
| 117 | name => $name, | ||
| 118 | # The component type, one of 'verb_title', 'verb_descrip', 'verb_exit', 'verb_content', | ||
| 119 | # 'verb_special', 'brief_title', 'brief_exit', 'brief_title_exit', 'brief_exit_title', | ||
| 120 | # 'brief_content', 'room_cmd', 'mudlib_path', 'weather', 'ignore_line', 'custom' | ||
| 121 | type => $type, | ||
| 122 | |||
| 123 | # The component's size - how many lines are in this component. If set to 0, the size | ||
| 124 | # is dynamic, and we use other IVs to find the extent of the component. If set to a | ||
| 125 | # positive integer like '1' or '3', the component is always that size. (Valid range: | ||
| 126 | # 0-256) | ||
| 127 | size => 0, # Not a fixed size | ||
| 128 | # The component's minimum size; ignored if ->size is not 0. If the minimum size is 0, | ||
| 129 | # the component is optional. (Valid range: 0-256) | ||
| 130 | minSize => 0, | ||
| 131 | # The maximum number of lines to check. If we check this many lines without finding | ||
| 132 | # the 'stop' line, the last line checked is the 'stop' line (this IV overrides all | ||
| 133 | # the others, and must not be set to 0. Valid range - 1-256) | ||
| 134 | maxSize => 16, | ||
| 135 | # As the Locator analyses text received from the world, looking for room statements, the | ||
| 136 | # way in which lines of text are checked against patterns/tags: | ||
| 137 | # 'check_line' - Check each line, one at a time, against all patterns/tags | ||
| 138 | # 'check_pattern_tag' - Check each set of patterns/tags, one at a time, against all | ||
| 139 | # lines (NB both sets of start patterns/tags are always checked first) | ||
| 140 | analyseMode => 'check_line', | ||
| 141 | # Flag set to FALSE if the Locator task should treat normal/bold standard colour tags | ||
| 142 | # interchangeably when using the IVs that follow (NB Setting this flag to FALSE makes | ||
| 143 | # the Locator task run a little faster) | ||
| 144 | boldSensitiveFlag => FALSE, | ||
| 145 | # Flag set to TRUE if the Locator task should only use tags that applied at the | ||
| 146 | # beginning of the line, when it was displayed (because of tags at offset 0 on that | ||
| 147 | # line, or because of tags on earlier lines, depending on how the world sends its | ||
| 148 | # tags); set to FALSE if the Locator task should only use tags that were sent by the | ||
| 149 | # world on a particular line | ||
| 150 | # NB If both ->useInitialTagsFlag and ->useExplicitTagsFlag are TRUE, then only tags | ||
| 151 | # explicity applied to the beginning of this line are used | ||
| 152 | useInitialTagsFlag => FALSE, | ||
| 153 | # Flag set to TRUE if the Locator task should only use tags that were explicity applied | ||
| 154 | # to this line (i.e. because an escape sequence occured on this line); set to FALSE if | ||
| 155 | # the Locator Task should use tags that applied on any part of the line, including | ||
| 156 | # tags that appeared on previous lines and are still in effect | ||
| 157 | # NB If both ->useInitialTagsFlag and ->useExplicitTagsFlag are TRUE, then only tags | ||
| 158 | # explicity applied to the beginning of this line are used | ||
| 159 | useExplicitTagsFlag => FALSE, | ||
| 160 | # Flag set to TRUE if the Locator task should treat the lines of this component as a | ||
| 161 | # single string (good for worlds where, for example, an exit list is spread over more | ||
| 162 | # than one line); set to FALSE otherwise | ||
| 163 | combineLinesFlag => FALSE, | ||
| 164 | |||
| 165 | # Option for worlds (like Achaea) which combine a room description and a contents list | ||
| 166 | # on the same line. If set to 'undef', the Locator task uses the whole line. If set | ||
| 167 | # to a standard/xterm/RGB colour tag, the task only uses text of that colour | ||
| 168 | useTextColour => undef, | ||
| 169 | # Option for worlds (like BatMud, Discworld) which combine graphics (i.e. ASCII maps) | ||
| 170 | # and room statement on the same line. If set to 0, the Locator task uses the whole | ||
| 171 | # line. If set to a positive integer n, the task ignores the first n characters. | ||
| 172 | # Ignored if ->useTextColour is set | ||
| 173 | # NB If ->combineLinesFlag is TRUE, only the first n characters of the combined line are | ||
| 174 | # ignored | ||
| 175 | ignoreFirstChars => 0, | ||
| 176 | # Complementary option. If set to 0, the Locator task uses the whole line. If set to a | ||
| 177 | # positive integer n, the task ignores all characters after the first n characters. | ||
| 178 | # Ignored if ->useTextColour or ->ignoreFirstChars is set | ||
| 179 | # NB If ->combineLinesFlag is TRUE, only the first n characters of the combined line are | ||
| 180 | # used | ||
| 181 | useFirstChars => 0, | ||
| 182 | # Complementary option. Set to a regex. If the regex matches the line, only the | ||
| 183 | # contents of the group substrings are used (if there is more than one group | ||
| 184 | # substring, they are joined together as a single line of text). | ||
| 185 | # If the regex doesn't match the line, or if this IV is undefined/an empty string, the | ||
| 186 | # whole line is used. Ignored if ->useTextColour, ->ignoreFirstChars or | ||
| 187 | # ->useFirstChars are set | ||
| 188 | # NB If ->combineLinesFlag is TRUE, the pattern is matched against the combined line | ||
| 189 | usePatternGroups => undef, | ||
| 190 | |||
| 191 | # A list of component types and/or names that the Locator task should NOT attempt to | ||
| 192 | # extract, IF this component can be successfully extracted (added for ZombieMUD, where | ||
| 193 | # two types of verbose description may be seen, each using the same format of exit | ||
| 194 | # list) | ||
| 195 | # NB In case it's not clear, both component types (e.g. 'verb_descrip') and | ||
| 196 | # component names (e.g. 'verb_descrip_1') can be added to the list | ||
| 197 | noExtractList => [], | ||
| 198 | |||
| 199 | # If ->size is 0, we use these IVs to find the extent of the component (if the component | ||
| 200 | # is before the anchor line, we count backwards and the 'start' line occurs after the | ||
| 201 | # 'stop' line in the display buffer; otherwise, we count forwards, and the 'start' | ||
| 202 | # line occurs before the 'stop' line in the display buffer) | ||
| 203 | # The Locator checks the IVs in the order they appear here | ||
| 204 | # NB The IVs using Axmud colour/style tags can use any of the tags in | ||
| 205 | # GA::Client->constColourStyleList except the dummy style tags (like 'bold', | ||
| 206 | # 'reverse_off' and 'attribs_off'), and can also use all xterm/RGB colour tags | ||
| 207 | |||
| 208 | # Start at the first line which DOES include one of these patterns | ||
| 209 | startPatternList => [], | ||
| 210 | # Start at the first line which DOES include one of these Axmud colour/style tags | ||
| 211 | startTagList => [], | ||
| 212 | # Flag set to TRUE if all patterns/tags must be found in the line, in order for the | ||
| 213 | # line to be a start line (if any patterns/tags are specified), set to FALSE if only | ||
| 214 | # one pattern/tag needs to be found in the line, in order for the line to be a start | ||
| 215 | # line (if any patterns/tags are specified) | ||
| 216 | startAllFlag => FALSE, # Any one pattern and/or tag must be found | ||
| 217 | # Start at the first line which DOES match this mode: 'no_colour' - line contains no | ||
| 218 | # colour tags, 'no_style' - line contains no style tags (not including the dummy tags | ||
| 219 | # listed above), 'no_colour_style' - line contains no colour or style tags, 'default' | ||
| 220 | # - line may contain colour and/or style tags, depending on the contents of | ||
| 221 | # ->startTagList | ||
| 222 | startTagMode => 'default', | ||
| 223 | |||
| 224 | # Start at the first line which DOES NOT include one of these patterns | ||
| 225 | startNoPatternList => [], | ||
| 226 | # Start at the first line which DOES NOT include one of these Axmud colour/style tags | ||
| 227 | startNoTagList => [], | ||
| 228 | # Flag set to TRUE if all patterns/tags must be found in the line, in order for the | ||
| 229 | # line to NOT be a start line (if any patterns/tags are specified), set to FALSE if | ||
| 230 | # only one pattern/tag needs to be found in the line, in order for the line to NOT be | ||
| 231 | # a start line (if any patterns/tags are specified) | ||
| 232 | startNoAllFlag => FALSE, # Any one pattern and/or tag must be found | ||
| 233 | # Start at the first line which DOES NOT match this mode: 'no_colour' - line contains no | ||
| 234 | # colour tags, 'no_style' - line contains no style tags (not including the dummy tags | ||
| 235 | # listed above), 'no_colour_style' - line contains no colour or style tags, 'default' | ||
| 236 | # - line may contain colour and/or style tags, depending on the contents of | ||
| 237 | # ->startNoTagList | ||
| 238 | startNoTagMode => 'default', | ||
| 239 | |||
| 240 | # Skip the first line which DOES include one of these patterns | ||
| 241 | # NB ->startPatternList and ->startNoPatternList (etc) are consulted before | ||
| 242 | # ->skipPatternList (etc), so a first line matching start patterns/tags cannot be | ||
| 243 | # skipped | ||
| 244 | skipPatternList => [], | ||
| 245 | # Skip the first line which DOES include one of these Axmud colour/style tags | ||
| 246 | skipTagList => [], | ||
| 247 | # Flag set to TRUE if all patterns/tags must be found in the line, in order for the | ||
| 248 | # line to be skipped (if any patterns/tags are specified), set to FALSE if only one | ||
| 249 | # pattern/tag needs to be found in the line, in order for the line to be skipped | ||
| 250 | # (if any patterns/tags are specified) | ||
| 251 | skipAllFlag => FALSE, # Any one pattern and/or tag must be found | ||
| 252 | # Skip the first line which DOES match this mode: 'no_colour' - line contains no | ||
| 253 | # colour tags, 'no_style' - line contains no style tags (not including the dummy tags | ||
| 254 | # listed above), 'no_colour_style' - line contains no colour or style tags, 'default' | ||
| 255 | # - line may contain colour and/or style tags, depending on the contents of | ||
| 256 | # ->skipTagList | ||
| 257 | skipTagMode => 'default', | ||
| 258 | |||
| 259 | # Stop before the first line which DOES include one of these patterns | ||
| 260 | stopBeforePatternList => [], | ||
| 261 | # Stop before the first line which DOES include one of these Axmud colour/style tags | ||
| 262 | stopBeforeTagList => [], | ||
| 263 | # Flag set to TRUE if all patterns/tags must be found in the line, in order for the | ||
| 264 | # line to be a stop-before line (if any patterns/tags are specified), set to FALSE if | ||
| 265 | # only one pattern/tag needs to be found in the line, in order for the line to be a | ||
| 266 | # stop-before line (if any patterns/tags are specified) | ||
| 267 | stopBeforeAllFlag => FALSE, # Any one pattern and/or tag must be found | ||
| 268 | # Stop before the first line which DOES match this mode: 'no_colour' - line contains no | ||
| 269 | # colour tags, 'no_style' - line contains no style tags (not including the dummy tags | ||
| 270 | # listed above), 'no_colour_style' - line contains no colour or style tags, 'default' | ||
| 271 | # - line may contain colour and/or style tags, depending on the contents of | ||
| 272 | # ->stopBeforeTagList | ||
| 273 | stopBeforeTagMode => 'default', | ||
| 274 | |||
| 275 | # Stop before the first line which DOES NOT include one of these patterns | ||
| 276 | stopBeforeNoPatternList => [], | ||
| 277 | # Stop before the first line which DOES NOT include one of these Axmud colour/style tags | ||
| 278 | stopBeforeNoTagList => [], | ||
| 279 | # Flag set to TRUE if all patterns/tags must be found in the line, in order for the | ||
| 280 | # line to NOT be a stop-before line (if any patterns/tags are specified), set to FALSE | ||
| 281 | # if only one pattern/tag needs to be found in the line, in order for the line to NOT | ||
| 282 | # be a stop-before line (if any patterns/tags are specified) | ||
| 283 | stopBeforeNoAllFlag => FALSE, # Any one pattern and/or tag must be found | ||
| 284 | # Stop before the first line which DOES NOT match this mode: 'no_colour' - line contains | ||
| 285 | # no colour tags, 'no_style' - line contains no style tags (not including the dummy | ||
| 286 | # tags listed above), 'no_colour_style' - line contains no colour or style tags, | ||
| 287 | # 'default' - line may contain colour and/or style tags, depending on the contents of | ||
| 288 | # ->stopBeforeNoTagList | ||
| 289 | stopBeforeNoTagMode => 'default', | ||
| 290 | |||
| 291 | # Stop at the first line which DOES include one of these patterns | ||
| 292 | stopAtPatternList => [], | ||
| 293 | # Stop at the first line which DOES include one of these Axmud colour/style tags | ||
| 294 | stopAtTagList => [], | ||
| 295 | # Flag set to TRUE if all patterns/tags must be found in the line, in order for the | ||
| 296 | # line to be a stop-at line (if any patterns/tags are specified), set to FALSE if only | ||
| 297 | # one pattern/tag needs to be found in the line, in order for the line to be a stop-at | ||
| 298 | # line (if any patterns/tags are specified) | ||
| 299 | stopAtAllFlag => FALSE, # Any one pattern and/or tag must be found | ||
| 300 | # Stop at the first line which DOES match this mode: 'no_colour' - line contains no | ||
| 301 | # colour tags, 'no_style' - line contains no style tags (not including the dummy tags | ||
| 302 | # listed above), 'no_colour_style' - line contains no colour or style tags, 'default' | ||
| 303 | # - line may contain colour and/or style tags, depending on the contents of | ||
| 304 | # ->stopAtTagList | ||
| 305 | stopAtTagMode => 'default', | ||
| 306 | |||
| 307 | # Stop at the first line which DOES NOT include one of these patterns | ||
| 308 | stopAtNoPatternList => [], | ||
| 309 | # Stop at the first line which DOES NOT include one of these Axmud colour/style tags | ||
| 310 | stopAtNoTagList => [], | ||
| 311 | # Flag set to TRUE if all patterns/tags must be found in the line, in order for the | ||
| 312 | # line to NOT be a stop-at line (if any patterns/tags are specified), set to FALSE if | ||
| 313 | # only one pattern/tag needs to be found in the line, in order for the line to NOT be | ||
| 314 | # a stop-at line (if any patterns/tags are specified) | ||
| 315 | stopAtNoAllFlag => FALSE, # Any one pattern and/or tag must be found | ||
| 316 | # Stop at the first line which DOES NOT match this mode: 'no_colour' - line contains no | ||
| 317 | # colour tags, 'no_style' - line contains no style tags (not including the dummy tags | ||
| 318 | # listed above), 'no_colour_style' - line contains no colour or style tags, 'default' | ||
| 319 | # - line may contain colour and/or style tags, depending on the contents of | ||
| 320 | # ->stopAtNoTagList | ||
| 321 | stopAtNoTagMode => 'default', | ||
| 322 | |||
| 323 | # Stop at the nth line which starts with a capital letter. If 0, we don't check | ||
| 324 | # upper-case letters | ||
| 325 | upperCount => 0, | ||
| 326 | # Stop at the nth line which does starts with any alphanumeric character that's not a | ||
| 327 | # capital letter. If 0, we don't check these characters | ||
| 328 | otherCount => 0, | ||
| 329 | # Stop before/at a certain line: | ||
| 330 | # 'no_char' - stop one line before/at the first line containing no characters at all | ||
| 331 | # 'no_letter_num' - stop one line before/at the first line containing no alphanumeric | ||
| 332 | # characters | ||
| 333 | # 'no_start_letter_num' - stop one line before/at the first line which doesn't start | ||
| 334 | # with an alphanumeric character | ||
| 335 | # 'no_tag' - stop one line before/at the first line containing no Axmud colour/style | ||
| 336 | # tags at all (not including the dummy style tags like 'bold', 'reverse_off' and | ||
| 337 | # 'attribs_off') | ||
| 338 | # 'has_letter_num' - stop one line before/at the first line which DOES contain | ||
| 339 | # alphanumeric characters | ||
| 340 | # 'has_start_letter_num' - stop one line before/at the first line which DOES start | ||
| 341 | # with an alphanumeric character | ||
| 342 | # 'has_tag' - stop one line before/at the first line which DOES contain an Axmud | ||
| 343 | # colour/style tag (not including the dummy style tags like 'bold', 'reverse_off' | ||
| 344 | # and 'attribs_off') | ||
| 345 | # 'default' - ignore this IV | ||
| 346 | stopBeforeMode => 'default', | ||
| 347 | stopAtMode => 'default', | ||
| 348 | }; | ||
| 349 | |||
| 350 | # Bless the object into existence | ||
| 351 | bless $self, $class; | ||
| 352 | return $self; | ||
| 353 | } | ||
| 354 | |||
| 355 | sub clone { | ||
| 356 | |||
| 357 | # Creates a clone of an existing room statement component object | ||
| 358 | # | ||
| 359 | # Expected arguments | ||
| 360 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 361 | # $worldObj - The world profile object to which the new component will belong | ||
| 362 | # $name - Unique name for this component (can match the component type) (max | ||
| 363 | # 16 chars) | ||
| 364 | # $type - One of 'ignore_line', 'verb_title', 'verb_descrip', 'verb_exit', | ||
| 365 | # 'verb_content', 'verb_special', 'brief_title', 'brief_exit', | ||
| 366 | # 'brief_title_exit', 'brief_exit_title', 'brief_content', 'room_cmd', | ||
| 367 | # 'mudlib_path', 'custom' | ||
| 368 | # | ||
| 369 | # Return values | ||
| 370 | # 'undef' on improper arguments, or if $name or $type are invalid | ||
| 371 | # Blessed reference to the newly-created object on success | ||
| 372 | |||
| 373 | my ($self, $session, $worldObj, $name, $type, $check) = @_; | ||
| 374 | |||
| 375 | # Local variables | ||
| 376 | my $matchFlag; | ||
| 377 | |||
| 378 | # Check for improper arguments | ||
| 379 | if ( | ||
| 380 | ! defined $session || ! defined $worldObj || ! defined $name || ! defined $type | ||
| 381 | || defined $check | ||
| 382 | ) { | ||
| 383 | return $axmud::CLIENT->writeImproper($self->_objClass . '->clone', @_); | ||
| 384 | } | ||
| 385 | |||
| 386 | # Check that $name is valid and not already in use by another component | ||
| 387 | if (! $axmud::CLIENT->nameCheck($name, 16)) { | ||
| 388 | |||
| 389 | return $axmud::CLIENT->writeError( | ||
| 390 | 'Registry naming error: invalid name \'' . $name . '\'', | ||
| 391 | $self->_objClass . '->clone', | ||
| 392 | ); | ||
| 393 | |||
| 394 | } elsif ($worldObj->ivExists('componentHash', $name)) { | ||
| 395 | |||
| 396 | return $axmud::CLIENT->writeError( | ||
| 397 | 'Registry naming error: profile \'' . $worldObj->name . '\' already has a component' | ||
| 398 | . ' called \'' . $name . '\'', | ||
| 399 | $self->_objClass . '->clone', | ||
| 400 | ); | ||
| 401 | } | ||
| 402 | |||
| 403 | # Check $type is valid | ||
| 404 | OUTER: foreach my $standardType ($axmud::CLIENT->constComponentTypeList) { | ||
| 405 | |||
| 406 | if ($type eq $standardType) { | ||
| 407 | |||
| 408 | $matchFlag = TRUE; | ||
| 409 | last OUTER; | ||
| 410 | } | ||
| 411 | } | ||
| 412 | |||
| 413 | if (! $matchFlag) { | ||
| 414 | |||
| 415 | return $session->writeError( | ||
| 416 | 'Invalid room statement component type \'' . $type . '\'', | ||
| 417 | $self->_objClass . '->clone', | ||
| 418 | ); | ||
| 419 | } | ||
| 420 | |||
| 421 | # Setup | ||
| 422 | my $clone = { | ||
| 423 | _objName => $name, | ||
| 424 | _objClass => $self->_objClass, | ||
| 425 | _parentFile => $worldObj->name, | ||
| 426 | _parentWorld => undef, | ||
| 427 | _privFlag => FALSE, # All IVs are public | ||
| 428 | |||
| 429 | # Object IVs | ||
| 430 | # ---------- | ||
| 431 | |||
| 432 | name => $name, | ||
| 433 | type => $type, | ||
| 434 | |||
| 435 | size => $self->size, | ||
| 436 | minSize => $self->minSize, | ||
| 437 | maxSize => $self->maxSize, | ||
| 438 | analyseMode => $self->analyseMode, | ||
| 439 | boldSensitiveFlag => $self->boldSensitiveFlag, | ||
| 440 | useInitialTagsFlag => $self->useInitialTagsFlag, | ||
| 441 | useExplicitTagsFlag => $self->useExplicitTagsFlag, | ||
| 442 | combineLinesFlag => $self->combineLinesFlag, | ||
| 443 | |||
| 444 | useTextColour => $self->useTextColour, | ||
| 445 | ignoreFirstChars => $self->ignoreFirstChars, | ||
| 446 | useFirstChars => $self->useFirstChars, | ||
| 447 | usePatternGroups => $self->usePatternGroups, | ||
| 448 | |||
| 449 | noExtractList => [$self->noExtractList], | ||
| 450 | |||
| 451 | startPatternList => [$self->startPatternList], | ||
| 452 | startTagList => [$self->startTagList], | ||
| 453 | startAllFlag => $self->startAllFlag, | ||
| 454 | startTagMode => $self->startTagMode, | ||
| 455 | |||
| 456 | startNoPatternList => [$self->startNoPatternList], | ||
| 457 | startNoTagList => [$self->startNoTagList], | ||
| 458 | startNoAllFlag => $self->startNoAllFlag, | ||
| 459 | startNoTagMode => $self->startNoTagMode, | ||
| 460 | |||
| 461 | skipPatternList => [$self->skipPatternList], | ||
| 462 | skipTagList => [$self->skipTagList], | ||
| 463 | skipAllFlag => $self->skipAllFlag, | ||
| 464 | skipTagMode => $self->skipTagMode, | ||
| 465 | |||
| 466 | stopBeforePatternList => [$self->stopBeforePatternList], | ||
| 467 | stopBeforeTagList => [$self->stopBeforeTagList], | ||
| 468 | stopBeforeAllFlag => $self->stopBeforeAllFlag, | ||
| 469 | stopBeforeTagMode => $self->stopBeforeTagMode, | ||
| 470 | |||
| 471 | stopBeforeNoPatternList => [$self->stopBeforeNoPatternList], | ||
| 472 | stopBeforeNoTagList => [$self->stopBeforeNoTagList], | ||
| 473 | stopBeforeNoAllFlag => $self->stopBeforeNoAllFlag, | ||
| 474 | stopBeforeNoTagMode => $self->stopBeforeNoTagMode, | ||
| 475 | |||
| 476 | stopAtPatternList => [$self->stopAtPatternList], | ||
| 477 | stopAtTagList => [$self->stopAtTagList], | ||
| 478 | stopAtAllFlag => $self->stopAtAllFlag, | ||
| 479 | stopAtTagMode => $self->stopAtTagMode, | ||
| 480 | |||
| 481 | stopAtNoPatternList => [$self->stopAtNoPatternList], | ||
| 482 | stopAtNoTagList => [$self->stopAtNoTagList], | ||
| 483 | stopAtNoAllFlag => $self->stopAtNoAllFlag, | ||
| 484 | stopAtNoTagMode => $self->stopAtNoTagMode, | ||
| 485 | |||
| 486 | upperCount => $self->upperCount, | ||
| 487 | otherCount => $self->otherCount, | ||
| 488 | stopBeforeMode => $self->stopBeforeMode, | ||
| 489 | stopAtMode => $self->stopAtMode, | ||
| 490 | }; | ||
| 491 | |||
| 492 | # Bless the cloned object into existence | ||
| 493 | bless $clone, $self->_objClass; | ||
| 494 | return $clone; | ||
| 495 | } | ||
| 496 | |||
| 497 | ################## | ||
| 498 | # Methods | ||
| 499 | |||
| 500 | ################## | ||
| 501 | # Accessors - set | ||
| 502 | |||
| 503 | ################## | ||
| 504 | # Accessors - get | ||
| 505 | |||
| 506 | sub name | ||
| 507 | { $_[0]->{name} } | ||
| 508 | sub type | ||
| 509 | { $_[0]->{type} } | ||
| 510 | |||
| 511 | sub size | ||
| 512 | { $_[0]->{size} } | ||
| 513 | sub minSize | ||
| 514 | { $_[0]->{minSize} } | ||
| 515 | sub maxSize | ||
| 516 | { $_[0]->{maxSize} } | ||
| 517 | sub analyseMode | ||
| 518 | { $_[0]->{analyseMode} } | ||
| 519 | sub boldSensitiveFlag | ||
| 520 | { $_[0]->{boldSensitiveFlag} } | ||
| 521 | sub useInitialTagsFlag | ||
| 522 | { $_[0]->{useInitialTagsFlag} } | ||
| 523 | sub useExplicitTagsFlag | ||
| 524 | { $_[0]->{useExplicitTagsFlag} } | ||
| 525 | sub combineLinesFlag | ||
| 526 | { $_[0]->{combineLinesFlag} } | ||
| 527 | |||
| 528 | sub useTextColour | ||
| 529 | { $_[0]->{useTextColour} } | ||
| 530 | sub ignoreFirstChars | ||
| 531 | { $_[0]->{ignoreFirstChars} } | ||
| 532 | sub useFirstChars | ||
| 533 | { $_[0]->{useFirstChars} } | ||
| 534 | sub usePatternGroups | ||
| 535 | { $_[0]->{usePatternGroups} } | ||
| 536 | |||
| 537 | sub noExtractList | ||
| 538 | { my $self = shift; return @{$self->{noExtractList}}; } | ||
| 539 | |||
| 540 | sub startPatternList | ||
| 541 | { my $self = shift; return @{$self->{startPatternList}}; } | ||
| 542 | sub startTagList | ||
| 543 | { my $self = shift; return @{$self->{startTagList}}; } | ||
| 544 | sub startAllFlag | ||
| 545 | { $_[0]->{startAllFlag} } | ||
| 546 | sub startTagMode | ||
| 547 | { $_[0]->{startTagMode} } | ||
| 548 | |||
| 549 | sub startNoPatternList | ||
| 550 | { my $self = shift; return @{$self->{startNoPatternList}}; } | ||
| 551 | sub startNoTagList | ||
| 552 | { my $self = shift; return @{$self->{startNoTagList}}; } | ||
| 553 | sub startNoAllFlag | ||
| 554 | { $_[0]->{startNoAllFlag} } | ||
| 555 | sub startNoTagMode | ||
| 556 | { $_[0]->{startNoTagMode} } | ||
| 557 | |||
| 558 | sub skipPatternList | ||
| 559 | { my $self = shift; return @{$self->{skipPatternList}}; } | ||
| 560 | sub skipTagList | ||
| 561 | { my $self = shift; return @{$self->{skipTagList}}; } | ||
| 562 | sub skipAllFlag | ||
| 563 | { $_[0]->{skipAllFlag} } | ||
| 564 | sub skipTagMode | ||
| 565 | { $_[0]->{skipTagMode} } | ||
| 566 | |||
| 567 | sub stopBeforePatternList | ||
| 568 | { my $self = shift; return @{$self->{stopBeforePatternList}}; } | ||
| 569 | sub stopBeforeTagList | ||
| 570 | { my $self = shift; return @{$self->{stopBeforeTagList}}; } | ||
| 571 | sub stopBeforeAllFlag | ||
| 572 | { $_[0]->{stopBeforeAllFlag} } | ||
| 573 | sub stopBeforeTagMode | ||
| 574 | { $_[0]->{stopBeforeTagMode} } | ||
| 575 | |||
| 576 | sub stopBeforeNoPatternList | ||
| 577 | { my $self = shift; return @{$self->{stopBeforeNoPatternList}}; } | ||
| 578 | sub stopBeforeNoTagList | ||
| 579 | { my $self = shift; return @{$self->{stopBeforeNoTagList}}; } | ||
| 580 | sub stopBeforeNoAllFlag | ||
| 581 | { $_[0]->{stopBeforeNoAllFlag} } | ||
| 582 | sub stopBeforeNoTagMode | ||
| 583 | { $_[0]->{stopBeforeNoTagMode} } | ||
| 584 | |||
| 585 | sub stopAtPatternList | ||
| 586 | { my $self = shift; return @{$self->{stopAtPatternList}}; } | ||
| 587 | sub stopAtTagList | ||
| 588 | { my $self = shift; return @{$self->{stopAtTagList}}; } | ||
| 589 | sub stopAtAllFlag | ||
| 590 | { $_[0]->{stopAtAllFlag} } | ||
| 591 | sub stopAtTagMode | ||
| 592 | { $_[0]->{stopAtTagMode} } | ||
| 593 | |||
| 594 | sub stopAtNoPatternList | ||
| 595 | { my $self = shift; return @{$self->{stopAtNoPatternList}}; } | ||
| 596 | sub stopAtNoTagList | ||
| 597 | { my $self = shift; return @{$self->{stopAtNoTagList}}; } | ||
| 598 | sub stopAtNoAllFlag | ||
| 599 | { $_[0]->{stopAtNoAllFlag} } | ||
| 600 | sub stopAtNoTagMode | ||
| 601 | { $_[0]->{stopAtNoTagMode} } | ||
| 602 | |||
| 603 | sub upperCount | ||
| 604 | { $_[0]->{upperCount} } | ||
| 605 | sub otherCount | ||
| 606 | { $_[0]->{otherCount} } | ||
| 607 | sub stopBeforeMode | ||
| 608 | { $_[0]->{stopBeforeMode} } | ||
| 609 | sub stopAtMode | ||
| 610 | { $_[0]->{stopAtMode} } | ||
| 611 | } | ||
| 612 | |||
| 613 | # Package must return a true value | ||
| 614 | 1 |