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