blib/lib/Games/Axmud/ModelObj.pm untested

filter: Statementstmt 0.0% 0 / 1134 Branchbran 0.0% 0 / 268 Conditioncond 0.0% 0 / 204 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 193 Podpod 0.0% 0 / 145 totaltotal 0.0% 0 / 1944 CC 135 SCAR 27.5
CC
135
Cov
0%
countExits
110.0
compress
90.0
countChildren
42.0
CRAP 15.6
1 # Copyright (C) 2011-2022 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::ModelObj::XXX
16 # All model objects (the world model itself can be found in world_model.pm)
17  
18 { package Games::Axmud::ModelObj::Region;
19  
20 use strict;
21 use warnings;
22 use diagnostics;
23  
24 use Glib qw(TRUE FALSE);
25  
26 our @ISA = qw(Games::Axmud::Generic::ModelObj Games::Axmud);
27  
28 ##################
29 # Constructors
30  
31 sub new {
32  
33 # Prepare a new instance of the 'region' model object (which represents an area of the
34 # world)
35 #
36 # Expected arguments
37 # $session - The parent GA::Session (not stored as an IV)
38 # $name - A name for the region, e.g. 'woodlands' (NB If $name is longer than 32
39 # characters, it is shortened)
40 # $modelFlag - TRUE if this is a model object, FALSE if it's a non-model object
41 #
42 # Optional arguments
43 # $parentRegion - World model number of the region to which this region belongs ('undef'
44 # if there isn't a parent region or it this is a non-model object)
45 #
46 # Return values
47 # 'undef' on improper arguments
48 # Blessed reference to the newly-created object on success
49  
50 my ($class, $session, $name, $modelFlag, $parentRegion, $check) = @_;
51  
52 # Local variables
53 my ($parentFile, $parentProf);
54  
55 # Check for improper arguments
56 if (
57 ! defined $class || ! defined $session || ! defined $name || ! defined $modelFlag
58 || defined $check
59 ) {
60 return $axmud::CLIENT->writeImproper($class . '->new', @_);
61 }
62  
63 if ($modelFlag) {
64  
65 $parentFile = 'worldmodel';
66 $parentProf = $session->currentWorld->name;
67 }
68  
69 # Setup
70 my $self = Games::Axmud::Generic::ModelObj->new($session, $name, 'region');
71  
72 # Set standard IVs
73 $self->{_objName} = $name;
74 $self->{_objClass} = $class;
75 $self->{_parentFile} = $parentFile; # May be 'undef'
76 $self->{_parentWorld} = $parentProf; # May be 'undef'
77 $self->{_privFlag} = FALSE, # All IVs are public
78  
79 # Set group 1 IVs
80 $self->{parent} = $parentRegion;
81 $self->{childHash} = {};
82 $self->{concreteFlag} = FALSE;
83 $self->{aliveFlag} = FALSE;
84 $self->{sentientFlag} = FALSE;
85 $self->{portableFlag} = FALSE;
86 $self->{saleableFlag} = FALSE;
87 $self->{privateHash} = {};
88  
89 # No group 2 IVs for regions
90 # No group 3 IVs for regions
91 # No group 4 IVs for regions
92  
93 # Set group 5 IVs
94 # Flag set to TRUE if this region is temporary, in which case Axmud deletes it (and
95 # everything it contains) at the end of the current session, or if that's not possible, at
96 # the beginning of the next one
97 $self->{tempRegionFlag} = FALSE;
98  
99 # Bless the object into existence
100 bless $self, $class;
101 return $self;
102 }
103  
104 ##################
105 # Methods
106  
107 sub countChildren {
108  
109 # Called by GA::Cmd::ModelReport->do
110 # Counts the number of rooms in this region (actually, counts the number of child
111 # GA::ModelObj::Room objects)
112 # Counts the number of non-room objects in this region (actually, counts the number of
113 # children which aren't room objects, and the number of children of rooms which aren't
114 # GA::Obj::Exit objects). Makes a separate count of child regions which aren't included
115 # in the main count
116 # Counts the number of exits in this region (actually, counts the number of child
117 # room objects, then counts the number of exits that each of those rooms has)
118 #
119 # Expected arguments
120 # $session - The calling function's GA::Session
121 #
122 # Return values
123 # An empty list on improper arguments
124 # Otherwise, returns the counts as a list in the form
125 # (room_count, exit_count, other_count, child_region_count)
126  
127 my ($self, $session, $check) = @_;
128  
129 # Local variables
130 my (
131 $roomCount, $exitCount, $otherCount, $childRegionCount,
132 @emptyList,
133 );
134  
135 # Check for improper arguments
136 if (! defined $session || defined $check) {
137  
138 $axmud::CLIENT->writeImproper($self->_objClass . '->countChildren', @_);
139 return @emptyList;
140 }
141  
142 # Initialise variables
143 $roomCount = 0;
144 $exitCount = 0;
145 $otherCount = 0;
146 $childRegionCount = 0;
147  
148 OUTER: foreach my $num ($self->ivKeys('childHash')) {
149  
150 my $obj = $session->worldModelObj->ivShow('modelHash', $num);
151  
152 if ($obj->category eq 'room') {
153  
154 $roomCount++;
155 if ($obj->childHash) {
156  
157 $otherCount += $obj->ivPairs('childHash');
158 }
159  
160 if ($obj->exitNumHash) {
161  
162 $exitCount += $obj->ivPairs('exitNumHash');
163 }
164  
165 } elsif ($obj->category eq 'region') {
166  
167 $childRegionCount++;
168  
169 } else {
170  
171 $otherCount++;
172 }
173 }
174  
175 return ($roomCount, $exitCount, $otherCount, $childRegionCount);
176 }
177  
178 sub countChildrenCategories {
179  
180 # Called by GA::Cmd::ModelReport->do
181 # A modified version of $self->countChildren, which also counts the category of each
182 # child object that isn't a room or exit
183 #
184 # Counts the number of rooms in this region (actually, counts the number of child
185 # GA::ModelObj::Room objects)
186 # Counts the number of non-room objects in this region (actually, counts the number of
187 # children which aren't room objects, and the number of children of rooms which aren't
188 # GA::Obj::Exit ). Compiles a hash of categories, in the form
189 # $categoryHash{category_of_object} = number_of_occurences
190 # Counts the number of exits in this region (actually, counts the number of child
191 # room objects, then counts the number of exits that each of those rooms has)
192 #
193 # Expected arguments
194 # $session - The calling function's GA::Session
195 #
196 # Return values
197 # An empty list on improper arguments
198 # Otherwise, returns the counts as a list in the form
199 # (room_count, exit_count, other_count, reference_to_category_hash)
200  
201 my ($self, $session, $check) = @_;
202  
203 # Local variables
204 my (
205 $roomCount, $exitCount, $otherCount,
206 @emptyList,
207 %categoryHash,
208 );
209  
210 # Check for improper arguments
211 if (! defined $session || defined $check) {
212  
213 $axmud::CLIENT->writeImproper($self->_objClass . '->countChildrenCategories', @_);
214 return @emptyList;
215 }
216  
217 # Initialise variables
218 $roomCount = 0;
219 $exitCount = 0;
220 $otherCount = 0;
221 %categoryHash = (
222 'weapon' => 0,
223 'armour' => 0,
224 'garment' => 0,
225 'character' => 0,
226 'minion' => 0,
227 'sentient' => 0,
228 'creature' => 0,
229 'portable' => 0,
230 'decoration' => 0,
231 'custom' => 0,
232  
233 );
234  
235 OUTER: foreach my $num ($self->ivKeys('childHash')) {
236  
237 my $obj = $session->worldModelObj->ivShow('modelHash', $num);
238  
239 if ($obj->category eq 'room') {
240  
241 $roomCount++;
242 if ($obj->childHash) {
243  
244 INNER: foreach my $otherNum ($obj->ivKeys('childHash')) {
245  
246 my $otherObj = $session->worldModelObj->ivShow('modelHash', $otherNum);
247  
248 $otherCount++;
249 $categoryHash{$otherObj->category} = $categoryHash{$otherObj->category} + 1;
250 }
251 }
252  
253 if ($obj->exitNumHash) {
254  
255 $exitCount += $obj->ivPairs('exitNumHash');
256 }
257  
258 } elsif ($obj->category ne 'region') { # Regions can have child regions
259  
260 $otherCount++;
261 $categoryHash{$obj->category} = $categoryHash{$obj->category} + 1;
262 }
263 }
264  
265 return ($roomCount, $exitCount, $otherCount, \%categoryHash);
266 }
267  
268 sub countVisits {
269  
270 # Called by GA::Cmd::ModelReport->do
271 # Checks every room in this region (actually, all child objects which are
272 # GA::ModelObj::Room objects)
273 # Counts the number of rooms that have been visited, and compiles a hash in the form
274 # $hash{character_name} = number_of_visits
275 # ...where 'number_of_visits' counts the rooms visited by 'character_name', not including
276 # rooms whose 'dummy_room' room flag is set
277 #
278 # Expected arguments
279 # $session - The calling function's GA::Session
280 #
281 # Return values
282 # An empty list on improper arguments
283 # Otherwise, returns a list in the form
284 # (
285 # number_of_rooms, number_of_dummy_rooms, number_of_rooms_never_visited,
286 # reference_to_compiled_hash
287 # )
288 # ...where:
289 # 'number_of_rooms' counts the rooms whose 'dummy_room' flag is not set,
290 # 'number_of_dummy_rooms' counts the rooms whose 'dummy_room' flag is set,
291 # 'number_of_rooms_never_visited' counts the rooms never visited by any character,
292 # not including rooms whose 'dummy_room' room flag is set
293  
294 my ($self, $session, $check) = @_;
295  
296 # Local variables
297 my (
298 $roomCount, $dummyCount, $noVisitCount,
299 @emptyList,
300 %hash,
301 );
302  
303 # Check for improper arguments
304 if (! defined $session || defined $check) {
305  
306 $axmud::CLIENT->writeImproper($self->_objClass . '->countVisits', @_);
307 return @emptyList;
308 }
309  
310 # Initialise variables
311 $roomCount = 0;
312 $dummyCount = 0;
313 $noVisitCount = 0;
314  
315 OUTER: foreach my $num ($self->ivKeys('childHash')) {
316  
317 my $obj = $session->worldModelObj->ivShow('modelHash', $num);
318  
319 if ($obj->category eq 'room') {
320  
321 if ($obj->ivExists('roomFlagHash', 'dummy_room')) {
322  
323 $dummyCount++;
324  
325 } else {
326  
327 $roomCount++;
328  
329 if (! $obj->visitHash) {
330  
331 $noVisitCount++;
332  
333 } else {
334  
335 INNER: foreach my $char ($obj->ivKeys('visitHash')) {
336  
337 if (! exists $hash{$char}) {
338 $hash{$char} = 1;
339 } else {
340 $hash{$char} = $hash{$char} + 1;
341 }
342 }
343 }
344 }
345 }
346 }
347  
348 return ($roomCount, $dummyCount, $noVisitCount, \%hash);
349 }
350  
351 sub countCharVisits {
352  
353 # Called by GA::Cmd::ModelReport->do
354 # Checks every room in this region (actually, all child objects which are
355 # GA::ModelObj::Room objects)
356 # Counts the number of rooms that have been visited by a specified character, and the
357 # number that haven't (not including any rooms whose 'dummy_room' room flag is set,
358 # which are counted separately)
359 #
360 # Expected arguments
361 # $session - The calling function's GA::Session
362 # $char - The name of the character to check
363 #
364 # Return values
365 # An empty list on improper arguments
366 # Otherwise, returns a list in the form
367 # (
368 # number_of_rooms, number_of_dummy_rooms, number_of_rooms_visited,
369 # number_of_rooms_never_visited,
370 # )
371 # ...where:
372 # 'number_of_rooms' counts the rooms whose 'dummy_room' flag is not set,
373 # 'number_of_dummy_rooms' counts the rooms whose 'dummy_room' flag is set,
374 # 'number_of_rooms_visited' and 'number_of_rooms_never_visited' do not include rooms
375 # whose 'dummy_room' room flag is set
376  
377 my ($self, $session, $char, $check) = @_;
378  
379 # Local variables
380 my (
381 $roomCount, $dummyCount, $visitCount, $noVisitCount,
382 @emptyList,
383 );
384  
385 # Check for improper arguments
386 if (! defined $session || ! defined $char || defined $check) {
387  
388 $axmud::CLIENT->writeImproper($self->_objClass . '->countCharVisits', @_);
389 return @emptyList;
390 }
391  
392 # Initialise variables
393 $roomCount = 0;
394 $dummyCount = 0;
395 $noVisitCount = 0;
396 $visitCount = 0;
397  
398 foreach my $num ($self->ivKeys('childHash')) {
399  
400 my $obj = $session->worldModelObj->ivShow('modelHash', $num);
401  
402 if ($obj->category eq 'room') {
403  
404 if ($obj->ivExists('roomFlagHash', 'dummy_room')) {
405  
406 $dummyCount++;
407  
408 } else {
409  
410 $roomCount++;
411  
412 if (! $obj->visitHash || ! $obj->ivExists('visitHash', $char)) {
413 $noVisitCount++;
414 } else {
415 $visitCount++;
416 }
417 }
418 }
419 }
420  
421 return ($roomCount, $dummyCount, $visitCount, $noVisitCount);
422 }
423  
424 sub countGuilds {
425  
426 # Called by GA::Cmd::ModelReport->do
427 # Checks every room in this region (actually, all child objects which are
428 # GA::ModelObj::Room objects)
429 # Counts the number of rooms that are marked as guild rooms, and compiles a hash in the form
430 # $hash{guild_name} = number_of_rooms
431 #
432 # Expected arguments
433 # $session - The calling function's GA::Session
434 #
435 # Optional arguments
436 # @guildList - List of GA::Profile::Guild names. If specified, only those guilds are
437 # counted (but the counts still return the totals for all guilds)
438 #
439 # Return values
440 # An empty list on improper arguments
441 # Otherwise, returns a list in the form
442 # (total_number_of_rooms, total_number_of_guild_rooms, reference_to_compiled_hash)
443  
444 my ($self, $session, @guildList) = @_;
445  
446 # Local variables
447 my (
448 $roomCount, $guildRoomCount,
449 @emptyList,
450 %hash, %restrictHash,
451 );
452  
453 # Check for improper arguments
454 if (! defined $session) {
455  
456 $axmud::CLIENT->writeImproper($self->_objClass . '->countGuilds', @_);
457 return @emptyList;
458 }
459  
460 # Initialise variables
461 $roomCount = 0;
462 $guildRoomCount = 0;
463 foreach my $guild (@guildList) {
464  
465 $restrictHash{$guild} = undef;
466 }
467  
468 foreach my $num ($self->ivKeys('childHash')) {
469  
470 my $obj = $session->worldModelObj->ivShow('modelHash', $num);
471  
472 if ($obj->category eq 'room') {
473  
474 $roomCount++;
475  
476 if ($obj->roomGuild) {
477  
478 $guildRoomCount++;
479  
480 if (! @guildList || exists $restrictHash{$obj->roomGuild}) {
481  
482 if (exists $hash{$obj->roomGuild}) {
483 $hash{$obj->roomGuild} = $hash{$obj->roomGuild} + 1;
484 } else {
485 $hash{$obj->roomGuild} = 1;
486 }
487 }
488 }
489 }
490 }
491  
492 return ($roomCount, $guildRoomCount, \%hash);
493 }
494  
495 sub countRoomFlags {
496  
497 # Called by GA::Cmd::ModelReport->do
498 # Checks every room in this region (actually, all child objects which are
499 # GA::ModelObj::Room objects)
500 # Counts the number of rooms that have room flags, and compiles a hash in the form
501 # $hash{room_flag} = number_of_rooms
502 #
503 # Expected arguments
504 # $session - The calling function's GA::Session
505 #
506 # Optional arguments
507 # @roomFlagList - List of room flags. If specified, only those room flags are counted
508 # (but the counts still return the totals for all room flags)
509 #
510 # Return values
511 # An empty list on improper arguments
512 # Otherwise, returns a list in the form
513 # (total_number_of_rooms, total_number_of_room_flags, reference_to_compiled_hash)
514  
515 my ($self, $session, @roomFlagList) = @_;
516  
517 # Local variables
518 my (
519 $roomCount, $roomFlagCount,
520 @emptyList,
521 %hash, %restrictHash,
522 );
523  
524 # Check for improper arguments
525 if (! defined $session) {
526  
527 $axmud::CLIENT->writeImproper($self->_objClass . '->countRoomFlags', @_);
528 return @emptyList;
529 }
530  
531 # Initialise variables
532 $roomCount = 0;
533 $roomFlagCount = 0;
534 foreach my $guild (@roomFlagList) {
535  
536 $restrictHash{$guild} = undef;
537 }
538  
539 OUTER: foreach my $num ($self->ivKeys('childHash')) {
540  
541 my $obj = $session->worldModelObj->ivShow('modelHash', $num);
542  
543 if ($obj->category eq 'room') {
544  
545 $roomCount++;
546  
547 if ($obj->roomFlagHash) {
548  
549 $roomFlagCount++;
550  
551 INNER: foreach my $flag ($obj->ivKeys('roomFlagHash')) {
552  
553 if (! @roomFlagList || exists $restrictHash{$flag}) {
554  
555 if (exists $hash{$flag}) {
556 $hash{$flag} = $hash{$flag} + 1;
557 } else {
558 $hash{$flag} = 1;
559 }
560 }
561 }
562 }
563 }
564 }
565  
566 return ($roomCount, $roomFlagCount, \%hash);
567 }
568  
569 sub countRooms {
570  
571 # Called by GA::Cmd::ModelReport->do
572 # Counts the number of rooms in this region
573 # Keeps track of the number of rooms with at least one title and room description, as well
574 # as rooms with title(s) but no descrip(s), descrip(s) but no title(s) and rooms with
575 # neither titles nor descrips
576 #
577 # Expected arguments
578 # $session - The calling function's GA::Session
579 #
580 # Return values
581 # An empty list on improper arguments
582 # Otherwise, returns the counts as a list in the form
583 # (
584 # total_rooms_in_region, titles_and_descrips_count, titles_only_count,
585 # descrips_only_count, neither_count,
586 # )
587  
588 my ($self, $session, $check) = @_;
589  
590 # Local variables
591 my (
592 $roomCount, $bothCount, $titleCount, $descripCount, $noneCount,
593 @emptyList,
594 );
595  
596 # Check for improper arguments
597 if (! defined $session || defined $check) {
598  
599 $axmud::CLIENT->writeImproper($self->_objClass . '->countExits', @_);
600 return @emptyList;
601 }
602  
603 # Initialise variables
604 $roomCount = 0;
605 $bothCount = 0;
606 $titleCount = 0;
607 $descripCount = 0;
608 $noneCount = 0;
609  
610 OUTER: foreach my $num ($self->ivKeys('childHash')) {
611  
612 my $obj = $session->worldModelObj->ivShow('modelHash', $num);
613  
614 if ($obj->category eq 'room') {
615  
616 $roomCount++;
617  
618 if ($obj->titleList && $obj->descripHash) {
619 $bothCount++;
620 } elsif ($obj->titleList) {
621 $titleCount++;
622 } elsif ($obj->descripHash) {
623 $descripCount++;
624 } else {
625 $noneCount++;
626 }
627 }
628 }
629  
630 return ($roomCount, $bothCount, $titleCount, $descripCount, $noneCount);
631 }
632  
633 sub countExits {
634  
635 # Called by GA::Cmd::ModelReport->do
636 # Counts the number of exits in this region (actually, counts the number of child
637 # GA::ModelObj::Room objects, and then counts each of their exits)
638 # Keeps track of the number of unallocated, unallocatable, uncertain and incomplete exits,
639 # as well as the total number of exits. (Distinguishes between normal incomplete exits,
640 # and incomplete exits which have been marked as 'impassabe'/'mystery')
641 #
642 # Expected arguments
643 # $session - The calling function's GA::Session
644 #
645 # Return values
646 # An empty list on improper arguments
647 # Otherwise, returns the counts as a list in the form
648 # (
649 # total_exits_in_region, unallocated_count, unallocatable_count, uncertain_count,
650 # incomplete_not_impassable, incomplete_impassable_count, incomplete_myster_count,
651 # )
652  
653 my ($self, $session, $check) = @_;
654  
655 # Local variables
656 my (
657 $exitCount, $unallocatedCount, $unallocatableCount, $uncertainCount, $incompleteCount,
658 $incompImpassCount, $incompMysteryCount,
659 @emptyList,
660 );
661  
662 # Check for improper arguments
663 if (! defined $session || defined $check) {
664  
665 $axmud::CLIENT->writeImproper($self->_objClass . '->countExits', @_);
666 return @emptyList;
667 }
668  
669 # Initialise variables
670 $exitCount = 0;
671 $unallocatedCount = 0;
672 $unallocatableCount = 0;
673 $uncertainCount = 0;
674 $incompleteCount = 0;
675 $incompImpassCount = 0;
676 $incompMysteryCount = 0;
677  
678 OUTER: foreach my $num ($self->ivKeys('childHash')) {
679  
680 my $obj = $session->worldModelObj->ivShow('modelHash', $num);
681  
682 if ($obj->category eq 'room' && $obj->exitNumHash) {
683  
684 INNER: foreach my $exitNumber ($obj->ivValues('exitNumHash')) {
685  
686 my $exitObj = $session->worldModelObj->ivShow('exitModelHash', $exitNumber);
687  
688 $exitCount++;
689  
690 if ($exitObj->drawMode eq 'temp_alloc') {
691  
692 $unallocatedCount++;
693  
694 } elsif ($exitObj->drawMode eq 'temp_unalloc') {
695  
696 $unallocatedCount++;
697 $unallocatableCount++;
698  
699 } elsif (
700 $exitObj->destRoom
701 && (! $exitObj->twinExit)
702 && (! $exitObj->retraceFlag)
703 && (! $exitObj->oneWayFlag)
704 && ($exitObj->randomType eq 'none')
705 ) {
706 $uncertainCount++;
707  
708 } elsif (! $exitObj->destRoom) {
709  
710 if ($exitObj->exitOrnament eq 'impass') {
711 $incompImpassCount++;
712 } elsif ($exitObj->exitOrnament eq 'mystery') {
713 $incompMysteryCount++;
714 } elsif ($exitObj->randomType eq 'none') {
715 $incompleteCount++;
716 }
717 }
718 }
719 }
720 }
721  
722 return (
723 $exitCount, $unallocatedCount, $unallocatableCount, $uncertainCount, $incompleteCount,
724 $incompImpassCount, $incompMysteryCount,
725 );
726 }
727  
728 sub countCheckedDirs {
729  
730 # Called by GA::Cmd::ModelReport->do
731 # Counts the number of checked directions in this region (actually, counts the number of
732 # child GA::ModelObj::Room objects, and then counts each of their checked directions)
733 # Keeps track of the number of checkable directions at the same time
734 #
735 # Expected arguments
736 # $session - The calling function's GA::Session
737 # %dirHash - A hash of custom primary directions which are checkable, in the form
738 # $hash{custom_primary_dir} = undef
739 #
740 # Return values
741 # An empty list on improper arguments
742 # Otherwise, returns the counts as a list in the form
743 # ( total_exits_in_region, checked_direction_count, checkable_direction_count )
744  
745 my ($self, $session, %dirHash) = @_;
746  
747 # Local variables
748 my (
749 $exitCount, $checkedCount, $checkableCount,
750 %emptyHash,
751 );
752  
753 # Check for improper arguments
754 if (! defined $session || ! %dirHash) {
755  
756 $axmud::CLIENT->writeImproper($self->_objClass . '->countCheckedDirs', @_);
757 return %emptyHash;
758 }
759  
760 # Initialise variables
761 $exitCount = 0;
762 $checkedCount = 0;
763 $checkableCount = 0;
764  
765 foreach my $childNum ($self->ivKeys('childHash')) {
766  
767 my (
768 $childObj,
769 %thisHash,
770 );
771  
772 $childObj = $session->worldModelObj->ivShow('modelHash', $childNum);
773  
774 if ($childObj->category eq 'room') {
775  
776 foreach my $exitNum ($childObj->ivValues('exitNumHash')) {
777  
778 my $exitObj = $session->worldModelObj->ivShow('exitModelHash', $exitNum);
779  
780 $exitCount++;
781 }
782  
783 # Checkable directions are all of those remaining in %thisHash after deleting
784 # actual exit objects and checked directions
785 %thisHash = %dirHash;
786 foreach my $dir ($childObj->ivKeys('checkedDirHash')) {
787  
788 delete $thisHash{$dir};
789 }
790  
791 foreach my $dir ($childObj->sortedExitList) {
792  
793 delete $thisHash{$dir};
794 }
795  
796 $checkedCount += $childObj->ivPairs('checkedDirHash');
797 $checkableCount += scalar (keys %thisHash);
798 }
799 }
800  
801 return ($exitCount, $checkedCount, $checkableCount);
802 }
803  
804 ##################
805 # Accessors - set
806  
807 ##################
808 # Accessors - get
809  
810 # Group 5 IVs
811 sub tempRegionFlag
812 { $_[0]->{tempRegionFlag} }
813 }
814  
815 { package Games::Axmud::ModelObj::Room;
816  
817 use strict;
818 use warnings;
819 use diagnostics;
820  
821 use Glib qw(TRUE FALSE);
822  
823 our @ISA = qw(Games::Axmud::Generic::ModelObj Games::Axmud);
824  
825 ##################
826 # Constructors
827  
828 sub new {
829  
830 # Prepare a new instance of the 'room' model object (which represents a single room in the
831 # world)
832 #
833 # Expected arguments
834 # $session - The parent GA::Session (not stored as an IV)
835 # $descrip - A string to describe the room - the same as its room title, if that's
836 # available; if not, a shortened version of the verbose description
837 # (NB as of v1.1.408, the $descrip is no longer stored anywhere)
838 # $mode - 'model' for an room model object (stored in
839 # GA::Obj::WorldModel->modelHash), 'non_model' for non-model room
840 # object, for example one used by the Locator task, or 'global' for
841 # the room object stored in the global variable $DEFAULT_ROOM (and
842 # which provides default values for all room object IVs)
843 #
844 # Optional arguments
845 # $parentRegion - World model number of the region to which this room belongs ('undef'
846 # if there isn't a parent region or it this is a non-model object)
847 #
848 # Return values
849 # 'undef' on improper arguments
850 # Blessed reference to the newly-created object on success
851  
852 my ($class, $session, $descrip, $mode, $parentRegion, $check) = @_;
853  
854 # Check for improper arguments
855 if (
856 ! defined $class || ! defined $session || ! defined $descrip || ! defined $mode
857 || defined $check
858 ) {
859 return $axmud::CLIENT->writeImproper($class . '->new', @_);
860 }
861  
862 # For very large world models (10,000+ rooms), some computers tend to run out of memory
863 # which produces a Perl error and a crash
864 # In response, we try to reduce the size of the world model as much as possible. Most of the
865 # memory used is for room objects and exit objects (GA::Obj::Exit). Most of the memory
866 # used by each of those objects is for IVs with default values
867 # Therefore, we remove most of the IVs altogether, restoring them only if some part of the
868 # Axmud code sets the IV to a non-default value. Default values for each IV are obtained
869 # from a room object stored in a global variable, $DEFAULT_ROOM, instead of from the room
870 # object itself
871 my $self;
872  
873 if ($mode eq 'global') {
874  
875 # This object is to be stored in the global variable, $DEFAULT_ROOM. Therefore it has
876 # default values for all IVs
877  
878 # Set standard IVs
879 $self->{_objName} = 'room';
880 $self->{_objClass} = $class;
881 $self->{_parentFile} = undef;
882 $self->{_parentWorld} = undef;
883 $self->{_privFlag} = FALSE, # All IVs are public
884  
885 # Set group 1 IVs
886 $self->{name} = 'room';
887 $self->{category} = 'room';
888 $self->{modelFlag} = FALSE;
889 $self->{number} = undef;
890 $self->{parent} = $parentRegion;
891 $self->{childHash} = {};
892  
893 $self->{concreteFlag} = FALSE;
894 $self->{aliveFlag} = FALSE;
895 $self->{sentientFlag} = FALSE;
896 $self->{portableFlag} = FALSE;
897 $self->{saleableFlag} = FALSE;
898  
899 $self->{privateHash} = {};
900  
901 $self->{sourceCodePath} = undef;
902 $self->{notesList} = [];
903  
904 # No group 2 IVs for rooms
905 # No group 3 IVs for rooms
906 # No group 4 IVs for rooms
907  
908 # Set group 5 IVs
909 # The room's position in the map - specifically, its coordinates on the regionmap grid
910 # tied to this room's parent region
911 $self->{xPosBlocks} = undef;
912 $self->{yPosBlocks} = undef;
913 $self->{zPosBlocks} = undef;
914 # The room's tag, if it has been given one. Maximum 16 characters, and cannot contain
915 # the sequence '@@@', which is needed for route objects
916 $self->{roomTag} = undef;
917 # The offset (in pixels) where the room tag is drawn on the map. (0, 0) means draw the
918 # tag at the standard position; (10, -10) means draw it 10 pixels to the right, 10
919 # pixels higher
920 $self->{roomTagXOffset} = 0;
921 $self->{roomTagYOffset} = 0;
922 # The name of the guild, if this is a guild room ('undef' if all guilds can advance
923 # skills here)
924 $self->{roomGuild} = undef;
925 # The offset (in pixels) where the guild name is drawn on the map
926 $self->{roomGuildXOffset} = 0;
927 $self->{roomGuildYOffset} = 0;
928  
929 # When we move north from room A to a new room B, and when room B has an exit in the
930 # opposite direction, room A's departure exit is drawn as an 'uncertain' exit - we can
931 # definitely move north from A to B, and probably move south from B to A
932 # Until this is confirmed - at which point room A's departure exit becomes a one-way
933 # exit or a two-way exit - room B doesn't know that it has been set as the room A's
934 # departure exit's ->destinationRoom
935 # This is a problem because, if room B is deleted, room A's departure exit still points
936 # to the deleted room
937 # This room object is room B, and this hash IV contains a list of room A departure
938 # exits - uncertain exits - which lead here. The hash is in the form
939 # $uncertainExitHash{room_A_exit_number} = room_B_opposite_exit_number
940 # When an uncertain exit is created, the exit's destination room - this object - is told
941 # to update the hash
942 # When an uncertain exit becomes a two-way exit, the entry is deleted
943 $self->{uncertainExitHash} = {};
944 # We have the same issue with one-way exits. If we move north from room A to a new room
945 # B, when room B doesn't have an exit in the opposite direction, room A's departure
946 # exit is drawn as a '1-way' exit
947 # If room B is deleted, the one-way exit still points to it; if room B is moved to a new
948 # place in the same region, the automapper will still try to draw a one-way exit
949 # between them
950 # This room object is room B, and this hash IV contains a list of room A departure exits
951 # - one-way exits - which lead here. The hash is in the form
952 # $oneWayExitHash{room_A_exit_number} = undef
953 # When an one-way exit is created, the exit's destination room - this object - is told
954 # to update the hash
955 $self->{oneWayExitHash} = {};
956 # Also the same issue with involuntary/repulse exits patterns which have a defined
957 # destination room which is this room. When a pattern with a destination room is
958 # added, it is stored here. Hash in the form
959 # $invRepExitHash{departure_room_number} = undef
960 $self->{invRepExitHash} = {};
961 # Also the same issue with random exits which lead to a defined list of rooms, one of
962 # which which is this room. When a random exit adds this room to its list, it is
963 # stored here. Hash in the form
964 # $randomExitHash{exit_number} = undef
965 $self->{randomExitHash} = {};
966 # Some worlds have invisible exits hidden around the game for the user to discover. This
967 # hash stores 'checked directions' - primary and secondary directions which the user
968 # has tried, while the character was in this room (and while collection of checked
969 # directions was turned on), and which generated a failed exit message
970 # If an exit in the same direction is subsequently created, or if an unallocated exit is
971 # allocated to the same direction, the entry in this hash is automatically deleted
972 # Hash in the form
973 # $checkedDirHash{custom_primary_direction} = number_of_failed_attempts;
974 $self->{checkedDirHash} = {};
975 # Wilderness mode. Many worlds have 'wilderness' areas where exits aren't explicitly
976 # stated, but are assumed to exist between adjacent rooms
977 # There are three settings for this mode:
978 # 'normal' - All of this room's exits have a GA::Obj::Exit, and the automapper
979 # window draws each of those exits
980 # 'wild' - None of this room's exits have a GA::Obj::Exit, and the automapper
981 # window does not draw the room with any exits. Axmud assumes that movement
982 # between this room and any adjacent room (and back again) is possible
983 # 'border' - Like 'wild', except that Axmud assumes that movement between this room
984 # and any adjacent room is possible, but only if the adjacent room's ->wildMode is
985 # set to 'wild' or 'border'. If the adjacent room's ->wildMode is set to 'normal',
986 # Axmud assumes that no exit exists between the two rooms unless it has been
987 # explicitly added to the model with a GA::Obj::Exit
988 $self->{wildMode} = 'normal';
989  
990 # List of titles (i.e. brief descriptions) for this room
991 $self->{titleList} = [];
992 # Hash of known descriptions (i.e. verbose descriptions) for this room
993 # $self->descripHash{status} = description;
994 # 'status' is the current value of the world model's ->lightStatus, which is usually one
995 # of 'day', 'night' or 'darkness'
996 # When this object is created, ->descripHash contains a single key-value pair - the
997 # current light status and description. More pairs can be added later
998 $self->{descripHash} = {};
999 # GA::Profile::World->unspecifiedRoomPatternList provides a list of patterns that match
1000 # a line in 'unspecified' rooms (those that don't use a recognisable room statement;
1001 # typically a room whose exit list is completely obscured)
1002 # If this room is an unspecified room, a list of patterns that match a line telling us
1003 # that the character has arrived in the room. The world profile's unspecified patterns
1004 # are checked after these ones; patterns in this list should match lines that are only
1005 # used with this room
1006 $self->{unspecifiedPatternList} = [];
1007 # For non-model room objects, flag set to TRUE if the room has an unspecified room
1008 # statement (e.g. 'You emerge from the bushes covered in thorns' - the character is in
1009 # a new room, but we don't know which one, or anything about its description, contents
1010 # and exits)
1011 $self->{unspecifiedFlag} = FALSE;
1012 # For non-model room objects, set to TRUE if the room is dark (right now), so that we
1013 # don't know its description, contents or exits; set to FALSE otherwise
1014 $self->{currentlyDarkFlag} = FALSE;
1015  
1016 # List of named exits, listed in the same order that standard exits use
1017 # e.g. ('north', 'northeast', 'east'...)
1018 # For non-model rooms, it won't include hidden exits
1019 $self->{sortedExitList} = [];
1020 # List of exit objects in the format
1021 # $exitNumHash{direction} = exit_number_in_exit_model (model rooms)
1022 # $exitNumHash{direction} = exit_object (non-model rooms)
1023 # ('direction' matches an element in $self->sortedExitList)
1024 # For non-model rooms, this hash won't include hidden exits
1025 $self->{exitNumHash} = {};
1026  
1027 # List of failed exit patterns for this room, which tells the Locator task that a
1028 # movement command has failed (but that the exit used was blocked only temporarily,
1029 # for example when a guard is sometimes present, and sometimes not)
1030 $self->{failExitPatternList}
1031 = [];
1032 # A list of strings which match the text sent by the world, when we leave this room and
1033 # arrive at the destination room, but when the world doesn't send a room statement for
1034 # the destination room (called a 'faller' in LPmuds)
1035 $self->{specialDepartPatternList}
1036 = [];
1037 # Hash of involuntary exit patterns for this room, which tells the Locator task that an
1038 # involuntary move has taken place (for example, when dragged by a river from one room
1039 # to another)
1040 # The keys in the hash are patterns matching a line of received text
1041 # The corresponding values can be 'undef' if the destination room is unknown. Otherwise,
1042 # it can be any of these (checked in this order):
1043 # 1. The destination room's number
1044 # 2. A direction matching which matches an exit object's nominal direction, >dir
1045 # 3. A standard primary direction which matches an exit object's drawn map
1046 # direction, ->mapDir
1047 # 4. Any other value (including if no matching exits exist) is treated like an
1048 # unknown destination room
1049 $self->{involuntaryExitPatternHash}
1050 = {};
1051 # Hash of repulsed exit patterns for this room, which tells the Locator that not only
1052 # did an attempted move fail, but that the character has been moved to a new
1053 # (different) room - often in the opposite direction
1054 # The keys in the hash are patterns matching a line of received text
1055 # The corresponding values can be 'undef' if the destination room is unknown. Otherwise,
1056 # it can be any of these (checked in this order):
1057 # 1. The destination room's number
1058 # 2. A direction matching which matches an exit object's nominal direction, >dir
1059 # 3. A standard primary direction which matches an exit object's drawn map
1060 # direction, ->mapDir
1061 # 4. Any other value (including if no matching exits exist) is treated like an
1062 # unknown destination room
1063 $self->{repulseExitPatternHash} = {};
1064  
1065 # For worlds that provide a list of commands available in the room (typically instead of
1066 # an exit list, but not necessarily), a list of those commands
1067 $self->{roomCmdList} = [];
1068 # A temporary list of room commands. Set whenever $self->roomCmdList is set. Thereafter,
1069 # when the user types ';roomcommand', the first command is removed from the list,
1070 # executed as a world command, and added to the end of the list
1071 $self->{tempRoomCmdList} = [];
1072  
1073 # Records the number of visits to this room for each character. Hash in the form
1074 # $visitHash{character_name} = number_of_visits
1075 $self->{visitHash} = {};
1076 # Flag set to TRUE if this room can only be entered by certain guilds, races or indeed
1077 # named characters
1078 $self->{exclusiveFlag} = FALSE;
1079 # A hash of guilds, races, named chars etc allowed in this room (shouldn't include world
1080 # profiles), in the form
1081 # $exclusiveHash{profile_name} = undef
1082 $self->{exclusiveHash} = {};
1083  
1084 # Room flag hash - a hash of room properties. If the key exists in a hash, the 'flag' is
1085 # 'set to TRUE'; if a key doesn't exist in the hash, the 'flag' is 'set to FALSE'.
1086 # (The key's corresponding value is always 'undef'.)
1087 # If this hash is empty, all the flags are 'set to FALSE'.
1088 # GA::Obj::WorldModel has an equivalent hash containing all of the keys below. The key's
1089 # value is the colour the room should be painted, if the flag is set. When more than
1090 # one flag is set, GA::Obj::WorldModel works out for itself which should take priority
1091 $self->{roomFlagHash} = {};
1092 # On the last occasion that the room was drawn, the room flag that was used to draw the
1093 # room's interior (i.e. the highest priority room flag - so we only have to look it up
1094 # once per drawing cycle). Set to 'undef' if no room flags are set for this room
1095 $self->{lastRoomFlag} = undef;
1096  
1097 # GA::Generic::ModelObj defines ->sourceCodePath, the path to the object's source code
1098 # on the world (if known)
1099 # If the room is in a virtual area, this should be set to something like
1100 # '/filepath/forest/24,3' - the 'path' that the world gives for this individual room.
1101 # The following IV should be set to the file path for the virtual area itself, e.g.
1102 # '/filepath/forest'. If set to 'undef', the room isn't in a virtual area
1103 $self->{virtualAreaPath} = undef;
1104  
1105 # Data from this room supplied by various MUD protocols. At the moment, MSDP and MXP
1106 # data is supported
1107 # Note that MSDP is not used by the Locator task/automapper, as it often received after
1108 # the room statement (and after the automapper needs it)
1109 #
1110 # Hash storing data about the room. When MSDP supplies data, the following key-value
1111 # pairs are added:
1112 # 'vnum' => some_value,
1113 # 'name' => some_value,
1114 # 'area' => some_value,
1115 # 'xpos' => some_value,
1116 # 'ypos' => some_value,
1117 # 'zpos' => some_value,
1118 # 'terrain' => some_value,
1119 # When MXP supplies data, the following key-value pair is added:
1120 # 'vnum' => some_value,
1121 $self->{protocolRoomHash} = {};
1122 # Hash storing data about the room's exits. When MSDP supplies data, the following
1123 # key-value pair(s) are added:
1124 # 'abbrev_exit' => destination_room_vnum,
1125 $self->{protocolExitHash} = {};
1126  
1127 # List of blessed references to objects currently in this room (including player
1128 # characters). This IV is used for non-model rooms created by the Locator task; it
1129 # contains non-model objects for the contents of the Locator's current room
1130 $self->{tempObjList} = [];
1131 # Hash of hidden objects, in the form
1132 # $hiddenObjHash{number_of_hidden_object} = 'commands_to_obtain_it'
1133 # The keys of ->hiddenObjHash are a subset of the keys in $self->childHash.
1134 $self->{hiddenObjHash} = {};
1135 # Hash of things that can be 'searched' (or 'examined'), and the response in the form
1136 # $searchHash{string} = response
1137 # e.g. $searchHash{fireplace} = 'It's an empty fireplace'
1138 # Decorations which can be interacted with get their own model object,
1139 # GA::ModelObj::Decoration, and are stored in $self->childHash; this hash is used to
1140 # store things that only exist in response to 'search' or 'examine' commands
1141 $self->{searchHash} = {};
1142  
1143 # List of recognised nouns that appear in the verbose description (set by the
1144 # automapper, when the user allows it)
1145 $self->{nounList} = [];
1146 # List of recognised adjectives that appear in the verbose description (set by the
1147 # automapper, when the user allows it)
1148 $self->{adjList} = [];
1149  
1150 # List of Axbasic scripts to run, when the character arrives in this room (if the
1151 # automapper knows the current location). Only non-task based scripts are suitable for
1152 # this list
1153 $self->{arriveScriptList} = [];
1154  
1155 } elsif ($mode eq 'model') {
1156  
1157 # This object is stored in the world model, i.e. in GA::Obj::WorldModel->modelHash
1158  
1159 # Set standard IVs
1160 # $self->{_objName} = 'room';
1161 # $self->{_objClass} = $class;
1162 $self->{_parentFile} = 'worldmodel';
1163 $self->{_parentWorld} = $session->currentWorld->name;
1164 # $self->{_privFlag} = FALSE, # All IVs are public
1165  
1166 # Set group 1 IVs
1167 # $self->{category} = 'room';
1168 $self->{modelFlag} = TRUE;
1169 $self->{number} = undef; # Set later
1170 $self->{parent} = $parentRegion;
1171  
1172 # Set group 5 IVs
1173 $self->{xPosBlocks} = undef;
1174 $self->{yPosBlocks} = undef;
1175 $self->{zPosBlocks} = undef;
1176  
1177 } elsif ($mode eq 'non_model') {
1178  
1179 # This object is not stored in the world model (e.g. room objects used by the Locator
1180 # task)
1181  
1182 # Set standard IVs
1183 # $self->{_objName} = 'room';
1184 # $self->{_objClass} = $class;
1185 $self->{_parentFile} = undef;
1186 $self->{_parentWorld} = undef;
1187 # $self->{_privFlag} = FALSE, # All IVs are public
1188  
1189 # Set group 1 IVs
1190 # $self->{category} = 'room';
1191 $self->{modelFlag} = FALSE;
1192 $self->{number} = undef; # Set later
1193 $self->{parent} = undef;
1194  
1195 # Set group 5 IVs
1196 $self->{xPosBlocks} = undef;
1197 $self->{yPosBlocks} = undef;
1198 $self->{zPosBlocks} = undef;
1199 }
1200  
1201 # Bless the object into existence
1202 bless $self, $class;
1203 return $self;
1204 }
1205  
1206 sub compress {
1207  
1208 # Called by GA::Obj::File->updateExtractedData and GA::Cmd::CompressModel->do
1209 # Drastically reduce the amount of memory used by each exit object by completely removing
1210 # IVs whose values are the default values for an exit object (the code obtains the
1211 # default values from the exit object stored in the global variable $DEFAULT_EXIT,
1212 # instead)
1213 #
1214 # Expected arguments
1215 # (none besides $self)
1216 #
1217 # Return values
1218 # 'undef' on improper arguments
1219 # 1 otherwise
1220  
1221 my ($self, $check) = @_;
1222  
1223 # Local variables
1224 my %hash;
1225  
1226 # Check for improper arguments
1227 if (defined $check) {
1228  
1229 return $axmud::CLIENT->writeImproper($self->_objClass . '->compress', @_);
1230 }
1231  
1232 # Deal with universal IVs
1233 foreach my $iv ( qw (_objName _objClass _privFlag) ) {
1234  
1235 delete $self->{$iv};
1236 }
1237  
1238 # Deal with flag scalars which are FALSE by default
1239 foreach my $iv (
1240 qw (
1241 concreteFlag aliveFlag sentientFlag portableFlag saleableFlag unspecifiedFlag
1242 currentlyDarkFlag exclusiveFlag
1243 )
1244 ) {
1245 if (exists $self->{$iv} && ! $self->{$iv}) {
1246  
1247 delete $self->{$iv};
1248 }
1249 }
1250  
1251 # Deal with non-flag scalars which are undefined by default
1252 foreach my $iv (
1253 qw (
1254 sourceCodePath roomTag roomGuild lastRoomFlag virtualAreaPath
1255 )
1256 ) {
1257 if (exists $self->{$iv} && ! defined $self->{$iv}) {
1258  
1259 delete $self->{$iv};
1260 }
1261 }
1262  
1263 # Deal with non-flag scalars which have a defined value by default
1264 %hash = (
1265 'name' => 'room',
1266 'category' => 'room',
1267 'roomTagXOffset' => 0,
1268 'roomTagYOffset' => 0,
1269 'roomGuildXOffset' => 0,
1270 'roomGuildYOffset' => 0,
1271 'wildMode' => 'normal',
1272 );
1273  
1274 foreach my $iv (keys %hash) {
1275  
1276 if (exists $self->{$iv} && $self->{$iv} eq $hash{$iv}) {
1277  
1278 delete $self->{$iv};
1279 }
1280 }
1281  
1282 # Deal with lists which are empty by default
1283 foreach my $iv (
1284 qw (
1285 notesList titleList unspecifiedPatternList sortedExitList failExitPatternList
1286 specialDepartPatternList roomCmdList tempRoomCmdList tempObjList nounList adjList
1287 arriveScriptList
1288 )
1289 ) {
1290 if (exists $self->{$iv}) {
1291  
1292 my $listRef = $self->{$iv};
1293 if (! @$listRef) {
1294  
1295 delete $self->{$iv};
1296 }
1297 }
1298 }
1299  
1300 # Deal with hashes which are empty by default
1301 foreach my $iv (
1302 qw (
1303 childHash privateHash uncertainExitHash oneWayExitHash invRepExitHash randomExitHash
1304 checkedDirHash descripHash exitNumHash involuntaryExitPatternHash
1305 repulseExitPatternHash visitHash exclusiveHash roomFlagHash protocolRoomHash
1306 protocolExitHash hiddenObjHash searchHash
1307 )
1308 ) {
1309 if (exists $self->{$iv}) {
1310  
1311 my $hashRef = $self->{$iv};
1312 if (! %$hashRef) {
1313  
1314 delete $self->{$iv};
1315 }
1316 }
1317 }
1318  
1319 # Operation complete
1320 return 1;
1321 }
1322  
1323 ##################
1324 # Methods
1325  
1326 ##################
1327 # Accessors - set
1328  
1329 ##################
1330 # Accessors - get
1331  
1332 # To conserve memory, IVs with default values don't exist in the blessed reference; instead, we
1333 # obtain them from a default room object stored in the global variable $DEFAULT_ROOM
1334  
1335 sub _objName {
1336 if ( ! exists $_[0]->{_objName} )
1337 { $axmud::DEFAULT_ROOM->{_objName} } else { $_[0]->{_objName} }
1338 }
1339 sub _objClass {
1340 if ( ! exists $_[0]->{_objClass} )
1341 { $axmud::DEFAULT_ROOM->{_objClass} } else { $_[0]->{_objClass} }
1342 }
1343 sub _parentFile
1344 { $_[0]->{_parentFile} }
1345 sub _parentWorld
1346 { $_[0]->{_parentWorld} }
1347 sub _privFlag {
1348 if ( ! exists $_[0]->{_privFlag} )
1349 { $axmud::DEFAULT_ROOM->{_privFlag} } else { $_[0]->{_privFlag} }
1350 }
1351  
1352 # Group 1 IVs
1353 sub name {
1354 if ( ! exists $_[0]->{name} )
1355 { $axmud::DEFAULT_ROOM->{name} } else { $_[0]->{name} }
1356 }
1357 sub category {
1358 if ( ! exists $_[0]->{category} )
1359 { $axmud::DEFAULT_ROOM->{category} } else { $_[0]->{category} }
1360 }
1361 sub modelFlag
1362 { $_[0]->{modelFlag} }
1363 sub number
1364 { $_[0]->{number} }
1365 sub parent
1366 { $_[0]->{parent} }
1367 sub childHash {
1368 my $self = shift;
1369 if ( ! exists $self->{childHash} )
1370 { return %{$axmud::DEFAULT_ROOM->{childHash}}; }
1371 else
1372 { return %{$self->{childHash}}; }
1373 }
1374  
1375 sub concreteFlag {
1376 if ( ! exists $_[0]->{concreteFlag} )
1377 { $axmud::DEFAULT_ROOM->{concreteFlag} } else { $_[0]->{concreteFlag} }
1378 }
1379 sub aliveFlag {
1380 if ( ! exists $_[0]->{aliveFlag} )
1381 { $axmud::DEFAULT_ROOM->{aliveFlag} } else { $_[0]->{aliveFlag} }
1382 }
1383 sub sentientFlag {
1384 if ( ! exists $_[0]->{sentientFlag} )
1385 { $axmud::DEFAULT_ROOM->{sentientFlag} } else { $_[0]->{sentientFlag} }
1386 }
1387 sub portableFlag {
1388 if ( ! exists $_[0]->{portableFlag} )
1389 { $axmud::DEFAULT_ROOM->{portableFlag} } else { $_[0]->{portableFlag} }
1390 }
1391 sub saleableFlag {
1392 if ( ! exists $_[0]->{saleableFlag} )
1393 { $axmud::DEFAULT_ROOM->{saleableFlag} } else { $_[0]->{saleableFlag} }
1394 }
1395  
1396 sub privateHash {
1397 my $self = shift;
1398 if ( ! exists $self->{privateHash} )
1399 { return %{$axmud::DEFAULT_ROOM->{privateHash}}; }
1400 else
1401 { return %{$self->{privateHash}}; }
1402 }
1403  
1404 sub sourceCodePath {
1405 if ( ! exists $_[0]->{sourceCodePath} )
1406 { $axmud::DEFAULT_ROOM->{sourceCodePath} } else { $_[0]->{sourceCodePath} }
1407 }
1408 sub notesList {
1409 my $self = shift;
1410 if ( ! exists $self->{notesList} )
1411 { return @{$axmud::DEFAULT_ROOM->{notesList}}; }
1412 else
1413 { return @{$self->{notesList}}; }
1414 }
1415  
1416 # Group 5 IVs
1417 sub xPosBlocks
1418 { $_[0]->{xPosBlocks} }
1419 sub yPosBlocks
1420 { $_[0]->{yPosBlocks} }
1421 sub zPosBlocks
1422 { $_[0]->{zPosBlocks} }
1423 sub roomTag {
1424 if ( ! exists $_[0]->{roomTag} )
1425 { $axmud::DEFAULT_ROOM->{roomTag} } else { $_[0]->{roomTag} }
1426 }
1427 sub roomTagXOffset {
1428 if ( ! exists $_[0]->{roomTagXOffset} )
1429 { $axmud::DEFAULT_ROOM->{roomTagXOffset} } else { $_[0]->{roomTagXOffset} }
1430 }
1431 sub roomTagYOffset {
1432 if ( ! exists $_[0]->{roomTagYOffset} )
1433 { $axmud::DEFAULT_ROOM->{roomTagYOffset} } else { $_[0]->{roomTagYOffset} }
1434 }
1435 sub roomGuild {
1436 if ( ! exists $_[0]->{roomGuild} )
1437 { $axmud::DEFAULT_ROOM->{roomGuild} } else { $_[0]->{roomGuild} }
1438 }
1439 sub roomGuildXOffset {
1440 if ( ! exists $_[0]->{roomGuildXOffset} )
1441 { $axmud::DEFAULT_ROOM->{roomGuildXOffset} } else { $_[0]->{roomGuildXOffset} }
1442 }
1443 sub roomGuildYOffset {
1444 if ( ! exists $_[0]->{roomGuildYOffset} )
1445 { $axmud::DEFAULT_ROOM->{roomGuildYOffset} } else { $_[0]->{roomGuildYOffset} }
1446 }
1447  
1448 sub uncertainExitHash {
1449 my $self = shift;
1450 if ( ! exists $self->{uncertainExitHash} )
1451 { return %{$axmud::DEFAULT_ROOM->{uncertainExitHash}}; }
1452 else
1453 { return %{$self->{uncertainExitHash}}; }
1454 }
1455 sub oneWayExitHash {
1456 my $self = shift;
1457 if ( ! exists $self->{oneWayExitHash} )
1458 { return %{$axmud::DEFAULT_ROOM->{oneWayExitHash}}; }
1459 else
1460 { return %{$self->{oneWayExitHash}}; }
1461 }
1462 sub invRepExitHash {
1463 my $self = shift;
1464 if ( ! exists $self->{invRepExitHash} )
1465 { return %{$axmud::DEFAULT_ROOM->{invRepExitHash}}; }
1466 else
1467 { return %{$self->{invRepExitHash}}; }
1468 }
1469 sub randomExitHash {
1470 my $self = shift;
1471 if ( ! exists $self->{randomExitHash} )
1472 { return %{$axmud::DEFAULT_ROOM->{randomExitHash}}; }
1473 else
1474 { return %{$self->{randomExitHash}}; }
1475 }
1476 sub checkedDirHash {
1477 my $self = shift;
1478 if ( ! exists $self->{checkedDirHash} )
1479 { return %{$axmud::DEFAULT_ROOM->{checkedDirHash}}; }
1480 else
1481 { return %{$self->{checkedDirHash}}; }
1482 }
1483 sub wildMode {
1484 if ( ! exists $_[0]->{wildMode} )
1485 { $axmud::DEFAULT_ROOM->{wildMode} } else { $_[0]->{wildMode} }
1486 }
1487  
1488 sub titleList {
1489 my $self = shift;
1490 if ( ! exists $self->{titleList} )
1491 { return @{$axmud::DEFAULT_ROOM->{titleList}}; }
1492 else
1493 { return @{$self->{titleList}}; }
1494 }
1495 sub descripHash {
1496 my $self = shift;
1497 if ( ! exists $self->{descripHash} )
1498 { return %{$axmud::DEFAULT_ROOM->{descripHash}}; }
1499 else
1500 { return %{$self->{descripHash}}; }
1501 }
1502 sub unspecifiedPatternList {
1503 my $self = shift;
1504 if ( ! exists $self->{unspecifiedPatternList} )
1505 { return @{$axmud::DEFAULT_ROOM->{unspecifiedPatternList}}; }
1506 else
1507 { return @{$self->{unspecifiedPatternList}}; }
1508 }
1509 sub unspecifiedFlag {
1510 if ( ! exists $_[0]->{unspecifiedFlag} )
1511 { $axmud::DEFAULT_ROOM->{unspecifiedFlag} } else { $_[0]->{unspecifiedFlag} }
1512 }
1513 sub currentlyDarkFlag {
1514 if ( ! exists $_[0]->{currentlyDarkFlag} )
1515 { $axmud::DEFAULT_ROOM->{currentlyDarkFlag} } else { $_[0]->{currentlyDarkFlag} }
1516 }
1517  
1518 sub sortedExitList {
1519 my $self = shift;
1520 if ( ! exists $self->{sortedExitList} )
1521 { return @{$axmud::DEFAULT_ROOM->{sortedExitList}}; }
1522 else
1523 { return @{$self->{sortedExitList}}; }
1524 }
1525 sub exitNumHash {
1526 my $self = shift;
1527 if ( ! exists $self->{exitNumHash} )
1528 { return %{$axmud::DEFAULT_ROOM->{exitNumHash}}; }
1529 else
1530 { return %{$self->{exitNumHash}}; }
1531 }
1532 sub failExitPatternList {
1533 my $self = shift;
1534 if ( ! exists $self->{failExitPatternList} )
1535 { return @{$axmud::DEFAULT_ROOM->{failExitPatternList}}; }
1536 else
1537 { return @{$self->{failExitPatternList}}; }
1538 }
1539 sub specialDepartPatternList {
1540 my $self = shift;
1541 if ( ! exists $self->{specialDepartPatternList} )
1542 { return @{$axmud::DEFAULT_ROOM->{specialDepartPatternList}}; }
1543 else
1544 { return @{$self->{specialDepartPatternList}}; }
1545 }
1546 sub involuntaryExitPatternHash {
1547 my $self = shift;
1548 if ( ! exists $self->{involuntaryExitPatternHash} )
1549 { return %{$axmud::DEFAULT_ROOM->{involuntaryExitPatternHash}}; }
1550 else
1551 { return %{$self->{involuntaryExitPatternHash}}; }
1552 }
1553 sub repulseExitPatternHash {
1554 my $self = shift;
1555 if ( ! exists $self->{repulseExitPatternHash} )
1556 { return %{$axmud::DEFAULT_ROOM->{repulseExitPatternHash}}; }
1557 else
1558 { return %{$self->{repulseExitPatternHash}}; }
1559 }
1560  
1561 sub roomCmdList {
1562 my $self = shift;
1563 if ( ! exists $self->{roomCmdList} )
1564 { return @{$axmud::DEFAULT_ROOM->{roomCmdList}}; }
1565 else
1566 { return @{$self->{roomCmdList}}; }
1567 }
1568 sub tempRoomCmdList {
1569 my $self = shift;
1570 if ( ! exists $self->{tempRoomCmdList} )
1571 { return @{$axmud::DEFAULT_ROOM->{tempRoomCmdList}}; }
1572 else
1573 { return @{$self->{tempRoomCmdList}}; }
1574 }
1575  
1576 sub visitHash {
1577 my $self = shift;
1578 if ( ! exists $self->{visitHash} )
1579 { return %{$axmud::DEFAULT_ROOM->{visitHash}}; }
1580 else
1581 { return %{$self->{visitHash}}; }
1582 }
1583 sub exclusiveFlag {
1584 if ( ! exists $_[0]->{exclusiveFlag} )
1585 { $axmud::DEFAULT_ROOM->{exclusiveFlag} } else { $_[0]->{exclusiveFlag} }
1586 }
1587 sub exclusiveHash {
1588 my $self = shift;
1589 if ( ! exists $self->{exclusiveHash} )
1590 { return %{$axmud::DEFAULT_ROOM->{exclusiveHash}}; }
1591 else
1592 { return %{$self->{exclusiveHash}}; }
1593 }
1594  
1595 sub roomFlagHash {
1596 my $self = shift;
1597 if ( ! exists $self->{roomFlagHash} )
1598 { return %{$axmud::DEFAULT_ROOM->{roomFlagHash}}; }
1599 else
1600 { return %{$self->{roomFlagHash}}; }
1601 }
1602 sub lastRoomFlag {
1603 if ( ! exists $_[0]->{lastRoomFlag} )
1604 { $axmud::DEFAULT_ROOM->{lastRoomFlag} } else { $_[0]->{lastRoomFlag} }
1605 }
1606  
1607 sub virtualAreaPath {
1608 if ( ! exists $_[0]->{virtualAreaPath} )
1609 { $axmud::DEFAULT_ROOM->{virtualAreaPath} } else { $_[0]->{virtualAreaPath} }
1610 }
1611  
1612 sub protocolRoomHash {
1613 my $self = shift;
1614 if ( ! exists $self->{protocolRoomHash} )
1615 { return %{$axmud::DEFAULT_ROOM->{protocolRoomHash}}; }
1616 else
1617 { return %{$self->{protocolRoomHash}}; }
1618 }
1619 sub protocolExitHash {
1620 my $self = shift;
1621 if ( ! exists $self->{protocolExitHash} )
1622 { return %{$axmud::DEFAULT_ROOM->{protocolExitHash}}; }
1623 else
1624 { return %{$self->{protocolExitHash}}; }
1625 }
1626  
1627 sub tempObjList {
1628 my $self = shift;
1629 if ( ! exists $self->{tempObjList} )
1630 { return @{$axmud::DEFAULT_ROOM->{tempObjList}}; }
1631 else
1632 { return @{$self->{tempObjList}}; }
1633 }
1634 sub hiddenObjHash {
1635 my $self = shift;
1636 if ( ! exists $self->{hiddenObjHash} )
1637 { return %{$axmud::DEFAULT_ROOM->{hiddenObjHash}}; }
1638 else
1639 { return %{$self->{hiddenObjHash}}; }
1640 }
1641 sub searchHash {
1642 my $self = shift;
1643 if ( ! exists $self->{searchHash} )
1644 { return %{$axmud::DEFAULT_ROOM->{searchHash}}; }
1645 else
1646 { return %{$self->{searchHash}}; }
1647 }
1648  
1649 sub nounList {
1650 my $self = shift;
1651 if ( ! exists $self->{nounList} )
1652 { return @{$axmud::DEFAULT_ROOM->{nounList}}; }
1653 else
1654 { return @{$self->{nounList}}; }
1655 }
1656 sub adjList {
1657 my $self = shift;
1658 if ( ! exists $self->{adjList} )
1659 { return @{$axmud::DEFAULT_ROOM->{adjList}}; }
1660 else
1661 { return @{$self->{adjList}}; }
1662 }
1663  
1664 sub arriveScriptList {
1665 my $self = shift;
1666 if ( ! exists $self->{arriveScriptList} )
1667 { return @{$axmud::DEFAULT_ROOM->{arriveScriptList}}; }
1668 else
1669 { return @{$self->{arriveScriptList}}; }
1670 }
1671 }
1672  
1673 { package Games::Axmud::ModelObj::Weapon;
1674  
1675 use strict;
1676 use warnings;
1677 use diagnostics;
1678  
1679 use Glib qw(TRUE FALSE);
1680  
1681 our @ISA = qw(Games::Axmud::Generic::ModelObj Games::Axmud);
1682  
1683 ##################
1684 # Constructors
1685  
1686 sub new {
1687  
1688 # Prepare a new instance of the 'weapon' model object
1689 #
1690 # Expected arguments
1691 # $session - The parent GA::Session (not stored as an IV)
1692 # $name - A name for the weapon, e.g. 'sword' - usually the same as $self->noun
1693 # $modelFlag - TRUE if this is a model object, FALSE if it's a non-model object
1694 #
1695 # Optional arguments
1696 # $parent - World model number of the room where this object is found, the shop from
1697 # which it can be bought or the NPC from which it is liberated ('undef'
1698 # if there is no parent object or it this is a non-model object)
1699 #
1700 # Return values
1701 # 'undef' on improper arguments
1702 # Blessed reference to the newly-created object on success
1703  
1704 my ($class, $session, $name, $modelFlag, $parent, $check) = @_;
1705  
1706 # Local variables
1707 my ($parentFile, $parentProf);
1708  
1709 # Check for improper arguments
1710 if (
1711 ! defined $class || ! defined $session || ! defined $name || ! defined $modelFlag
1712 || defined $check
1713 ) {
1714 return $axmud::CLIENT->writeImproper($class . '->new', @_);
1715 }
1716  
1717 if ($modelFlag) {
1718  
1719 $parentFile = 'worldmodel';
1720 $parentProf = $session->currentWorld->name;
1721 }
1722  
1723 # Setup
1724 my $self = Games::Axmud::Generic::ModelObj->new($session, $name, 'weapon');
1725  
1726 # Set standard IVs
1727 $self->{_objName} = $name;
1728 $self->{_objClass} = $class;
1729 $self->{_parentFile} = $parentFile; # May be 'undef'
1730 $self->{_parentWorld} = $parentProf; # May be 'undef'
1731 $self->{_privFlag} = FALSE, # All IVs are public
1732  
1733 # Set group 1 IVs
1734 $self->{parent} = $parent;
1735 $self->{childHash} = {};
1736 $self->{concreteFlag} = TRUE;
1737 $self->{aliveFlag} = FALSE;
1738 $self->{sentientFlag} = FALSE;
1739 $self->{portableFlag} = TRUE;
1740 $self->{saleableFlag} = TRUE;
1741 $self->{privateHash} = {};
1742  
1743 # Set group 2 IVs (but leave other IVs set to their default values)
1744 $self->{noun} = $name;
1745 # No group 3 IVs for weapons
1746 # Set group 4 IVs (but leave other IVs set to their default values)
1747 $self->{explicitFlag} = TRUE;
1748 $self->{fixableFlag} = TRUE;
1749 $self->{sellableFlag} = TRUE;
1750 # No group 5 IVs for weapons
1751  
1752 # Bless the object into existence
1753 bless $self, $class;
1754 return $self;
1755 }
1756  
1757 ##################
1758 # Methods
1759  
1760 ##################
1761 # Accessors - set
1762  
1763 ##################
1764 # Accessors - get
1765  
1766 # Group 5 IVs (none for this object)
1767 }
1768  
1769 { package Games::Axmud::ModelObj::Armour;
1770  
1771 use strict;
1772 use warnings;
1773 use diagnostics;
1774  
1775 use Glib qw(TRUE FALSE);
1776  
1777 our @ISA = qw(Games::Axmud::Generic::ModelObj Games::Axmud);
1778  
1779 ##################
1780 # Constructors
1781  
1782 sub new {
1783  
1784 # Prepare a new instance of the 'armour' model object
1785 #
1786 # Expected arguments
1787 # $session - The parent GA::Session (not stored as an IV)
1788 # $name - A name for the armour, e.g. 'shield' - usually the same as $self->noun
1789 # $modelFlag - TRUE if this is a model object, FALSE if it's a non-model object
1790 #
1791 # Optional arguments
1792 # $parent - World model number of the room where this object is found, the shop from
1793 # which it can be bought or the NPC from which it is liberated ('undef'
1794 # if there is no parent object or it this is a non-model object)
1795 #
1796 # Return values
1797 # 'undef' on improper arguments
1798 # Blessed reference to the newly-created object on success
1799  
1800 my ($class, $session, $name, $modelFlag, $parent, $check) = @_;
1801  
1802 # Local variables
1803 my ($parentFile, $parentProf);
1804  
1805 # Check for improper arguments
1806 if (
1807 ! defined $class || ! defined $session || ! defined $name || ! defined $modelFlag
1808 || defined $check
1809 ) {
1810 return $axmud::CLIENT->writeImproper($class . '->new', @_);
1811 }
1812  
1813 if ($modelFlag) {
1814  
1815 $parentFile = 'worldmodel';
1816 $parentProf = $session->currentWorld->name;
1817 }
1818  
1819 # Setup
1820 my $self = Games::Axmud::Generic::ModelObj->new($session, $name, 'armour');
1821  
1822 # Set standard IVs
1823 $self->{_objName} = $name;
1824 $self->{_objClass} = $class;
1825 $self->{_parentFile} = $parentFile; # May be 'undef'
1826 $self->{_parentWorld} = $parentProf; # May be 'undef'
1827 $self->{_privFlag} = FALSE, # All IVs are public
1828  
1829 # Set group 1 IVs
1830 $self->{parent} = $parent;
1831 $self->{childHash} = {};
1832 $self->{concreteFlag} = TRUE;
1833 $self->{aliveFlag} = FALSE;
1834 $self->{sentientFlag} = FALSE;
1835 $self->{portableFlag} = TRUE;
1836 $self->{saleableFlag} = TRUE;
1837 $self->{privateHash} = {};
1838  
1839 # Set group 2 IVs (but leave other IVs set to their default values)
1840 $self->{noun} = $name;
1841 # No group 3 IVs for armours
1842 # Set group 4 IVs (but leave other IVs set to their default values)
1843 $self->{explicitFlag} = TRUE;
1844 $self->{fixableFlag} = TRUE;
1845 $self->{sellableFlag} = TRUE;
1846 # No group 5 IVs for armours
1847  
1848 # Bless the object into existence
1849 bless $self, $class;
1850 return $self;
1851 }
1852  
1853 ##################
1854 # Methods
1855  
1856 ##################
1857 # Accessors - set
1858  
1859 ##################
1860 # Accessors - get
1861  
1862 # Group 5 IVs (none for this object)
1863 }
1864  
1865 { package Games::Axmud::ModelObj::Garment;
1866  
1867 use strict;
1868 use warnings;
1869 use diagnostics;
1870  
1871 use Glib qw(TRUE FALSE);
1872  
1873 our @ISA = qw(Games::Axmud::Generic::ModelObj Games::Axmud);
1874  
1875 ##################
1876 # Constructors
1877  
1878 sub new {
1879  
1880 # Prepare a new instance of the 'garment' model object
1881 #
1882 # Expected arguments
1883 # $session - The parent GA::Session (not stored as an IV)
1884 # $name - A name for the garment, e.g. 'shirt' - usually the same as $self->noun
1885 # $modelFlag - TRUE if this is a model object, FALSE if it's a non-model object
1886 #
1887 # Optional arguments
1888 # $parent - World model number of the room where this object is found, the shop from
1889 # which it can be bought or the NPC from which it is liberated ('undef'
1890 # if there is no parent object or it this is a non-model object)
1891 #
1892 # Return values
1893 # 'undef' on improper arguments
1894 # Blessed reference to the newly-created object on success
1895  
1896 my ($class, $session, $name, $modelFlag, $parent, $check) = @_;
1897  
1898 # Local variables
1899 my ($parentFile, $parentProf);
1900  
1901 # Check for improper arguments
1902 if (
1903 ! defined $class || ! defined $session || ! defined $name || ! defined $modelFlag
1904 || defined $check
1905 ) {
1906 return $axmud::CLIENT->writeImproper($class . '->new', @_);
1907 }
1908  
1909 if ($modelFlag) {
1910  
1911 $parentFile = 'worldmodel';
1912 $parentProf = $session->currentWorld->name;
1913 }
1914  
1915 # Setup
1916 my $self = Games::Axmud::Generic::ModelObj->new($session, $name, 'garment');
1917  
1918 # Set standard IVs
1919 $self->{_objName} = $name;
1920 $self->{_objClass} = $class;
1921 $self->{_parentFile} = $parentFile; # May be 'undef'
1922 $self->{_parentWorld} = $parentProf; # May be 'undef'
1923 $self->{_privFlag} = FALSE, # All IVs are public
1924  
1925 # Set group 1 IVs
1926 $self->{parent} = $parent;
1927 $self->{childHash} = {};
1928 $self->{concreteFlag} = TRUE;
1929 $self->{aliveFlag} = FALSE;
1930 $self->{sentientFlag} = FALSE;
1931 $self->{portableFlag} = TRUE;
1932 $self->{saleableFlag} = TRUE;
1933 $self->{privateHash} = {};
1934  
1935 # Set group 2 IVs (but leave other IVs set to their default values)
1936 $self->{noun} = $name;
1937 # No group 3 IVs for garments
1938 # Set group 4 IVs (but leave other IVs set to their default values)
1939 $self->{explicitFlag} = TRUE;
1940 $self->{fixableFlag} = TRUE;
1941 $self->{sellableFlag} = TRUE;
1942 # No group 5 IVs for garments
1943  
1944 # Bless the object into existence
1945 bless $self, $class;
1946 return $self;
1947 }
1948  
1949 ##################
1950 # Methods
1951  
1952 ##################
1953 # Accessors - set
1954  
1955 ##################
1956 # Accessors - get
1957  
1958 # Group 5 IVs (none for this object)
1959 }
1960  
1961 { package Games::Axmud::ModelObj::Char;
1962  
1963 use strict;
1964 use warnings;
1965 use diagnostics;
1966  
1967 use Glib qw(TRUE FALSE);
1968  
1969 our @ISA = qw(Games::Axmud::Generic::ModelObj Games::Axmud);
1970  
1971 ##################
1972 # Constructors
1973  
1974 sub new {
1975  
1976 # Prepare a new instance of the 'character' model object (which represents a character on
1977 # the world which isn't the one you're using at the moment)
1978 #
1979 # Expected arguments
1980 # $session - The parent GA::Session (not stored as an IV)
1981 # $name - The character's name (absolute max 32 chars)
1982 # $modelFlag - TRUE if this is a model object, FALSE if it's a non-model object
1983 #
1984 # Optional arguments
1985 # $parent - World model number of the parent object; probably never used, but the
1986 # parent could conceivably be a 'custom' model object
1987 #
1988 # Return values
1989 # 'undef' on improper arguments
1990 # Blessed reference to the newly-created object on success
1991  
1992 my ($class, $session, $name, $modelFlag, $parent, $check) = @_;
1993  
1994 # Local variables
1995 my ($parentFile, $parentProf);
1996  
1997 # Check for improper arguments
1998 if (
1999 ! defined $class || ! defined $session || ! defined $name || ! defined $modelFlag
2000 || defined $check
2001 ) {
2002 return $axmud::CLIENT->writeImproper($class . '->new', @_);
2003 }
2004  
2005 # Special check (for character and minion objects only) - name must not be longer than 32
2006 # chars
2007 if (! $axmud::CLIENT->nameCheck($name, 32)) {
2008  
2009 return $session->writeError('Illegal name \'' . $name . '\'', $class . '->new');
2010 }
2011  
2012 if ($modelFlag) {
2013  
2014 $parentFile = 'worldmodel';
2015 $parentProf = $session->currentWorld->name;
2016 }
2017  
2018 # Setup
2019 my $self = Games::Axmud::Generic::ModelObj->new($session, $name, 'char');
2020  
2021 # Set standard IVs
2022 $self->{_objName} = $name;
2023 $self->{_objClass} = $class;
2024 $self->{_parentFile} = $parentFile; # May be 'undef'
2025 $self->{_parentWorld} = $parentProf; # May be 'undef'
2026 $self->{_privFlag} = FALSE, # All IVs are public
2027  
2028 # Set group 1 IVs
2029 $self->{parent} = $parent;
2030 $self->{childHash} = {};
2031 $self->{concreteFlag} = TRUE;
2032 $self->{aliveFlag} = TRUE;
2033 $self->{sentientFlag} = TRUE;
2034 $self->{portableFlag} = FALSE;
2035 $self->{saleableFlag} = FALSE;
2036 $self->{privateHash} = {};
2037  
2038 # Set group 2 IVs (but leave other IVs set to their default values)
2039 $self->{noun} = $name;
2040 # Group 3 IVs - use default values
2041 # No group 4 IVs for characters
2042  
2043 # Set group 5 IVs
2044 # The character's guild, if known ('undef' if not)
2045 $self->{guild} = undef;
2046 # The character's race, if known ('undef' if not)
2047 $self->{race} = undef;
2048 # Flag set to TRUE if this character is owned by you, FALSE if it is owned by someone else
2049 $self->{ownCharFlag} = FALSE;
2050 # A string representing the owner of the character. Can be set to anything - the owner's
2051 # real-life name, or their nickname, or the name of their main character. Characters owned
2052 # by you can also have this set to anything - 'me' or 'HandsomeKing', etc
2053 $self->{owner} = undef;
2054  
2055 # What sort of character is this? ('mortal' for an ordinary character, 'wiz' for any kind of
2056 # admin, immortal or coder, 'test' for one of the world's official playtesting characters
2057 # at the world, if they're allowed)
2058 $self->{mortalStatus} = 'mortal';
2059  
2060 # Diplomatic status
2061 # Can mark this character as 'friendly', 'neutral' or 'hostile'
2062 $self->{diplomaticStatus} = 'neutral';
2063 # Flag set to TRUE if this character has ever attacked one of yours, FALSE if not
2064 $self->{grudgeFlag} = FALSE;
2065 # What to do, if this character attacks you. Flag set to TRUE for 'fight', FALSE for 'run
2066 # away'
2067 $self->{fightBackFlag} = FALSE;
2068  
2069 # The character's level (if known exactly, 0 if not)
2070 $self->{level} = 0;
2071 # If the exact level isn't known, a level for which the character is definitely stronger
2072 # (approximate)
2073 $self->{weakerLevel} = 0;
2074 # If the exact level isn't known, a level for which the character is definitely weaker
2075 # (approximate)
2076 $self->{strongerLevel} = 0;
2077 # Other info about the character, if known ('undef' if not)
2078 $self->{totalXP} = undef;
2079 $self->{totalQP} = undef;
2080 # List of quests the character has completed (if known)
2081 $self->{questList} = [];
2082  
2083 # What the character was carrying, last time they were seen (just a simple list of strings
2084 # - not linked to model objects)
2085 $self->{inventoryList} = [];
2086  
2087 # Bless the object into existence
2088 bless $self, $class;
2089 return $self;
2090 }
2091  
2092 ##################
2093 # Methods
2094  
2095 ##################
2096 # Accessors - set
2097  
2098 ##################
2099 # Accessors - get
2100  
2101 # Group 5 IVs
2102 sub guild
2103 { $_[0]->{guild} }
2104 sub race
2105 { $_[0]->{race} }
2106 sub ownCharFlag
2107 { $_[0]->{ownCharFlag} }
2108 sub owner
2109 { $_[0]->{owner} }
2110  
2111 sub mortalStatus
2112 { $_[0]->{mortalStatus} }
2113  
2114 sub diplomaticStatus
2115 { $_[0]->{diplomaticStatus} }
2116 sub grudgeFlag
2117 { $_[0]->{grudgeFlag} }
2118 sub fightBackFlag
2119 { $_[0]->{fightBackFlag} }
2120  
2121 sub level
2122 { $_[0]->{level} }
2123 sub weakerLevel
2124 { $_[0]->{weakerLevel} }
2125 sub strongerLevel
2126 { $_[0]->{strongerLevel} }
2127 sub totalXP
2128 { $_[0]->{totalXP} }
2129 sub totalQP
2130 { $_[0]->{totalQP} }
2131 sub questList
2132 { my $self = shift; return @{$self->{questList}}; }
2133  
2134 sub inventoryList
2135 { my $self = shift; return @{$self->{inventoryList}}; }
2136 }
2137  
2138 { package Games::Axmud::ModelObj::Minion;
2139  
2140 use strict;
2141 use warnings;
2142 use diagnostics;
2143  
2144 use Glib qw(TRUE FALSE);
2145  
2146 our @ISA = qw(Games::Axmud::Generic::ModelObj Games::Axmud);
2147  
2148 ##################
2149 # Constructors
2150  
2151 sub new {
2152  
2153 # Prepare a new instance of the 'minion' model object (which represents a non-player
2154 # character directly controlled - at the moment, or in general - by a character)
2155 #
2156 # Expected arguments
2157 # $session - The parent GA::Session (not stored as an IV)
2158 # $name - The minion's name (absolute max 32 chars)
2159 # $modelFlag - TRUE if this is a model object, FALSE if it's a non-model object
2160 #
2161 # Optional arguments
2162 # $parent - World model number of the parent object; probably never used, but the
2163 # parent could conceivably be a 'custom' model object
2164 #
2165 # Return values
2166 # 'undef' on improper arguments
2167 # Blessed reference to the newly-created object on success
2168  
2169 my ($class, $session, $name, $modelFlag, $parent, $check) = @_;
2170  
2171 # Local variables
2172 my ($parentFile, $parentProf);
2173  
2174 # Check for improper arguments
2175 if (
2176 ! defined $class || ! defined $session || ! defined $name || ! defined $modelFlag
2177 || defined $check
2178 ) {
2179 return $axmud::CLIENT->writeImproper($class . '->new', @_);
2180 }
2181  
2182 # Special check (for character and minion objects only) - name must not be longer than 32
2183 # chars
2184 if (! $axmud::CLIENT->nameCheck($name, 32)) {
2185  
2186 return $session->writeError('Illegal name \'' . $name . '\'', $class . '->new');
2187 }
2188  
2189 if ($modelFlag) {
2190  
2191 $parentFile = 'worldmodel';
2192 $parentProf = $session->currentWorld->name;
2193 }
2194  
2195 # Setup
2196 my $self = Games::Axmud::Generic::ModelObj->new($session, $name, 'minion');
2197  
2198 # Set standard IVs
2199 $self->{_objName} = $name;
2200 $self->{_objClass} = $class;
2201 $self->{_parentFile} = $parentFile; # May be 'undef'
2202 $self->{_parentWorld} = $parentProf; # May be 'undef'
2203 $self->{_privFlag} = FALSE, # All IVs are public
2204  
2205 # Set group 1 IVs
2206 $self->{parent} = $parent;
2207 $self->{childHash} = {};
2208 $self->{concreteFlag} = TRUE;
2209 $self->{aliveFlag} = TRUE;
2210 $self->{sentientFlag} = TRUE; # Minions are made sentient by default
2211 $self->{portableFlag} = FALSE;
2212 $self->{saleableFlag} = FALSE;
2213 $self->{privateHash} = {};
2214  
2215 # Set group 2 IVs (but leave other IVs set to their default values)
2216 $self->{noun} = $name;
2217 # Group 3 IVs - use default values
2218 # No group 4 IVs for minions
2219  
2220 # Set group 5 IVs
2221 # The minion's guild, if known ('undef' if not)
2222 $self->{guild} = undef;
2223 # The minion's race, if known ('undef' if not)
2224 $self->{race} = undef;
2225 # Flag set to TRUE if this minion is owned by you, FALSE if it is owned by someone else
2226 $self->{ownMinionFlag} = FALSE;
2227  
2228 # The minion's level (if known exactly, 0 if not)
2229 $self->{level} = 0;
2230 # If the exact level isn't known, a level for which the minion is definitely stronger
2231 # (approximate)
2232 $self->{weakerLevel} = 0;
2233 # If the exact level isn't known, a level for which the minion is definitely weaker
2234 # (approximate)
2235 $self->{strongerLevel} = 0;
2236  
2237 # What the minion was carrying, last time they were seen (just a simple list of strings -
2238 # not linked to model objects)
2239 $self->{inventoryList} = [];
2240  
2241 # The cost of acquiring this minion (if it can be bought), in the world profile's standard
2242 # currency unit
2243 $self->{value} = 0;
2244  
2245 # Bless the object into existence
2246 bless $self, $class;
2247 return $self;
2248 }
2249  
2250 ##################
2251 # Methods
2252  
2253 ##################
2254 # Accessors - set
2255  
2256 ##################
2257 # Accessors - get
2258  
2259 # Group 5 IVs
2260 sub guild
2261 { $_[0]->{guild} }
2262 sub race
2263 { $_[0]->{race} }
2264 sub ownMinionFlag
2265 { $_[0]->{ownMinionFlag} }
2266  
2267 sub level
2268 { $_[0]->{level} }
2269 sub weakerLevel
2270 { $_[0]->{weakerLevel} }
2271 sub strongerLevel
2272 { $_[0]->{strongerLevel} }
2273  
2274 sub inventoryList
2275 { my $self = shift; return @{$self->{inventoryList}}; }
2276  
2277 sub value
2278 { $_[0]->{value} }
2279 }
2280  
2281 { package Games::Axmud::ModelObj::Sentient;
2282  
2283 use strict;
2284 use warnings;
2285 use diagnostics;
2286  
2287 use Glib qw(TRUE FALSE);
2288  
2289 our @ISA = qw(Games::Axmud::Generic::ModelObj Games::Axmud);
2290  
2291 ##################
2292 # Constructors
2293  
2294 sub new {
2295  
2296 # Prepare a new instance of the 'sentient' model object (representing an NPC capable of
2297 # language, at least in theory)
2298 #
2299 # Expected arguments
2300 # $session - The parent GA::Session (not stored as an IV)
2301 # $name - A name for the sentient, e.g. 'guard' - usually the same as $self->noun
2302 # $modelFlag - TRUE if this is a model object, FALSE if it's a non-model object
2303 #
2304 # Optional arguments
2305 # $parent - World model number of the room where this object is found or the region in
2306 # which it wanders ('undef' if there is no parent object or it this is a
2307 # non-model object)
2308 #
2309 # Return values
2310 # 'undef' on improper arguments
2311 # Blessed reference to the newly-created object on success
2312  
2313 my ($class, $session, $name, $modelFlag, $parent, $check) = @_;
2314  
2315 # Local variables
2316 my ($parentFile, $parentProf);
2317  
2318 # Check for improper arguments
2319 if (
2320 ! defined $class || ! defined $session || ! defined $name || ! defined $modelFlag
2321 || defined $check
2322 ) {
2323 return $axmud::CLIENT->writeImproper($class . '->new', @_);
2324 }
2325  
2326 if ($modelFlag) {
2327  
2328 $parentFile = 'worldmodel';
2329 $parentProf = $session->currentWorld->name;
2330 }
2331  
2332 # Setup
2333 my $self = Games::Axmud::Generic::ModelObj->new($session, $name, 'sentient');
2334  
2335 # Set standard IVs
2336 $self->{_objName} = $name;
2337 $self->{_objClass} = $class;
2338 $self->{_parentFile} = $parentFile; # May be 'undef'
2339 $self->{_parentWorld} = $parentProf; # May be 'undef'
2340 $self->{_privFlag} = FALSE, # All IVs are public
2341  
2342 # Set group 1 IVs
2343 $self->{parent} = $parent;
2344 $self->{childHash} = {};
2345 $self->{concreteFlag} = TRUE;
2346 $self->{aliveFlag} = TRUE;
2347 $self->{sentientFlag} = TRUE;
2348 $self->{portableFlag} = FALSE;
2349 $self->{saleableFlag} = FALSE;
2350 $self->{privateHash} = {};
2351  
2352 # Set group 2 IVs (but leave other IVs set to their default values)
2353 $self->{noun} = $name;
2354 # Group 3 IVs - use default values
2355 # No group 4 IVs for sentients
2356  
2357 # Set group 5 IVs
2358 # The sentient's guild, if known ('undef' if not)
2359 $self->{guild} = undef,
2360 # The sentient's race, if known ('undef' if not)
2361 $self->{race} = undef,
2362  
2363 # Flag set to TRUE if the sentient has ever said anything, FALSE if not
2364 $self->{talkativeFlag} = FALSE;
2365 # List of things the sentient has said (a list of strings)
2366 $self->{talkList} = [];
2367 # Flag set to TRUE if the sentient has ever been noticed performing an action, FALSE if not
2368 $self->{actionFlag} = FALSE;
2369 # List of text received when the sentient performs an action
2370 $self->{actionList} = [];
2371 # Flag set to TRUE if the sentient has ever initiated combat, FALSE if not
2372 $self->{unfriendlyFlag} = FALSE;
2373 # Whether the sentient is 'good', 'evil' or 'neutral' (default is neutral)
2374 $self->{morality} = 'neutral';
2375  
2376 # Flag set to TRUE if the sentient tends to wander around of its own volition, FALSE if not
2377 $self->{wanderFlag} = FALSE;
2378 # Flag set to TRUE if the sentient has ever fleed combat, FALSE if not
2379 $self->{fleeFlag} = FALSE;
2380 # Flag set to TRUE if the sentient tends to flee combat quickly, FALSE if not
2381 $self->{quickFleeFlag} = FALSE;
2382 # Flag set to TRUE if this sentient should NEVER be attacked, FALSE if not
2383 $self->{noAttackFlag} = FALSE;
2384 # Flag set to TRUE if this sentient mercies, rather than kills, its opponents; FALSE if not
2385 $self->{mercyFlag} = FALSE;
2386 # The name of the quest with which this sentient is associated ('undef' if no quest)
2387 $self->{questName} = undef;
2388  
2389 # The sentient's level (if known exactly, 0 if not)
2390 $self->{level} = 0;
2391 # If the exact level isn't known, a level for which the sentient is definitely stronger
2392 # (approximate)
2393 $self->{weakerLevel} = 0;
2394 # If the exact level isn't known, a level for which the sentient is definitely weaker
2395 # (approximate)
2396 $self->{strongerLevel} = 0;
2397  
2398 # What the sentient was carrying, last time it was seen (just a simple list of strings
2399 # - not linked to model objects)
2400 $self->{inventoryList} = [];
2401 # Every time the sentient's cash is stolen, the amount is entered into this list (until the
2402 # list contains ten entries) - from this, the average amount of cash carried by the
2403 # sentient can be generated
2404 $self->{cashList} = [];
2405  
2406 # Bless the object into existence
2407 bless $self, $class;
2408 return $self;
2409 }
2410  
2411 ##################
2412 # Methods
2413  
2414 ##################
2415 # Accessors - set
2416  
2417 ##################
2418 # Accessors - get
2419  
2420 # Group 5 IVs
2421 sub guild
2422 { $_[0]->{guild} }
2423 sub race
2424 { $_[0]->{race} }
2425  
2426 sub talkativeFlag
2427 { $_[0]->{talkativeFlag} }
2428 sub talkList
2429 { my $self = shift; return @{$self->{talkList}}; }
2430 sub actionFlag
2431 { $_[0]->{actionFlag} }
2432 sub actionList
2433 { my $self = shift; return @{$self->{actionList}}; }
2434 sub unfriendlyFlag
2435 { $_[0]->{unfriendlyFlag} }
2436 sub morality
2437 { $_[0]->{morality} }
2438  
2439 sub wanderFlag
2440 { $_[0]->{wanderFlag} }
2441 sub fleeFlag
2442 { $_[0]->{fleeFlag} }
2443 sub quickFleeFlag
2444 { $_[0]->{quickFleeFlag} }
2445 sub noAttackFlag
2446 { $_[0]->{noAttackFlag} }
2447 sub mercyFlag
2448 { $_[0]->{mercyFlag} }
2449 sub questName
2450 { $_[0]->{questName} }
2451  
2452 sub level
2453 { $_[0]->{level} }
2454 sub weakerLevel
2455 { $_[0]->{weakerLevel} }
2456 sub strongerLevel
2457 { $_[0]->{strongerLevel} }
2458  
2459 sub inventoryList
2460 { my $self = shift; return @{$self->{inventoryList}}; }
2461 sub cashList
2462 { my $self = shift; return @{$self->{cashList}}; }
2463 }
2464  
2465 { package Games::Axmud::ModelObj::Creature;
2466  
2467 use strict;
2468 use warnings;
2469 use diagnostics;
2470  
2471 use Glib qw(TRUE FALSE);
2472  
2473 our @ISA = qw(Games::Axmud::Generic::ModelObj Games::Axmud);
2474  
2475 ##################
2476 # Constructors
2477  
2478 sub new {
2479  
2480 # Prepare a new instance of the 'creature' model object (representing an NPC not capable of
2481 # language, at least in theory)
2482 #
2483 # Expected arguments
2484 # $session - The parent GA::Session (not stored as an IV)
2485 # $name - A name for the creature, e.g. 'spider' - usually the same as $self->noun
2486 # $modelFlag - TRUE if this is a model object, FALSE if it's a non-model object
2487 #
2488 # Optional arguments
2489 # $parent - World model number of the room where this object is found or the region in
2490 # which it wanders ('undef' if there is no parent object or it this is a
2491 # non-model object)
2492 #
2493 # Return values
2494 # 'undef' on improper arguments
2495 # Blessed reference to the newly-created object on success
2496  
2497 my ($class, $session, $name, $modelFlag, $parent, $check) = @_;
2498  
2499 # Local variables
2500 my ($parentFile, $parentProf);
2501  
2502 # Check for improper arguments
2503 if (
2504 ! defined $class || ! defined $session || ! defined $name || ! defined $modelFlag
2505 || defined $check
2506 ) {
2507 return $axmud::CLIENT->writeImproper($class . '->new', @_);
2508 }
2509  
2510 if ($modelFlag) {
2511  
2512 $parentFile = 'worldmodel';
2513 $parentProf = $session->currentWorld->name;
2514 }
2515  
2516 # Setup
2517 my $self = Games::Axmud::Generic::ModelObj->new($session, $name, 'creature');
2518  
2519 # Set standard IVs
2520 $self->{_objName} = $name;
2521 $self->{_objClass} = $class;
2522 $self->{_parentFile} = $parentFile; # May be 'undef'
2523 $self->{_parentWorld} = $parentProf; # May be 'undef'
2524 $self->{_privFlag} = FALSE, # All IVs are public
2525  
2526 # Set group 1 IVs
2527 $self->{parent} = $parent;
2528 $self->{childHash} = {};
2529 $self->{concreteFlag} = TRUE;
2530 $self->{aliveFlag} = TRUE;
2531 $self->{sentientFlag} = FALSE;
2532 $self->{portableFlag} = FALSE;
2533 $self->{saleableFlag} = FALSE;
2534 $self->{privateHash} = {};
2535  
2536 # Set group 2 IVs (but leave other IVs set to their default values)
2537 $self->{noun} = $name;
2538 # Group 3 IVs - use default values
2539 # No group 4 IVs for creatures
2540  
2541 # Set group 5 IVs
2542 # The creature's guild, if known ('undef' if not)
2543 $self->{guild} = undef,
2544 # The creature's race, if known ('undef' if not)
2545 $self->{race} = undef,
2546  
2547 # Flag set to TRUE if the creature has ever been noticed performing an action, FALSE if not
2548 $self->{actionFlag} = FALSE;
2549 # List of text received when the creature performs an action
2550 $self->{actionList} = [];
2551 # Flag set to TRUE if the creature has ever initiated combat, FALSE if not
2552 $self->{unfriendlyFlag} = FALSE;
2553 # Whether the creature is 'good', 'evil' or 'neutral' (default is neutral)
2554 $self->{morality} = 'neutral';
2555  
2556 # Flag set to TRUE if the creature tends to wander around of its own volition, FALSE if not
2557 $self->{wanderFlag} = FALSE;
2558 # Flag set to TRUE if the creature has ever fleed combat, FALSE if not
2559 $self->{fleeFlag} = FALSE;
2560 # Flag set to TRUE if the creature tends to flee combat quickly, FALSE if not
2561 $self->{quickFleeFlag} = FALSE;
2562 # Flag set to TRUE if this creature should NEVER be attacked, FALSE if not
2563 $self->{noAttackFlag} = FALSE;
2564 # Flag set to TRUE if this creature mercies, rather than kills, its opponents; FALSE if not
2565 $self->{mercyFlag} = FALSE;
2566 # The name of the quest with which this creature is associated ('undef' if no quest)
2567 $self->{questName} = undef;
2568  
2569 # The creature's level (if known exactly, 0 if not)
2570 $self->{level} = 0;
2571 # If the exact level isn't known, a level for which the creature is definitely stronger
2572 # (approximate)
2573 $self->{weakerLevel} = 0;
2574 # If the exact level isn't known, a level for which the creature is definitely weaker
2575 # (approximate)
2576 $self->{strongerLevel} = 0;
2577  
2578 # What the creature was carrying, last time it was seen (just a simple list of strings
2579 # - not linked to model objects)
2580 $self->{inventoryList} = [];
2581 # Every time the creature's cash is stolen, the amount is entered into this list (until the
2582 # list contains ten entries) - from this, the average amount of cash carried by the
2583 # creature can be generated
2584 $self->{cashList} = [];
2585  
2586 # Bless the object into existence
2587 bless $self, $class;
2588 return $self;
2589 }
2590  
2591 ##################
2592 # Methods
2593  
2594 ##################
2595 # Accessors - set
2596  
2597 ##################
2598 # Accessors - get
2599  
2600 # Group 5 IVs
2601 sub guild
2602 { $_[0]->{guild} }
2603 sub race
2604 { $_[0]->{race} }
2605  
2606 sub actionFlag
2607 { $_[0]->{actionFlag} }
2608 sub actionList
2609 { my $self = shift; return @{$self->{actionList}}; }
2610 sub unfriendlyFlag
2611 { $_[0]->{unfriendlyFlag} }
2612 sub morality
2613 { $_[0]->{morality} }
2614  
2615 sub wanderFlag
2616 { $_[0]->{wanderFlag} }
2617 sub fleeFlag
2618 { $_[0]->{fleeFlag} }
2619 sub quickFleeFlag
2620 { $_[0]->{quickFleeFlag} }
2621 sub noAttackFlag
2622 { $_[0]->{noAttackFlag} }
2623 sub mercyFlag
2624 { $_[0]->{mercyFlag} }
2625 sub questName
2626 { $_[0]->{questName} }
2627  
2628 sub level
2629 { $_[0]->{level} }
2630 sub weakerLevel
2631 { $_[0]->{weakerLevel} }
2632 sub strongerLevel
2633 { $_[0]->{strongerLevel} }
2634  
2635 sub inventoryList
2636 { my $self = shift; return @{$self->{inventoryList}}; }
2637 sub cashList
2638 { my $self = shift; return @{$self->{cashList}}; }
2639 }
2640  
2641 { package Games::Axmud::ModelObj::Portable;
2642  
2643 use strict;
2644 use warnings;
2645 use diagnostics;
2646  
2647 use Glib qw(TRUE FALSE);
2648  
2649 our @ISA = qw(Games::Axmud::Generic::ModelObj Games::Axmud);
2650  
2651 ##################
2652 # Constructors
2653  
2654 sub new {
2655  
2656 # Prepare a new instance of the 'portable' model object (representing any object that can be
2657 # picked up, at least in theory, and which isn't a weapon, armour or garment)
2658 #
2659 # Expected arguments
2660 # $session - The parent GA::Session (not stored as an IV)
2661 # $name - A name for the portable, e.g. 'bucket' - usually the same as $self->noun
2662 # $modelFlag - TRUE if this is a model object, FALSE if it's a non-model object
2663 #
2664 # Optional arguments
2665 # $parent - World model number of the room where this object is found, the shop from
2666 # which it can be bought or the NPC from which it is liberated ('undef'
2667 # if there is no parent object or it this is a non-model object)
2668 #
2669 # Return values
2670 # 'undef' on improper arguments
2671 # Blessed reference to the newly-created object on success
2672  
2673 my ($class, $session, $name, $modelFlag, $parent, $check) = @_;
2674  
2675 # Local variables
2676 my ($parentFile, $parentProf);
2677  
2678 # Check for improper arguments
2679 if (
2680 ! defined $class || ! defined $session || ! defined $name || ! defined $modelFlag
2681 || defined $check
2682 ) {
2683 return $axmud::CLIENT->writeImproper($class . '->new', @_);
2684 }
2685  
2686 if ($modelFlag) {
2687  
2688 $parentFile = 'worldmodel';
2689 $parentProf = $session->currentWorld->name;
2690 }
2691  
2692 # Setup
2693 my $self = Games::Axmud::Generic::ModelObj->new($session, $name, 'portable');
2694  
2695 # Set standard IVs
2696 $self->{_objName} = $name;
2697 $self->{_objClass} = $class;
2698 $self->{_parentFile} = $parentFile; # May be 'undef'
2699 $self->{_parentWorld} = $parentProf; # May be 'undef'
2700 $self->{_privFlag} = FALSE, # All IVs are public
2701  
2702 # Set group 1 IVs
2703 $self->{parent} = $parent;
2704 $self->{childHash} = {};
2705 $self->{concreteFlag} = TRUE;
2706 $self->{aliveFlag} = FALSE;
2707 $self->{sentientFlag} = FALSE;
2708 $self->{portableFlag} = TRUE;
2709 $self->{saleableFlag} = TRUE;
2710 $self->{privateHash} = {};
2711  
2712 # Set group 2 IVs (but leave other IVs set to their default values)
2713 $self->{noun} = $name;
2714 # No group 3 IVs for portables
2715 # Set group 4 IVs (but leave other IVs set to their default values)
2716 $self->{explicitFlag} = TRUE;
2717 $self->{fixableFlag} = FALSE;
2718 $self->{sellableFlag} = TRUE;
2719  
2720 # Set group 5 IVs
2721 # The object's type (matches a portable type in the dictionary object)
2722 $self->{type} = 'other';
2723  
2724 # Bless the object into existence
2725 bless $self, $class;
2726 return $self;
2727 }
2728  
2729 ##################
2730 # Methods
2731  
2732 ##################
2733 # Accessors - set
2734  
2735 ##################
2736 # Accessors - get
2737  
2738 # Group 5 IVs
2739 sub type
2740 { $_[0]->{type} }
2741 }
2742  
2743 { package Games::Axmud::ModelObj::Decoration;
2744  
2745 use strict;
2746 use warnings;
2747 use diagnostics;
2748  
2749 use Glib qw(TRUE FALSE);
2750  
2751 our @ISA = qw(Games::Axmud::Generic::ModelObj Games::Axmud);
2752  
2753 ##################
2754 # Constructors
2755  
2756 sub new {
2757  
2758 # Prepare a new instance of the 'decoration' model object (representing any object that
2759 # can't be picked up, at least in theory, but which can be interacted with)
2760 #
2761 # Expected arguments
2762 # $session - The parent GA::Session (not stored as an IV)
2763 # $name - A name for the decoration, e.g. 'curtain' - usually the same as
2764 # $self->noun
2765 # $modelFlag - TRUE if this is a model object, FALSE if it's a non-model object
2766 #
2767 # Optional arguments
2768 # $parent - World model number of the room where this object is found ('undef' if
2769 # there is no parent object or it this is a non-model object)
2770 #
2771 # Return values
2772 # 'undef' on improper arguments
2773 # Blessed reference to the newly-created object on success
2774  
2775 my ($class, $session, $name, $modelFlag, $parent, $check) = @_;
2776  
2777 # Local variables
2778 my ($parentFile, $parentProf);
2779  
2780 # Check for improper arguments
2781 if (
2782 ! defined $class || ! defined $session || ! defined $name || ! defined $modelFlag
2783 || defined $check
2784 ) {
2785 return $axmud::CLIENT->writeImproper($class . '->new', @_);
2786 }
2787  
2788 if ($modelFlag) {
2789  
2790 $parentFile = 'worldmodel';
2791 $parentProf = $session->currentWorld->name;
2792 }
2793  
2794 # Setup
2795 my $self = Games::Axmud::Generic::ModelObj->new($session, $name, 'decoration');
2796  
2797 # Set standard IVs
2798 $self->{_objName} = $name;
2799 $self->{_objClass} = $class;
2800 $self->{_parentFile} = $parentFile; # May be 'undef'
2801 $self->{_parentWorld} = $parentProf; # May be 'undef'
2802 $self->{_privFlag} = FALSE, # All IVs are public
2803  
2804 # Set group 1 IVs
2805 $self->{parent} = $parent;
2806 $self->{childHash} = {};
2807 $self->{concreteFlag} = TRUE;
2808 $self->{aliveFlag} = FALSE;
2809 $self->{sentientFlag} = FALSE;
2810 $self->{portableFlag} = FALSE;
2811 $self->{saleableFlag} = FALSE;
2812 $self->{privateHash} = {};
2813  
2814 # Set group 2 IVs (but leave other IVs set to their default values)
2815 $self->{noun} = $name;
2816 # No group 3 IVs for decorations
2817 # Set group 4 IVs (but leave other IVs set to their default values)
2818 $self->{explicitFlag} = FALSE;
2819 $self->{fixableFlag} = FALSE;
2820 $self->{sellableFlag} = FALSE;
2821  
2822 # Set group 5 IVs
2823 # The object's type (matches a decoration type in the dictionary object)
2824 $self->{type} = 'other';
2825  
2826 # Bless the object into existence
2827 bless $self, $class;
2828 return $self;
2829 }
2830  
2831 ##################
2832 # Methods
2833  
2834 ##################
2835 # Accessors - set
2836  
2837 ##################
2838 # Accessors - get
2839  
2840 # Group 5 IVs
2841 sub type
2842 { $_[0]->{type} }
2843 }
2844  
2845 { package Games::Axmud::ModelObj::Custom;
2846  
2847 use strict;
2848 use warnings;
2849 use diagnostics;
2850  
2851 use Glib qw(TRUE FALSE);
2852  
2853 our @ISA = qw(Games::Axmud::Generic::ModelObj Games::Axmud);
2854  
2855 ##################
2856 # Constructors
2857  
2858 sub new {
2859  
2860 # Prepare a new instance of the 'custom' model object (which can represent any concept)
2861 #
2862 # Expected arguments
2863 # $session - The parent GA::Session (not stored as an IV)
2864 # $name - A name for the custom object, e.g. 'big_idea'
2865 # $modelFlag - TRUE if this is a model object, FALSE if it's a non-model object
2866 #
2867 # Optional arguments
2868 # $parent - World model number of the parent object ('undef' if there is no parent
2869 # object or it this is a non-model object)
2870 #
2871 # Return values
2872 # 'undef' on improper arguments
2873 # Blessed reference to the newly-created object on success
2874  
2875 my ($class, $session, $name, $modelFlag, $parent, $check) = @_;
2876  
2877 # Local variables
2878 my ($parentFile, $parentProf);
2879  
2880 # Check for improper arguments
2881 if (
2882 ! defined $class || ! defined $session || ! defined $name || ! defined $modelFlag
2883 || defined $check
2884 ) {
2885 return $axmud::CLIENT->writeImproper($class . '->new', @_);
2886 }
2887  
2888 if ($modelFlag) {
2889  
2890 $parentFile = 'worldmodel';
2891 $parentProf = $session->currentWorld->name;
2892 }
2893  
2894 # Setup
2895 my $self = Games::Axmud::Generic::ModelObj->new($session, $name, 'custom');
2896  
2897 # Set standard IVs
2898 $self->{_objName} = $name;
2899 $self->{_objClass} = $class;
2900 $self->{_parentFile} = $parentFile; # May be 'undef'
2901 $self->{_parentWorld} = $parentProf; # May be 'undef'
2902 $self->{_privFlag} = FALSE, # All IVs are public
2903  
2904 # Set group 1 IVs (most should be set separately for each instance of this object)
2905 $self->{parent} = $parent;
2906 $self->{childHash} = {};
2907 # $self->{concreteFlag} = FALSE;
2908 # $self->{aliveFlag} = FALSE;
2909 # $self->{sentientFlag} = FALSE;
2910 # $self->{portableFlag} = FALSE;
2911 # $self->{saleableFlag} = FALSE;
2912 # $self->{privateHash} = {};
2913  
2914 # Group 2 IVs - use default values
2915 # No group 3 IVs for custom model objects
2916 # Group 4 IVs - use default values
2917 # No group 5 IVs for custom model objects
2918  
2919 # Bless the object into existence
2920 bless $self, $class;
2921 return $self;
2922 }
2923  
2924 ##################
2925 # Methods
2926  
2927 ##################
2928 # Accessors - set
2929  
2930 ##################
2931 # Accessors - get
2932  
2933 # Group 5 IVs (none for this object)
2934 }
2935  
2936 # Package must return a true value
2937 1