| 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::Profile::XXX | ||
| 16 | # The code that handles a profile | ||
| 17 | |||
| 18 | { package Games::Axmud::Profile::World; | ||
| 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::Profile Games::Axmud); | ||
| 27 | |||
| 28 | ################## | ||
| 29 | # Constructors | ||
| 30 | |||
| 31 | sub new { | ||
| 32 | |||
| 33 | # Called by any function | ||
| 34 | # Creates a new instance of the world profile | ||
| 35 | # | ||
| 36 | # Expected arguments | ||
| 37 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 38 | # $name - A unique string name for this profile (max 16 chars, containing | ||
| 39 | # A-Za-z0-9_ - 1st char can't be number, non-Latin alphabets acceptable. | ||
| 40 | # Must not exist as a key in the global hash of reserved names, | ||
| 41 | # $axmud::CLIENT->constReservedHash) | ||
| 42 | # | ||
| 43 | # Optional arguments | ||
| 44 | # $tempFlag - If set to TRUE, this is a temporary profile created for use with an 'edit' | ||
| 45 | # window; $name is not checked for validity. Otherwise set to FALSE (or | ||
| 46 | # 'undef') | ||
| 47 | # | ||
| 48 | # Return values | ||
| 49 | # 'undef' on improper arguments or if $name is invalid | ||
| 50 | # Blessed reference to the newly-created object on success | ||
| 51 | |||
| 52 | my ($class, $session, $name, $tempFlag, $check) = @_; | ||
| 53 | |||
| 54 | # Check for improper arguments | ||
| 55 | if (! defined $class || ! defined $session || ! defined $name || defined $check) { | ||
| 56 | |||
| 57 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 58 | } | ||
| 59 | |||
| 60 | if (! $tempFlag) { | ||
| 61 | |||
| 62 | # Check that $name is valid and not already in use by another profile | ||
| 63 | if (! $axmud::CLIENT->nameCheck($name, 16)) { | ||
| 64 | |||
| 65 | return $axmud::CLIENT->writeError( | ||
| 66 | 'Registry naming error: invalid name \'' . $name . '\'', | ||
| 67 | $class . '->new', | ||
| 68 | ); | ||
| 69 | |||
| 70 | } elsif ($axmud::CLIENT->ivExists('worldProfHash', $name)) { | ||
| 71 | |||
| 72 | return $axmud::CLIENT->writeError( | ||
| 73 | 'Registry naming error: profile \'' . $name . '\' already exists', | ||
| 74 | $class . '->new', | ||
| 75 | ); | ||
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 79 | # Setup | ||
| 80 | my $self = { | ||
| 81 | _objName => $name, | ||
| 82 | _objClass => $class, | ||
| 83 | _parentFile => $name, | ||
| 84 | _parentWorld => undef, | ||
| 85 | _privFlag => FALSE, # All IVs are public | ||
| 86 | |||
| 87 | # Standard profile IVs | ||
| 88 | # -------------------- | ||
| 89 | |||
| 90 | name => $name, | ||
| 91 | category => 'world', | ||
| 92 | # The name of associated world profile (world profiles don't have a parent world) | ||
| 93 | parentWorld => undef, | ||
| 94 | |||
| 95 | # Hash of tasks that start whenever this profile is made a current profile (as soon as | ||
| 96 | # the character is marked as 'logged in') - the profile's initial tasklist. Hash in | ||
| 97 | # the form | ||
| 98 | # $initTaskHash{unique_task_name} = blessed_reference_to_task_object | ||
| 99 | initTaskHash => {}, | ||
| 100 | # The order in which the tasks are started (not very important for tasks unless they | ||
| 101 | # are Script tasks). List contains all the keys in $self->initTaskHash | ||
| 102 | initTaskOrderList => [], | ||
| 103 | # How many initial tasks have been created, in total (used to give each one a unique | ||
| 104 | # name). Reset to 0 when the profile's initial tasklist is emptied | ||
| 105 | initTaskTotal => 0, | ||
| 106 | # Hash of scripts that start whenever this definiton is made a current profile (as soon | ||
| 107 | # as the character is marked as 'logged in') - the profile's initial scriptlist. Hash | ||
| 108 | # in the form | ||
| 109 | # $initScriptHash{script_name} = mode | ||
| 110 | # ...where 'script_name' matches the file from which the script is loaded, and 'mode' is | ||
| 111 | # set to one of the following value: | ||
| 112 | # 'no_task' - run the script without a task | ||
| 113 | # 'run_task' - run the script from within a task | ||
| 114 | # 'run_task_win' - run the script from within a task, in 'forced window' mode | ||
| 115 | initScriptHash => {}, | ||
| 116 | # The order in which the scripts are started. List contains all the keys in | ||
| 117 | # $self->initScriptHash | ||
| 118 | initScriptOrderList => [], | ||
| 119 | # The name of the mission to start whenever a new session begins with this as a current | ||
| 120 | # profile, as soon as the character is marked as logged in - but NOT when a current | ||
| 121 | # profile is set after the login | ||
| 122 | # Profiles are checked in priority order; only the first mission found is run. Set to | ||
| 123 | # the name of the mission, or 'undef' | ||
| 124 | initMission => undef, | ||
| 125 | # A list of commands to execute, as if the user had typed them in the 'main' window's | ||
| 126 | # command entry box, whenever a new session begins with this as a current profile, | ||
| 127 | # as soon as the character is marked as logged in - but NOT when a current profile | ||
| 128 | # is set after the login | ||
| 129 | # Profiles are checked in priority order; commands are sent from all profiles, but | ||
| 130 | # duplicate commands are not sent | ||
| 131 | # Commands are sent AFTER the commands specified by the current world profile's | ||
| 132 | # ->columns, ->rows and ->sendSizeInfoFlag IVs (so this list doesn't need to include | ||
| 133 | # them) | ||
| 134 | initCmdList => [], | ||
| 135 | |||
| 136 | # Flag set to TRUE if this profile has EVER been a current profile (in which case, it | ||
| 137 | # will have cages etc); set to FALSE if not (in which case, the parent file object | ||
| 138 | # will set up cages etc when this profile first becomes a current profile) | ||
| 139 | # NB The flag will be TRUE for all pre-configured worlds, as the code that creates them | ||
| 140 | # also creates cages for each world | ||
| 141 | # NB Will also be TRUE for a cloned world, if the original's value was TRUE. Although | ||
| 142 | # the clone has never been a current world, it does have cages etc) | ||
| 143 | setupCompleteFlag => FALSE, | ||
| 144 | # List containing notes written by this user for this profile, and available to the | ||
| 145 | # Notepad task when it's running | ||
| 146 | notepadList => [], | ||
| 147 | # A hash to store any data your own plugins/scripts want to store (when a profile is | ||
| 148 | # cloned, this data is not copied to the clone) | ||
| 149 | privateHash => {}, | ||
| 150 | |||
| 151 | # World profile IVs | ||
| 152 | # ----------------- | ||
| 153 | |||
| 154 | # A flag set to TRUE if this profile's 'worldprof' file, and its associated 'otherprof' | ||
| 155 | # and 'worldmodel' files, should not be saved (set to FALSE otherwise) | ||
| 156 | # Used when the Connections window starts a new session for which the user hasn't | ||
| 157 | # specified a world name; setting this flag to TRUE effectively makes the profile | ||
| 158 | # temporary | ||
| 159 | noSaveFlag => FALSE, | ||
| 160 | # A list of GA::Obj::ConnectHistory objects, storing details about every connection to | ||
| 161 | # this world (but only when GA::Client->connectHistoryFlag is TRUE). The first object | ||
| 162 | # in the list is for the earliest connection, the last object, the most recent (or | ||
| 163 | # current) connection | ||
| 164 | connectHistoryList => [], | ||
| 165 | |||
| 166 | # A hash of key-value pairs that can be be set for any world which, for one reason or | ||
| 167 | # another, must not use certain telnet options/protocols | ||
| 168 | # The key is a string representing a telnet option or protocol (e.g. 'naws' or 'mxp'). | ||
| 169 | # It matches an argument recognised by GA::Client->toggle_telnetOption or | ||
| 170 | # GA::Client->toggle_mudProtocol. The corresponding value is always 'undef' | ||
| 171 | # If the key exists in the hash, the session won't use that option/protocol, regardless | ||
| 172 | # of the value of the corresponding GA::Client IVs (->useNawsFlag and ->useMxpFlag, in | ||
| 173 | # the examples above) | ||
| 174 | # NB This hash is only consulted by code in GA::Session. All other Axmud code uses the | ||
| 175 | # original GA::Client IVs | ||
| 176 | telnetOverrideHash => { | ||
| 177 | # # Telnet options | ||
| 178 | # 'echo' => undef, # GA::Client->useEchoFlag | ||
| 179 | # 'sga' => undef, # GA::Client->useSgaFlag | ||
| 180 | # 'ttype' => undef, # GA::Client->useTTypeFlag | ||
| 181 | # 'eor' => undef, # GA::Client->useEorFlag | ||
| 182 | # 'naws' => undef, # GA::Client->useNawsFlag | ||
| 183 | # 'new_environ' => undef, # GA::Client->useNewEnvironFlag | ||
| 184 | # 'charset' => undef, # GA::Client->useCharSetFlag | ||
| 185 | # # Telnet protocols | ||
| 186 | # 'msdp' => undef, # GA::Client->useMsdpFlag | ||
| 187 | # 'mssp' => undef, # GA::Client->useMsspFlag | ||
| 188 | # 'mccp' => undef, # GA::Client->useMccpFlag | ||
| 189 | # 'msp' => undef, # GA::Client->useMspFlag | ||
| 190 | # 'mxp' => undef, # GA::Client->useMxpFlag | ||
| 191 | # 'pueblo' => undef, # GA::Client->usePuebloFlag | ||
| 192 | # 'zmp' => undef, # GA::Client->useZmpFlag | ||
| 193 | # 'aard102' => undef, # GA::Client->useAard102Flag | ||
| 194 | # 'atcp' => undef, # GA::Client->useAtcpFlag | ||
| 195 | # 'gmcp' => undef, # GA::Client->useGmcpFlag | ||
| 196 | # 'mtts' => undef, # GA::Client->useMttsFlag | ||
| 197 | # 'mnes' => undef, # GA::Client->useMnesFlag | ||
| 198 | # 'mcp' => undef, # GA::Client->useMcpFlag | ||
| 199 | }, | ||
| 200 | # A hash which overrides the values of certain GA::Client flags related to MXP | ||
| 201 | # permissions | ||
| 202 | # The key is a string representing a permission (e.g. 'room'). It matches an | ||
| 203 | # argument recognised by GA::Client->set_allowMxpFlag | ||
| 204 | # If the key doesn't exist in the hash, the session uses the value of the GA::Client IV. | ||
| 205 | # If the key exists in the hash, the session uses the key's corresponding value | ||
| 206 | # instead. The corresponding value should be TRUE or FALSE | ||
| 207 | # NB This hash is only consulted by code in GA::Session (the 'room' key is consulted by | ||
| 208 | # code in the Locator task). All other Axmud code uses the original GA::Client IVs | ||
| 209 | mxpOverrideHash => { | ||
| 210 | # 'room' => TRUE, # GA::Client->allowMxpRoomFlag | ||
| 211 | # 'flexible' => TRUE, # GA::Client->allowMxpFlexibleFlag | ||
| 212 | # 'perm' => TRUE, # GA::Client->allowMxpPermFlag | ||
| 213 | }, | ||
| 214 | # A hash which overrides the values of GA::Client->termTypeMode, ->customClientName, | ||
| 215 | # ->customClientVersion, ->useCtrlSeqFlag, ->useVisibleCursorFlag and | ||
| 216 | # ->useDirectKeysFlag | ||
| 217 | # The key has the same name as the GA::Client IV. If the key doesn't exist in the hash, | ||
| 218 | # the session uses the value of the GA::Client IV. If the key exists in the hash, the | ||
| 219 | # session uses the key's corresponding value instead. The corresponding value should | ||
| 220 | # match one of the acceptable values of the GA::Client IV | ||
| 221 | # NB This hash is only consulted by code in GA::Session. All other Axmud code uses the | ||
| 222 | # original GA::Client IVs | ||
| 223 | termOverrideHash => { | ||
| 224 | # 'termTypeMode' => 'send_client', # GA::Client->termTypeMode | ||
| 225 | # 'customClientName' => '', # GA::Client->customClientName | ||
| 226 | # 'customClientVersion' => '', # GA::Client->customClientVersion | ||
| 227 | # 'useCtrlSeqFlag' => TRUE, # GA::Client->useCtrlSeqFlag | ||
| 228 | # 'useVisibleCursorFlag' => FALSE, # GA::Client->useVisibleCursorFlag | ||
| 229 | # 'useDirectKeysFlag' => FALSE, # GA::Client->useDirectKeysFlag | ||
| 230 | }, | ||
| 231 | # A hash which overrides the values of GA::Client->echoSigilFlag, ->perlSigilFlag, | ||
| 232 | # ->scriptSigilFlag and ->multiSigilFlag | ||
| 233 | # The key is one of the strings 'echo', 'perl', 'script', 'multi' or 'bypass'. If the | ||
| 234 | # key doesn't exist in the hash, the session uses the value of the GA::Client IV. If | ||
| 235 | # the key exists in the hash, the session uses the key's corresponding value instead. | ||
| 236 | # The corresponding value should be TRUE or FALSE | ||
| 237 | # NB This hash is only consulted by code in GA::Session. All other Axmud code uses the | ||
| 238 | # original GA::Client IVs | ||
| 239 | sigilOverrideHash => { | ||
| 240 | # 'echo' => TRUE, # GA::Client->echoSigilFlag | ||
| 241 | # 'perl' => TRUE, # GA::Client->perlSigilFlag | ||
| 242 | # 'script' => TRUE, # GA::Client->scriptSigilFlag | ||
| 243 | # 'multi' => TRUE, # GA::Client->multiSigilFlag | ||
| 244 | # 'speed' => TRUE, # GA::Client->speedSigilFlag | ||
| 245 | # 'bypass' => TRUE, # GA::Client->bypassSigilFlag | ||
| 246 | }, | ||
| 247 | |||
| 248 | # A hash containing all the profiles associated with this world, in the form | ||
| 249 | # $profHash{profile_name} = profile_category | ||
| 250 | # NB Includes an entry for this world profile, i.e. | ||
| 251 | # $profHash{this_profile_name} = 'world' | ||
| 252 | profHash => { | ||
| 253 | $name => 'world', | ||
| 254 | }, | ||
| 255 | # A hash containing characters and their passwords (if known), in the form | ||
| 256 | # $passwordHash{char_profile_name} = password | ||
| 257 | # $passwordHash{char_profile_name} = 'undef' (if password not known) | ||
| 258 | passwordHash => {}, | ||
| 259 | # The Connections window enables the user to add new characters to the profile, and to | ||
| 260 | # edit the password of existing characters. In both cases, a new entry is made to this | ||
| 261 | # hash; when the profile next becomes a current profile, GA::Session->setupProfiles | ||
| 262 | # creates the characters and/or updates passwords. Hash in the form | ||
| 263 | # $newPasswordHash{char_profile_name} = password | ||
| 264 | # $newPasswordHash{char_profile_name} = 'undef' (if password not known) | ||
| 265 | newPasswordHash => {}, | ||
| 266 | # For worlds that have separate account/character names, a hash of matching account and | ||
| 267 | # character names, in the form | ||
| 268 | # $accountHash{char_profile_name} = account_name | ||
| 269 | # $accountHash{char_profile_name} = 'undef' (if no separate account name) | ||
| 270 | accountHash => {}, | ||
| 271 | # Connections window enables user to set the account name in the same way. Hash in the | ||
| 272 | # form | ||
| 273 | # $newAccountHash{char_profile_name} = account_name | ||
| 274 | # $newAccountHash{char_profile_name} = 'undef' (if no separate account name) | ||
| 275 | newAccountHash => {}, | ||
| 276 | |||
| 277 | # The connection protocol to use: 'telnet', 'ssh' or 'ssl' | ||
| 278 | protocol => 'telnet', | ||
| 279 | |||
| 280 | # Connection details. If specified, ->ipv6 is used. Otherwise if specified, ->ipv4 is | ||
| 281 | # used. Otherwise, ->dns is used. If none are specified, '127.0.0.1' is used | ||
| 282 | dns => undef, | ||
| 283 | ipv4 => undef, | ||
| 284 | ipv6 => undef, | ||
| 285 | port => 23, | ||
| 286 | # SSH connection details (if the username is not set, the GA::Session prompts the user | ||
| 287 | # for a password on every connection, and if the user doesn't provide one, reverts to | ||
| 288 | # a telnet connection) | ||
| 289 | sshUserName => undef, | ||
| 290 | sshPassword => undef, | ||
| 291 | # Flag set to TRUE if $self->port should be specified in the SSH connection; FALSE if it | ||
| 292 | # should be omitted | ||
| 293 | sshPortFlag => FALSE, | ||
| 294 | |||
| 295 | # Previous connection details | ||
| 296 | lastConnectDate => undef, | ||
| 297 | lastConnectTime => undef, | ||
| 298 | numberConnects => 0, | ||
| 299 | lastConnectChar => undef, | ||
| 300 | |||
| 301 | # The world's long name (if any; suggested max length of 32) | ||
| 302 | longName => undef, | ||
| 303 | # Flag set to TRUE if the world contains overt adult (sexual) themes, FALSE if not. | ||
| 304 | # This IV doesn't appear in the profile's edit window, so is usually only TRUE if the | ||
| 305 | # pre-configured world (or basic mudlist) specifies it | ||
| 306 | adultFlag => FALSE, | ||
| 307 | # URL of the world's own website ('undef' if unknown) | ||
| 308 | worldURL => undef, | ||
| 309 | # URL of the world's entry on a referrer website (can be any, but www.mudstats.com is | ||
| 310 | # used by default; 'undef' if unknown) | ||
| 311 | referURL => undef, | ||
| 312 | # Short description of the world (use newline characters, if required; 'undef' if no | ||
| 313 | # description known) | ||
| 314 | worldDescrip => undef, | ||
| 315 | # Short hint message for this world, shown on first connection and again if the user | ||
| 316 | # types the ';hint' command. Typically used to warn users about which world commands | ||
| 317 | # must be sent, before the automapper can work, etc etc. Newline characters are not | ||
| 318 | # required. Set to 'undef' if no hint is needed | ||
| 319 | worldHint => undef, | ||
| 320 | # Which character set to use with this world. If set, should be one of the characters | ||
| 321 | # sets provided by Perl's Encode module (and stored in GA::Client->charSetList); if | ||
| 322 | # set to 'undef', GA::Client->charSet is used as the character set | ||
| 323 | worldCharSet => undef, | ||
| 324 | |||
| 325 | # The terminal type to use for this world. If set, it is sent to the world when the | ||
| 326 | # server requests a terminal type. If an empty string (or 'undef'), Axmud decides | ||
| 327 | # which terminal type to send, based on the GA::Client->termTypeMode, | ||
| 328 | # ->customClientName and ->customClientVersion | ||
| 329 | termType => undef, | ||
| 330 | # The terminal size to use for this world ('undef' if not set) | ||
| 331 | columns => 0, # e.g. 100 | ||
| 332 | rows => 0, # e.g. 50 | ||
| 333 | # If the flag is TRUE, ->termType, ->columns and ->rows are sent to the world manually | ||
| 334 | # (and NAWS is not used in this session) after logging in. If set to FALSE, they | ||
| 335 | # aren't sent, and NAWS can be used (if the GA::Client flag allows it) | ||
| 336 | sendSizeInfoFlag => FALSE, | ||
| 337 | |||
| 338 | # MSSP data collected from this world (if any, containing only generic variables). Hash | ||
| 339 | # in the form | ||
| 340 | # $msspGenericValueHash{variable} = value | ||
| 341 | msspGenericValueHash => {}, | ||
| 342 | # MSSP data collected from this world (if any, containing only custom variables) | ||
| 343 | msspCustomValueHash => {}, | ||
| 344 | |||
| 345 | # Automatic login mode. Axmud needs to know when the character has logged in; the | ||
| 346 | # GA::Session->loginFlag is set to TRUE at this point | ||
| 347 | # Axmud can perform an automatic login, if allowed. The following IV specifies which | ||
| 348 | # kind of login to perform when this world profile is the current world profile. The | ||
| 349 | # mode can be any of the following values: | ||
| 350 | # 'none' - No automatic login (user must use the ;lgn command) | ||
| 351 | # 'immediate' - Immediate login (character marked as 'logged in' immediately - not | ||
| 352 | # recommended, as tasks like the Locator task will start looking for room | ||
| 353 | # statements in the world's introductory text) | ||
| 354 | # 'lp' - LP/Diku/AberMUD login (consecutive prompts for character/password) | ||
| 355 | # 'tiny' - TinyMUD login (send 'connect char pass' after a line of text containing | ||
| 356 | # the word 'connect' is received. Actually, the current command cage's | ||
| 357 | # 'connect' command is used, so the actual command sent might be different) | ||
| 358 | # 'world_cmd' - Send a sequence of world commands at the first prompt. Any command | ||
| 359 | # which contains '@name@' is substituted for the character's name, any command | ||
| 360 | # which contains '@account@' is substituted for the account name, and any | ||
| 361 | # command which contains '@password@' is substituted for the character's | ||
| 362 | # password (if not set, removed altogether). Any of them that are not set are | ||
| 363 | # substituted for an empty string. NB If $self->loginConnectPatternList is | ||
| 364 | # set, we wait for one of those patterns, rather than waiting for the first | ||
| 365 | # prompt | ||
| 366 | # 'telnet' - Basic telnet login (e.g. 'login:' 'password:') | ||
| 367 | # 'task' - Run a task (character is logged if the task calls GA::Session->doLogin) | ||
| 368 | # 'script_task' - Run an Axbasic script from within a task (character is logged in | ||
| 369 | # if the script executes a LOGIN statement) | ||
| 370 | # 'script' - Run an Axbasic script (character is logged in if the script executes | ||
| 371 | # a LOGIN statement) | ||
| 372 | # 'mission' - Start a mission (character is logged in if the mission uses the | ||
| 373 | # ';login' client command) | ||
| 374 | loginMode => 'none', | ||
| 375 | # For login mode 'world_cmd', the sequence of world commands to send. Commands | ||
| 376 | # containing '@name@', '@account@' and '@password@' are substituted | ||
| 377 | loginCmdList => [], | ||
| 378 | # For login modes 'task', 'script_task', 'script', 'mission', the name of the task | ||
| 379 | # (formal name or task label), script or mission to start | ||
| 380 | loginObjName => undef, | ||
| 381 | # For login mode 'tiny', a list of patterns matching the line which mean we should send | ||
| 382 | # the connect command | ||
| 383 | # For login mode 'world_cmd', a list of patterns matching the line which mean we should | ||
| 384 | # send the list of (substituted) world commands. If this list is empty, we wait for | ||
| 385 | # the first prompt before sending them, instead | ||
| 386 | loginConnectPatternList => [ | ||
| 387 | 'connect', | ||
| 388 | ], | ||
| 389 | # Login success pattern list - used in login modes 'lp', 'tiny', 'world_cmd', 'telnet' | ||
| 390 | # and 'mission' | ||
| 391 | # In modes 'lp', 'tiny', 'world_cmd' and 'telnet', if the list is empty, the automatic | ||
| 392 | # login is completed as soon as a response to the world's prompt(s) has been sent | ||
| 393 | # In mode 'mission', the automatic login is normally completed when the mission | ||
| 394 | # finishes, but is completed early if a line matching one of these patterns is | ||
| 395 | # received | ||
| 396 | loginSuccessPatternList => [], | ||
| 397 | # Login account mode - whether an account name is needed to login to this world, as well | ||
| 398 | # as the usual character name/password. The setting of this IV affects text displayed | ||
| 399 | # in the Connections window, so its value doesn't really matter. Specifically, it does | ||
| 400 | # not affect the automatic login process (using the IVs just above) at all | ||
| 401 | # 'unknown' - not known if user must login with an account name, 'not_required' - | ||
| 402 | # account name not required, 'required' - account name required | ||
| 403 | loginAccountMode => 'unknown', | ||
| 404 | # Some worlds force the user to type a character from a list; often the user must type | ||
| 405 | # 1 for the first listed character, 2 for the second one, and so on | ||
| 406 | # A collection of patterns to take care of this situation. A list in groups of three; | ||
| 407 | # the first item is a pattern which should match the line containing the character's | ||
| 408 | # name and usually uses one or more group substrings. The second item is the number of | ||
| 409 | # the group substring containing the character name (can be set if multiple character | ||
| 410 | # names appear on the same line; set to 0 if only one character name appears per | ||
| 411 | # matching line). The third item is the command to send to the world, and should | ||
| 412 | # usually contain a group substring variable like $1 | ||
| 413 | # | ||
| 414 | # e.g. Choose a character | ||
| 415 | # 1. Gandalf | ||
| 416 | # 2. Bilbo | ||
| 417 | # | ||
| 418 | # In this case, the pattern to use would be '(\d)\.\s(.*)' | ||
| 419 | # Characters appear on their own line, so we can use the group substring number 0 | ||
| 420 | # The corresponding world command to use would be simply '$1' - above, the | ||
| 421 | # number 1 or 2 | ||
| 422 | # | ||
| 423 | # e.g. 1. Gandalf 2. Bilbo | ||
| 424 | # | ||
| 425 | # In this case, the pattern to use might be '(\d)\.\s(.*)\s(\d)\.\s(.*)', | ||
| 426 | # the group substring number would be 1, and the world command would be '$1' | ||
| 427 | # We'd then add a second identical pattern to the list, together with the | ||
| 428 | # group substring number 2 and the world command '$2' | ||
| 429 | # | ||
| 430 | # If this list is empty, it is ignored. If $self->loginMode is not 'mission', it is | ||
| 431 | # ignored | ||
| 432 | # If this list is set, GA::Session checks every incoming line of text (complete, or not) | ||
| 433 | # for patterns that match the current character's name (case-insensitively). If there | ||
| 434 | # are any lines that match the name and also match one of the patterns in the list | ||
| 435 | # (case-insensitively), the corresponding world command is sent, and the GA::Session | ||
| 436 | # stops checking incoming lines. If a login takes place for any reason (via a call to | ||
| 437 | # GA::Session->doLogin), the GA::Session stops checking incoming lines | ||
| 438 | # This IV is used with a login mission ($self->loginMode is 'mission', and | ||
| 439 | # $self->loginObjName is set to the name of the GA::Obj::Mission). Typically, the | ||
| 440 | # contents of the mission should look like this: | ||
| 441 | # 't Your account', (Wait for this prompt) | ||
| 442 | # 'a', (Send account name) | ||
| 443 | # 't Password', (Wait for this prompt) | ||
| 444 | # 'w', (Send password) | ||
| 445 | # ... we now wait for GA::Session to choose a character... | ||
| 446 | # 't Welcome back to DeathMud', (This line seen after the character is chosen) | ||
| 447 | # ';login', (Mark the character as logged in) | ||
| 448 | # List (groups of 3) | ||
| 449 | # 0 - the pattern matching a line containing the character's name (because a | ||
| 450 | # perl substitution will be performed, it must match the whole line - begin | ||
| 451 | # and/or end the pattern with '.*' if necessary | ||
| 452 | # 1- the number of the group substring that contains the character's name; can be set | ||
| 453 | # to 0 if only one character name appears per line | ||
| 454 | # 2 - the world command to send, usually including a group substring variable, e.g. $1 | ||
| 455 | loginSpecialList => [], | ||
| 456 | |||
| 457 | # Automatic quit mode. Users can disconnect from many worlds by sending some kind of | ||
| 458 | # 'quit' world command, but at other worlds, it's not so simple. These IVs are used | ||
| 459 | # only when the user types ';quit', ';qquit' or ';quitall'. They are ignored if the | ||
| 460 | # user simply types some kind of 'quit' world command, or if a connection to a world | ||
| 461 | # is terminated remotely. | ||
| 462 | # 'normal' - Send the standard 'quit' world command, as defined by the current | ||
| 463 | # highest-priority command cage | ||
| 464 | # 'world_cmd' - Send a sequence of world commands | ||
| 465 | # 'task' - Run a task (the task is responsible for sending a 'quit' world command) | ||
| 466 | # 'task_script' - Run an Axbasic script from within a task (the script is | ||
| 467 | # responsible for sending a 'quit' world command) | ||
| 468 | # 'script' - Run an Axbasic script (the script is responsible for sending a 'quit' | ||
| 469 | # world command) | ||
| 470 | # 'mission' - Start a mission (the mission is responsible for sending a 'quit' | ||
| 471 | # world command) | ||
| 472 | autoQuitMode => 'normal', | ||
| 473 | # For quit mode 'world_cmd', the sequence of commands to send. (Unlike | ||
| 474 | # $self->loginCmdList, no substitutions take place.) If the list is empty, Axmud | ||
| 475 | # reverts to quit mode 'normal' | ||
| 476 | autoQuitCmdList => [], | ||
| 477 | # For quit modes 'task', 'task_script', 'script' and 'mission', the name of the task | ||
| 478 | # (formal name or task label), script or mission to start. If an empty string or | ||
| 479 | # 'undef', Axmud reverts to quit mode 'normal' | ||
| 480 | autoQuitObjName => undef, | ||
| 481 | |||
| 482 | # If set to FALSE, the world can be sent a string containing multiple commands | ||
| 483 | # (separated by command separators, e.g. 'n;n;w') | ||
| 484 | # If set to TRUE, Axmud must send each command separately | ||
| 485 | autoSeparateCmdFlag => TRUE, | ||
| 486 | # Slowwalking IVs (implemented by GA::Session as 'excess commands') | ||
| 487 | # Some worlds enforce a maximum number of commands per second (or maximum number of | ||
| 488 | # commands per fraction of a second) | ||
| 489 | # If this variable is set, commands are counted as they are sent. When the maximum is | ||
| 490 | # reached, further commands are stored temporarily. If this value is set to 0, no | ||
| 491 | # maximum is used; all commands are sent immediately | ||
| 492 | excessCmdLimit => 0, | ||
| 493 | # The time period (in seconds) to wait before sending stored commands. The value 1 | ||
| 494 | # means 'wait 1 seconds before sending the next batch of commands). The minimum value | ||
| 495 | # (in case this IV is set to 0) is the same as GA::Session->sessionLoopDelay | ||
| 496 | excessCmdDelay => 1, | ||
| 497 | # Some worlds don't explicitly state when a dead character is resurrected. If this flag | ||
| 498 | # is set to TRUE, the Status task will change the character's ->lifeStatus to 'alive' | ||
| 499 | # whenever one of the triggers which detect the current health points (etc) fires, if | ||
| 500 | # the character is dead, asleep or passed out. Otherwise, the Status task will wait | ||
| 501 | # for an explicit regenerated, come around or woken up trigger to fire. | ||
| 502 | lifeStatusOverrideFlag => FALSE, | ||
| 503 | |||
| 504 | # Command prompt patterns - a list of patterns which match the world's command prompts | ||
| 505 | # Useful at worlds that don't use EOR or GA, since we don't want to test triggers | ||
| 506 | # against incomplete lines, but we do want to test them against prompts | ||
| 507 | # Also useful at worlds (like Dead Souls) that, when display several room statements | ||
| 508 | # at once, add the beginning of the room statement to the end of the previous prompt | ||
| 509 | # (as the GA::Session code is able to split the line, at that point) | ||
| 510 | # The pattern should normally begin with an initial ^ character, but must not end with | ||
| 511 | # a terminal $ character (because if it does, it can't be used to split lines) | ||
| 512 | cmdPromptPatternList => [], | ||
| 513 | # Empty line suppression. If set to 0, no empty lines are suppressed. If set to 1, all | ||
| 514 | # empty lines are suppressed. If set to n (where n > 1), all consecutive lines from | ||
| 515 | # n onwards are suppressed (e.g. n = 3, 2 consecutive empty lines are preserved, all | ||
| 516 | # further consecutive empty lines are suppressed) | ||
| 517 | suppressEmptyLineCount => 0, | ||
| 518 | # Flag set to TRUE if empty line suppression should only be applied after the character | ||
| 519 | # is marked as logged in (preserving the world's initial ASCII art, if present); set | ||
| 520 | # to FALSE if empty line suppression should be applied immediately | ||
| 521 | suppressBeforeLoginFlag => FALSE, | ||
| 522 | |||
| 523 | # The name of the dictionary used by this world (the dictionary often has the same name | ||
| 524 | # as the world). Set to 'undef' until a dictionary is created for it | ||
| 525 | dict => undef, | ||
| 526 | # If this flag is TRUE, the Locator task will collect unknown words (words which appear | ||
| 527 | # in room statements, but which aren't in our dictionary), in order to provide a | ||
| 528 | # convenient list of words that could be added to the dictionary | ||
| 529 | collectUnknownWordFlag => FALSE, | ||
| 530 | # If this flag is TRUE, the Locator task will collect all contents lines, without | ||
| 531 | # splitting the line into objects, and store them in the dictionary (this flag isn't | ||
| 532 | # affected by the setting of $self->collectUnknownWordFlag; both that flag and this | ||
| 533 | # one can be set to TRUE) | ||
| 534 | collectContentsFlag => FALSE, | ||
| 535 | # Flag set to TRUE if objects in the same room and with the same name (e.g. two orcs) | ||
| 536 | # can be identified as 'orc 1' and 'orc 2' in commands sent to the world | ||
| 537 | numberedObjFlag => TRUE, # 'orc 1' and 'orc 2' possible on DS | ||
| 538 | # In worlds which specify multiples in contents lines like this: | ||
| 539 | # (2) A big axe | ||
| 540 | # ...a pattern which matches the portion '(2)' | ||
| 541 | # The pattern must contain a group substring. The first group substring is used as the | ||
| 542 | # multiple (other group substrings are ignored). In the example above, we would use | ||
| 543 | # the pattern '\((\d+)\)' | ||
| 544 | # Ignored if set to 'undef' (or an empty string). A matching pattern is NOT used as the | ||
| 545 | # multiple if the group substring does not contain a positive integer (1 is | ||
| 546 | # acceptable, but 0 is not) | ||
| 547 | multiplePattern => undef, | ||
| 548 | |||
| 549 | # Logging preferences for this world. The default settings are stored in | ||
| 550 | # GA::Client->constSessionLogPrefHash; the current settings are stored here. Hash in | ||
| 551 | # the form | ||
| 552 | # $logPrefHash{log_file_type} = TRUE or FALSE | ||
| 553 | logPrefHash => {}, # Set below | ||
| 554 | |||
| 555 | # The unit for counting the character's age. It matches one of the keys in the current | ||
| 556 | # dictionary's ->timeHash and ->timePluralHash IVs, which are the same in every | ||
| 557 | # language; so the value of this IV *must* be one of the English words 'second', | ||
| 558 | # 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade', 'century' or | ||
| 559 | # 'millennium' (or 'undef' if the age unit isn't known, or not used) | ||
| 560 | charAgeUnit => 'day', | ||
| 561 | # The unit in which the world weighs things (can be set to any word, of 'undef' if the | ||
| 562 | # unit is unknown, or not used) | ||
| 563 | weightUnit => undef, | ||
| 564 | # Strings representing the weight unit e.g. ('kilogram', 'kilo', 'kg', 'kilograms', | ||
| 565 | # 'kilos', 'kg') | ||
| 566 | # This list should contain abbreviations and plurals of the unit represented by | ||
| 567 | # ->weightUnit (If ->weightUnit is 'undef', should be an empty list) | ||
| 568 | weightUnitStringList => [], | ||
| 569 | |||
| 570 | # Dark room pattern groups (take the place of a room statement) (groups of 1) | ||
| 571 | # [0] - the pattern to match | ||
| 572 | darkRoomPatternList => [], | ||
| 573 | # Failed exit pattern groups (groups of 1) | ||
| 574 | # [0] - the pattern to match | ||
| 575 | failExitPatternList => [], | ||
| 576 | # Closed door pattern groups (groups of 1) | ||
| 577 | # [0] - the pattern (regex) to match | ||
| 578 | doorPatternList => [], | ||
| 579 | # Locked door pattern groups (groups of 1) | ||
| 580 | # [0] - the pattern to match | ||
| 581 | lockedPatternList => [], | ||
| 582 | # Involuntary exit patterns (groups of 1) | ||
| 583 | # [0] - the pattern to match | ||
| 584 | involuntaryExitPatternList => [], | ||
| 585 | # Unspecified room pattern groups (tell us that the character has arrived in a new room, | ||
| 586 | # but the room statement won't be displayed) (groups of 1) | ||
| 587 | # [0] - the pattern to match | ||
| 588 | unspecifiedRoomPatternList => [], | ||
| 589 | # Follow exit patterns, used when 'You follow Gandalf north' moves the character to a | ||
| 590 | # new room, and when the world sends a new room statement (groups of 2) | ||
| 591 | # [0] - the pattern to match | ||
| 592 | # [1] - the number of the group substring containing the direction | ||
| 593 | followPatternList => [], | ||
| 594 | # Follow anchor patterns, used when 'You follow Gandalf north' moves the character to a | ||
| 595 | # new room, but when the world doesn't send a new room statement (so the line | ||
| 596 | # matching the pattern must act as an anchor line) (groups of 2) | ||
| 597 | # [0] - the pattern to match | ||
| 598 | # [1] - the number of the group substring containing the direction | ||
| 599 | followAnchorPatternList => [], | ||
| 600 | # Transient exit pattern groups, matching any exits which are temporary and usually in | ||
| 601 | # random locations (such as the entrance to a wagon, which is moving from room to | ||
| 602 | # room) (groups of 2) | ||
| 603 | # [0] - the pattern to match | ||
| 604 | # [1] - the number of the destination room, or 'undef'/an empty string/zero if no | ||
| 605 | # destination room is set | ||
| 606 | transientExitPatternList => [], | ||
| 607 | |||
| 608 | # Status task format list - how the Status task should display its variables in its | ||
| 609 | # task window (if it's open) | ||
| 610 | # Status task variables are in the form @variable_name@; any items in the list matching | ||
| 611 | # that format are substituted for a value provided by the Status task, every time its | ||
| 612 | # task window is updated | ||
| 613 | statusFormatList => [ | ||
| 614 | # Not reasonable to expect the user to create this for themselves, so use a default | ||
| 615 | # list | ||
| 616 | 'HP: @health_points@ (@health_points_max@) MP: @magic_points@ (@magic_points_max@)' | ||
| 617 | . ' EP: @energy_points@ (@energy_points_max@) GP: @guild_points@' | ||
| 618 | . ' (@guild_points_max@) SP: @social_points@ (@social_points_max@)', | ||
| 619 | 'XP: @xp_current@ Total: @xp_total@ Level: @level@', | ||
| 620 | 'Bank: @bank_balance@ Purse: @purse_contents@', | ||
| 621 | 'Local Wimpy: @local_wimpy@ (@local_wimpy_max@) Remote Wimpy: @remote_wimpy@' | ||
| 622 | . ' (@remote_wimpy_max@)', | ||
| 623 | '@fight_count@ @coward_string@', | ||
| 624 | '@interact_string@', | ||
| 625 | 'Temp: XP: @temp_xp_count@ (Av: @temp_xp_average@) QP: @temp_quest_count@' | ||
| 626 | . ' Money: @temp_money_count@ Time: @temp_timer@', | ||
| 627 | ' @temp_fight_count@ @temp_coward_count@', | ||
| 628 | ' @temp_interact_count@', | ||
| 629 | 'Tasks: @task@ @task_active@', | ||
| 630 | ], | ||
| 631 | # Gauge format list - how the Status task should display data in the 'main' window's | ||
| 632 | # gauge box (groups of 7) | ||
| 633 | # [0] - the variable to display in the gauge; can be any of the Status task's | ||
| 634 | # character, fixed or custom variables | ||
| 635 | # [1] - the variable to display in the gauge as the 'maximum'; can be any of the | ||
| 636 | # Status task's character, fixed or custom variables | ||
| 637 | # - NB It's possible to use the same scalar in [0] and [1], e.g. 'bank_balance', | ||
| 638 | # in order to display a gauge that's always full (assuming that the Status | ||
| 639 | # task's ->gaugeValueFlag is TRUE, so the numerical value is also displayed) | ||
| 640 | # [2] - if TRUE, the total size of the gauge is ($value + $maxValue). If FALSE (or | ||
| 641 | # 'undef'), the total size is $maxValue | ||
| 642 | # [3] - the label to use, e.g. 'HP' | ||
| 643 | # [4] - the colour of the 'full' portion of the gauge (if 'undef', the default gauge | ||
| 644 | # colour is used) | ||
| 645 | # [5] - the colour of the 'empty' portion of the gauge (if 'undef', the default gauge | ||
| 646 | # colour is used) | ||
| 647 | # [6] - the colour of the label (if 'undef', the default label colour is used) | ||
| 648 | # A default list using the most common variables | ||
| 649 | gaugeFormatList => [ | ||
| 650 | 'health_points', 'health_points_max', FALSE, 'HP', | ||
| 651 | 'RED', 'red', 'WHITE', | ||
| 652 | 'magic_points', 'magic_points_max', FALSE, 'MP', | ||
| 653 | 'YELLOW', 'yellow', 'black', | ||
| 654 | 'energy_points', 'energy_points_max', FALSE, 'EP', | ||
| 655 | 'GREEN', 'green', 'black', | ||
| 656 | 'guild_points', 'guild_points_max', FALSE, 'GP', | ||
| 657 | 'BLUE', 'blue', 'WHITE', | ||
| 658 | 'social_points', 'social_points_max', FALSE, 'SP', | ||
| 659 | 'MAGENTA', 'magenta', 'WHITE', | ||
| 660 | ], | ||
| 661 | # Hash of Status task variables, whose values can be set when MSDP variables are | ||
| 662 | # received. Hash in the form | ||
| 663 | # $msdpStatusVarHash{msdp_variable} = status_task_variable | ||
| 664 | # Normally, the Status task only accepts a subset of MSDP variables for the categories | ||
| 665 | # 'Character', 'Combat' and 'World'. Adding key-value pairs to this hash allow the | ||
| 666 | # Status task to accept other MSDP variables too | ||
| 667 | msdpStatusVarHash => {}, | ||
| 668 | # Hash of Status task variables, whose values can be set when MXP entities are created | ||
| 669 | # or modified. Hash in the form | ||
| 670 | # $mspStatusVarHash{mxp_entity_name} = status_task_variable | ||
| 671 | # (There are no pre-existing MXP entities which the Status task accepts, as there are | ||
| 672 | # for MSDP variables) | ||
| 673 | mxpStatusVarHash => {}, | ||
| 674 | # Bar string pattern groups (groups of 6) | ||
| 675 | # [0] - the pattern to match | ||
| 676 | # [1] - the number of the group substring that contains the data we need | ||
| 677 | # [2] - 'health', 'magic', 'energy', 'guild', 'social', 'xp_current', 'xp_next_level', | ||
| 678 | # 'qp_current', 'qp_next_level', 'op_current', 'op_next_level' (note that | ||
| 679 | # other values, including all other Status task variables, are invalid here) | ||
| 680 | # [3] - 'hide' to use a gag trigger, 'show' to use a non-gag trigger, 'choose' to let | ||
| 681 | # the Status task choose | ||
| 682 | # [4] - the string which represents 1 unit, e.g. '=' or '*' | ||
| 683 | # [5] - how many units equal the maximum | ||
| 684 | barPatternList => [], | ||
| 685 | # Pattern groups containing one or more group substrings, only one of which is used | ||
| 686 | # (groups of 4) | ||
| 687 | # [0] - the pattern to match | ||
| 688 | # [1] - the number of the group substring that contains the data we need | ||
| 689 | # [2] - any Status task character, local or custom variable | ||
| 690 | # [3] - 'hide' to use a gag trigger, 'show' to use a non-gag trigger, 'choose' to let | ||
| 691 | # the Status task choose | ||
| 692 | groupPatternList => [], | ||
| 693 | # Affect string pattern groups (groups of 3) | ||
| 694 | # [0] - the pattern to match | ||
| 695 | # [1] - the number of the group substring that contains the data we need (probably a | ||
| 696 | # string like 'Curse Invisibility', with each word corresponding to a key in | ||
| 697 | # the current character's ->affectHash. If the string means that the | ||
| 698 | # character is not affected by any spells (etc), use the number 0 | ||
| 699 | # [2] - 'hide' to use a gag trigger, 'show' to use a non-gag trigger, 'choose' to let | ||
| 700 | # the Status task choose | ||
| 701 | affectPatternList => [], | ||
| 702 | # Stat string pattern groups (groups of 4) | ||
| 703 | # [0] - the pattern to match | ||
| 704 | # [1] - the number of the group substring that contains the data we need | ||
| 705 | # [2] - a key in the stat hash (e.g. 'int', 'con', 'dex') | ||
| 706 | # [3] - 'hide' to use a gag trigger, 'show' to use a non-gag trigger, 'choose' to let | ||
| 707 | # the Status task choose | ||
| 708 | statPatternList => [], | ||
| 709 | # Age string pattern groups (groups of 1) | ||
| 710 | # [0] - the pattern to match (all group substrings are used) | ||
| 711 | agePatternList => [], | ||
| 712 | # Time string pattern groups (groups of 1) | ||
| 713 | # [0] - the pattern to match (only the first group substring is used) | ||
| 714 | timePatternList => [], | ||
| 715 | # Status ignore pattern groups (groups of 1) | ||
| 716 | # [0] - the pattern to match when strings should be ignored | ||
| 717 | statusIgnorePatternList => [], | ||
| 718 | |||
| 719 | # Life status pattern groups (groups of 1) | ||
| 720 | # [0] - the pattern to match | ||
| 721 | deathPatternList => [], | ||
| 722 | resurrectPatternList => [], | ||
| 723 | passedOutPatternList => [], | ||
| 724 | comeAroundPatternList => [], | ||
| 725 | fallAsleepPatternList => [], | ||
| 726 | wakeUpPatternList => [], | ||
| 727 | questCompletePatternList => [], | ||
| 728 | |||
| 729 | # Inventory string pattern groups (groups of 5) | ||
| 730 | # [0] - the pattern to match | ||
| 731 | # [1] - the number of the group substring that contains object(s) in the inventory | ||
| 732 | # (might be 0 if the line doesn't contain any objects) | ||
| 733 | # [2] - what kind of possession this is. Standard strings are: | ||
| 734 | # 'wield', 'hold', 'wear', 'carry' for objects; | ||
| 735 | # 'sack' for anything being carried in something else (which usually doesn't | ||
| 736 | # appear in the inventory list); | ||
| 737 | # 'purse', 'deposit', 'deposit_only', 'withdraw', 'withdraw_only', 'balance' | ||
| 738 | # which update the character's purse and bank balances; | ||
| 739 | # 'empty_purse' for an empty purse, 'empty_bank' for an empty bank account | ||
| 740 | # 'misc' for any other type of possession | ||
| 741 | # 'ignore' for a line in the inventory which should be ignored | ||
| 742 | # [3] - 'hide' to use a gag trigger, 'show' to use a non-gag trigger (all the | ||
| 743 | # triggers are disabled when the task is disactivated, so we don't need a | ||
| 744 | # 'choose') | ||
| 745 | # [4] - 'start' if this line is always at the beginning of an inventory list; 'stop' | ||
| 746 | # if it is always the end of an inventory list; 'optional' for any other line | ||
| 747 | inventoryPatternList => [], | ||
| 748 | # Inventory ignore pattern groups (groups of 2) | ||
| 749 | # [0] - the pattern to match when strings should be ignored | ||
| 750 | # [1] - 'hide' to use a gag trigger, 'show' to use a non-gag trigger (all the | ||
| 751 | # triggers are disabled when the task is disactivated, so we don't need a | ||
| 752 | # 'choose') | ||
| 753 | inventoryIgnorePatternList => [], | ||
| 754 | # Inventory discard pattern groups (groups of 1) | ||
| 755 | # [0] - the pattern which matches a portion of a line | ||
| 756 | # All patterns in the list are matched against all lines. For any matching lines, the | ||
| 757 | # matching portion(s) are removed from the line (using the pattern(s) in Perl | ||
| 758 | # substitutions), and the rest of the line is parsed as an object. | ||
| 759 | # These patterns are matched against lines after patterns in | ||
| 760 | # ->inventoryIgnorePatternList are checked | ||
| 761 | inventoryDiscardPatternList => [], | ||
| 762 | # Inventory split pattern groups (groups of 1) | ||
| 763 | # [0] - the pattern which matches a portion of a line | ||
| 764 | # All patterns in the list are matched against all lines. For any matching lines, the | ||
| 765 | # line is split into multiple pieces, in a standard Perl split operation using the | ||
| 766 | # pattern. If multiple discard patterns are specified, they are all applied, one after | ||
| 767 | # another, potentially splitting existing line pieces into smaller pieces. Each piece | ||
| 768 | # is then parsed as a (separate) object. The portion of the line matching the split | ||
| 769 | # pattern is discarded | ||
| 770 | # NB The split occurs before the object(s) are passed to GA::Obj::WorldModel->parseObj. | ||
| 771 | # That function uses the current dictonary to parse a string like 'Two orcs, a sword | ||
| 772 | # and three shields' into a list of objects. This IV doesn't need to include commas | ||
| 773 | # and words like 'and' because ->parseObj already takes care of that | ||
| 774 | # These patterns are matched against lines after patterns in | ||
| 775 | # ->inventoryIgnorePatternList and ->inventoryDiscardPatternList are checked | ||
| 776 | inventorySplitPatternList => [], | ||
| 777 | # The way in which the Inventory task (if running) interprets the character's inventory | ||
| 778 | # In inventory mode 'match_all', only lines matching one of the patterns in | ||
| 779 | # ->inventoryPatternList (and not matching ->inventoryIgnorePatternList) are used. The | ||
| 780 | # lines are processed as soon as they are received. There should be at least one | ||
| 781 | # 'start' or 'stop' line; when a 'start' line is received, the previously-gathered | ||
| 782 | # inventory is emptied; when a 'stop' line is received, the previously-gathered | ||
| 783 | # inventory is marked to be emptied as soon as the next matching line is found | ||
| 784 | # In inventory mode 'start_stop', all lines between a 'start' and 'stop' pattern are | ||
| 785 | # used. Lines which match one of the patterns in ->inventoryPatternList (and which | ||
| 786 | # don't match one of the patterns in ->inventoryIgnorePatternList) are processed as | ||
| 787 | # soon as they are received; other lines between 'start' and 'stop' are processed when | ||
| 788 | # the Inventory task is next called (default: once a second) | ||
| 789 | # In inventory mode 'start_empty', all lines between a 'start' line and the first empty | ||
| 790 | # line are used. Lines which match one of the patterns in ->inventoryPatternList (and | ||
| 791 | # which don't match one of the patterns in ->inventoryIgnorePatternList) are processed | ||
| 792 | # as soon as they are received; other lines between 'start' and the first empty line | ||
| 793 | # are processed when the Inventory task is next called (default: once a second) | ||
| 794 | # NB 'optional' patterns must contain group substrings; only the group substrings are | ||
| 795 | # processed as an object. 'start' and 'stop' patterns can contain group substrings, or | ||
| 796 | # not; the group substrings are processed as objects, if found | ||
| 797 | # NB In modes 'start_stop' and 'start_empty', lines which don't match an 'optional' | ||
| 798 | # pattern are processed whole | ||
| 799 | inventoryMode => 'match_all', | ||
| 800 | |||
| 801 | # Object condition pattern groups (groups of 4) | ||
| 802 | # [0] - the pattern to match | ||
| 803 | # [1] - the number of the group substring that contains the object (set to 0 if no | ||
| 804 | # part of the string is guaranteed to contain the object) | ||
| 805 | # [2] - 'hide' to use a gag trigger, 'show' to use a non-gag trigger (all the | ||
| 806 | # triggers are disabled when the task is disactivated, so we don't need a | ||
| 807 | # 'choose') | ||
| 808 | # [3] - the corresponding condition in the range 0-100 | ||
| 809 | conditionPatternList => [], | ||
| 810 | # Condition ignore string arguments (groups of 1) | ||
| 811 | conditionIgnorePatternList => [], | ||
| 812 | |||
| 813 | # Fight pattern groups applying to all characters in the world (groups of 2) | ||
| 814 | # [0] - the pattern to match | ||
| 815 | # [1] - the number of the group substring that contains the target (if 0, string | ||
| 816 | # doesn't contain the target) | ||
| 817 | fightStartedPatternList => [], | ||
| 818 | cannotFindTargetPatternList => [], | ||
| 819 | targetAlreadyDeadPatternList | ||
| 820 | => [], | ||
| 821 | targetKilledPatternList => [], | ||
| 822 | fightDefeatPatternList => [], | ||
| 823 | wimpyEngagedPatternList => [], | ||
| 824 | # Exceptions to these pattern groups [groups of 1] | ||
| 825 | # [0] - the pattern to match | ||
| 826 | noFightStartedPatternList => [], | ||
| 827 | noCannotFindTargetPatternList | ||
| 828 | => [], | ||
| 829 | noTargetAlreadyDeadPatternList | ||
| 830 | => [], | ||
| 831 | noTargetKilledPatternList => [], | ||
| 832 | noFightDefeatPatternList => [], | ||
| 833 | noWimpyEngagedPatternList => [], | ||
| 834 | |||
| 835 | # Interaction pattern groups applying to all characters in the world (groups of 2) | ||
| 836 | # [0] - the pattern to match | ||
| 837 | # [1] - the number of the group substring that contains the target (if 0, string | ||
| 838 | # doesn't contain the target) | ||
| 839 | interactionStartedPatternList | ||
| 840 | => [], | ||
| 841 | cannotInteractPatternList | ||
| 842 | => [], | ||
| 843 | interactionSuccessPatternList | ||
| 844 | => [], | ||
| 845 | interactionFailPatternList | ||
| 846 | => [], | ||
| 847 | interactionFightPatternList | ||
| 848 | => [], # Converts the interaction into a fight | ||
| 849 | interactionDisasterPatternList | ||
| 850 | => [], # Engages wimpy mode | ||
| 851 | # Exceptions to these pattern groups [groups of 1] | ||
| 852 | # [0] - the pattern to match | ||
| 853 | noInteractionStartedPatternList | ||
| 854 | => [], | ||
| 855 | noCannotInteractPatternList | ||
| 856 | => [], | ||
| 857 | noInteractionSuccessPatternList | ||
| 858 | => [], | ||
| 859 | noInteractionFailPatternList | ||
| 860 | => [], | ||
| 861 | noInteractionFightPatternList | ||
| 862 | => [], | ||
| 863 | noInteractionDisasterPatternList | ||
| 864 | => [], | ||
| 865 | |||
| 866 | # Fight/interaction pattern groups (groups of 3) | ||
| 867 | # [0] - the pattern to match | ||
| 868 | # [1] - the number of the group substring that contains the target | ||
| 869 | # [2] - the number of the group substring that contains the direction (0 if not | ||
| 870 | # supplied by the world, e.g. 'The orc runs away.') | ||
| 871 | targetLeavesPatternList => [], | ||
| 872 | targetArrivesPatternList => [], | ||
| 873 | # Exceptions to these pattern groups (groups of 1) | ||
| 874 | # [0] - the pattern to match | ||
| 875 | noTargetLeavesPatternList => [], | ||
| 876 | noTargetArrivesPatternList => [], | ||
| 877 | |||
| 878 | # Fight/interaction pattern groups (groups of 1) | ||
| 879 | # [0] - the pattern to match | ||
| 880 | noFightsRoomPatternList => [], | ||
| 881 | noInteractionsRoomPatternList | ||
| 882 | => [], | ||
| 883 | |||
| 884 | # Get success strings (what the world sends after the 'get axe' command) (groups of 1) | ||
| 885 | # [0] - the pattern to match | ||
| 886 | getSuccessPatternList => [], | ||
| 887 | # Get too heavy pattern groups (what the world sends after the 'get axe' command, if | ||
| 888 | # it's too heavy to pick up, but when the axe actually exists) (groups of 1) | ||
| 889 | # [0] - the pattern to match | ||
| 890 | getHeavyPatternList => [], | ||
| 891 | # Get fail pattern groups (what the world sends after the 'get axe' command, when the | ||
| 892 | # axe doesn't exist) (groups of 1) | ||
| 893 | # [0] - the pattern to match | ||
| 894 | getFailPatternList => [], | ||
| 895 | # Drop success pattern groups (what the world sends after the 'drop axe' command) | ||
| 896 | # (groups of 1) | ||
| 897 | # [0] - the pattern to match | ||
| 898 | dropSuccessPatternList => [], | ||
| 899 | # Drop forbidden pattern groups (what the world sends after the 'drop axe' command, if | ||
| 900 | # the action is forbidden - perhaps because the character has to stop wielding the axe | ||
| 901 | # first) (groups of 1) | ||
| 902 | # [0] - the pattern to match | ||
| 903 | dropForbidPatternList => [], | ||
| 904 | # Drop fail pattern groups (what the world sends after the 'drop axe' command, when the | ||
| 905 | # axe doesn't exist) (groups of 1) | ||
| 906 | # [0] - the pattern to match | ||
| 907 | dropFailPatternList => [], | ||
| 908 | |||
| 909 | # Buy success strings (what the world sends after the 'buy axe' command) (groups of 1) | ||
| 910 | # [0] - the pattern to match | ||
| 911 | buySuccessPatternList => [], | ||
| 912 | # Buy partial success strings (can be used in situations like 'buy x y and z' if the | ||
| 913 | # world send 'The shopkeeper can't cope with that many items') (groups of 1) | ||
| 914 | # [0] - the pattern to match | ||
| 915 | buyPartialPatternList => [], | ||
| 916 | # Buy fail strings (what the world sends after the 'buy axe' command, if it's not | ||
| 917 | # possible for any reason) (groups of 1) | ||
| 918 | # [0] - the pattern to match | ||
| 919 | buyFailPatternList => [], | ||
| 920 | # Sell success strings (what the world sends after the 'sell axe' command) (groups of 1) | ||
| 921 | # [0] - the pattern to match | ||
| 922 | sellSuccessPatternList => [], | ||
| 923 | # Sell partial success strings (can be used in situations like 'sell all' if the world | ||
| 924 | # sends 'The shopkeeper can't cope with that many items') (groups of 1) | ||
| 925 | # [0] - the pattern to match | ||
| 926 | sellPartialPatternList => [], | ||
| 927 | # Sell fail strings (what the world sends after the 'sell axe' command, if it's not | ||
| 928 | # possible for any reason) (groups of 1) | ||
| 929 | sellFailPatternList => [], | ||
| 930 | |||
| 931 | # Advance success strings (what the world sends after you successfully advance a skill) | ||
| 932 | # (groups of 1) | ||
| 933 | # [0] - the pattern to match | ||
| 934 | advanceSuccessPatternList => [], | ||
| 935 | # Advance fail strings (what the world sends after you fail to advance a skill) (groups | ||
| 936 | # of 1) | ||
| 937 | # [0] - the pattern to match | ||
| 938 | advanceFailPatternList => [], | ||
| 939 | |||
| 940 | # List of patterns for use in the Channels and Divert task (groups of 3) | ||
| 941 | # [0] - the pattern to match | ||
| 942 | # [1] - a channel name | ||
| 943 | # [2] - a flag set to FALSE if the matching line must also be displayed in the 'main' | ||
| 944 | # window, TRUE if it must be gagged in the 'main' window | ||
| 945 | # When text matching a pattern is received, the Channels task displays it in a tab with | ||
| 946 | # the name of the channel. The Divert task uses assigned colours for the channels | ||
| 947 | # 'tell', 'social', 'custom' and 'warning', and a separate assigned colour for every | ||
| 948 | # other channel | ||
| 949 | # Channel names must be 1-16 characters. There is no need to add channels anywhere; the | ||
| 950 | # channel exists if it's defined in this list | ||
| 951 | channelList => [], | ||
| 952 | # A list of exceptions. If text matches a pattern in $self->channelList, but also | ||
| 953 | # matches any of the patterns in this list, it is not diverted to the Channels or | ||
| 954 | # Divert task (groups of 1) | ||
| 955 | # [0] - the pattern to match | ||
| 956 | noChannelList => [], | ||
| 957 | |||
| 958 | # Hash of currency units mapping each unit onto a standard unit (usually the largest | ||
| 959 | # one) | ||
| 960 | # e.g. ->currencyHash{'gold'} = 1; | ||
| 961 | # The keys in this hash can represent either an adjective (e.g. 'gold' as in 'gold | ||
| 962 | # coin'), or a noun ('dollar') | ||
| 963 | # NB One of keys with a value of 1 - here, 'gold' - must also be specified in | ||
| 964 | # $self->standardCurrencyUnit (if there is more than one key with the value 1, choose | ||
| 965 | # one of the keys as the standard unit) | ||
| 966 | currencyHash => { | ||
| 967 | 'gold' => 1, | ||
| 968 | }, | ||
| 969 | standardCurrencyUnit => 'gold', | ||
| 970 | # The number of decimal places to which any cash value should be rounded, when | ||
| 971 | # intercepted by the Inventory task (the Status task does the actual rounding). Use | ||
| 972 | # a value of 0 to round cash values to the nearest integer or -1 to prevent | ||
| 973 | # rounding altogether. Maximum value 9. | ||
| 974 | # If you use a value of 1 or more, it should match the lowest value in ->currencyHash | ||
| 975 | # (e.g. if you use bronze => 0.01, then ->currencyRounding should be 2 for 2dp) | ||
| 976 | currencyRounding => -1, | ||
| 977 | |||
| 978 | # Hash of missions (each one stored in a GA::Obj::Mission object) | ||
| 979 | # ->missionHash{unique_name} = blessed_reference_to_mission_object | ||
| 980 | missionHash => {}, | ||
| 981 | |||
| 982 | # Variables which are also used by the character profile characters - if these values | ||
| 983 | # are unknown, or they vary too much, leave them empty/set to 0 | ||
| 984 | # Hash of quests (list of quest names in this world) | ||
| 985 | # ->questHash{unique_name} = blessed_reference_to_quest_object | ||
| 986 | questHash => {}, | ||
| 987 | # Number of quests stored in ->questHash | ||
| 988 | questCount => 0, | ||
| 989 | # Total quest points, XP and cash earned by the quests stored in ->questHash | ||
| 990 | questPointCount => 0, | ||
| 991 | questXPCount => 0, | ||
| 992 | questCashCount => 0, | ||
| 993 | |||
| 994 | # Hash of character stats | ||
| 995 | # $statHash{stat_name} = default_value | ||
| 996 | # (N.B. 'default_value' is usually 0) | ||
| 997 | statHash => {}, | ||
| 998 | # Ordered list of character stats. If set, the Status task (or anything else) can | ||
| 999 | # use this list to display a list of character stats, in the order in which they occur | ||
| 1000 | # in the list. If this list is empty, the task uses the keys in $self->statHash in | ||
| 1001 | # alphabetical order | ||
| 1002 | statOrderList => [], | ||
| 1003 | |||
| 1004 | # Hash of commands sent by the Status task when it is in 'active' mode (e.g. 'score', | ||
| 1005 | # 'sc' sent every ten seconds) | ||
| 1006 | # This hash is inherited by the character profile, and from there it is copied by the | ||
| 1007 | # Status task | ||
| 1008 | # e.g. $statusCmdHash{'score'} = 30 | ||
| 1009 | # (sends the command 'score' every 30 seconds) | ||
| 1010 | statusCmdHash => {}, | ||
| 1011 | # Hash of commands the Inventory task should send to the world periodically | ||
| 1012 | # This hash is inherited by the character profile, and from there it is copied by the | ||
| 1013 | # Status task | ||
| 1014 | # e.g. $inventoryCommandHash{'i'} = 30 | ||
| 1015 | # (sends the command 'i' every 30 seconds) | ||
| 1016 | inventoryCmdHash => {}, | ||
| 1017 | |||
| 1018 | # A section of text which describes a room is called a 'room statement'. Axmud's Locator | ||
| 1019 | # task uses room statements to track the character's current location in the world | ||
| 1020 | # Many worlds use room statements in one of two forms, 'verbose' and 'brief'. Axmud | ||
| 1021 | # divides these into three distinct forms, some of which are not available in every | ||
| 1022 | # world: | ||
| 1023 | # | ||
| 1024 | # 'Verbose', e.g. | ||
| 1025 | # | ||
| 1026 | # Village Road Intersection | ||
| 1027 | # You are in the main intersection of the village. Saquivor road extends north and | ||
| 1028 | # south, intersected east to west by a road that leads west toward a wilderness, | ||
| 1029 | # and east toward shore. | ||
| 1030 | # Obvious exits: south, north, east, west | ||
| 1031 | # A damp towel is here. | ||
| 1032 | # | ||
| 1033 | # 'Short verbose' | ||
| 1034 | # (Exactly the same as 'verbose', but the verbose description part is usually | ||
| 1035 | # omitted) | ||
| 1036 | # | ||
| 1037 | # 'Brief', e.g. | ||
| 1038 | # | ||
| 1039 | # Village Road Intersection [s, n, e, w] | ||
| 1040 | # | ||
| 1041 | # When the task loop spins, the Locator task checks incoming text to see whether it | ||
| 1042 | # looks like a verbose, short verbose or brief room statement. | ||
| 1043 | # Normally, the Locator task looks out for text matching all three forms of statement. | ||
| 1044 | # However, if a particular world omits one or more form, the task can be told to | ||
| 1045 | # ignore those forms | ||
| 1046 | # | ||
| 1047 | # Room statements consist of an ordered list of components. Each component is a | ||
| 1048 | # GA::Obj::Component object. Axmud recognises the following component types | ||
| 1049 | # (available as a list in GA::Client->constComponentTypeList): | ||
| 1050 | # 'anchor' - See below (1 line only) | ||
| 1051 | # 'verb_title' - The room title in a verbose/short verbose statement | ||
| 1052 | # 'verb_descrip' - The description in a verbose/short verbose statement | ||
| 1053 | # 'verb_exit' - The exit list in a verbose/short verbose statement | ||
| 1054 | # 'verb_content' - The contents list in a verbose/short verbose statement | ||
| 1055 | # 'verb_special' - Lines adjacent to the verbose description, which are actually | ||
| 1056 | # a contents list | ||
| 1057 | # 'brief_title' - The room title in a brief statement | ||
| 1058 | # 'brief_exit' - The exit list in a brief statement | ||
| 1059 | # 'brief_title_exit' | ||
| 1060 | # - The room title and exit list (1 line only) | ||
| 1061 | # 'brief_exit_title' | ||
| 1062 | # - The exit list and room title (1 line only) | ||
| 1063 | # 'brief_content' - The contents list in a brief statement | ||
| 1064 | # 'room_cmd' - List of commands available in the room | ||
| 1065 | # 'mudlib_path' - Path to the room's source code, relative to | ||
| 1066 | # GA::Obj::WorldModel->mudlibPath | ||
| 1067 | # 'weather' - Lines describing the weather. They are not stored in the world | ||
| 1068 | # model but are displayed in the Locator task's window (if | ||
| 1069 | # open. The component's name is displayed too, so this | ||
| 1070 | # component can used for the weather, the time of day, or | ||
| 1071 | # anything else that we want displayed in the window | ||
| 1072 | # 'ignore_line' - Lines inside the statement, which should be ignored (here, | ||
| 1073 | # 'inside' can mean the first or last lines of the statement) | ||
| 1074 | # 'custom' - Available for any other code that wants to create their own | ||
| 1075 | # GA::Obj:Components, and to store them here | ||
| 1076 | # The 'anchor' is a special component, which is always one line long and matches a | ||
| 1077 | # specific pattern. The Locator task finds a room statement by looking for a line | ||
| 1078 | # matching the anchor line. | ||
| 1079 | # For most worlds, the anchor line is the list of exits, matching a pattern like | ||
| 1080 | # 'Obvious exits: '. On most worlds, the 'anchor' component and either the 'verb_exit' | ||
| 1081 | # or 'brief_exit' components share a line. | ||
| 1082 | # | ||
| 1083 | # An Axmud room statement consists of an ordered list of components, which must include | ||
| 1084 | # at least the anchor line (all other components are, in theory, optional.) | ||
| 1085 | # Any component can be used with any form of statement - for example, in worlds which | ||
| 1086 | # use identical contents lists in their verbose and brief statements, you can use the | ||
| 1087 | # 'verb_content' component in both) | ||
| 1088 | # Every component can have a fixed number of lines or a dynamic number, can stop at a | ||
| 1089 | # line matching a pattern (or not matching a pattern), or stop at the first empty line | ||
| 1090 | # (or the first line not containing alphanumeric characters). (Exceptions: the | ||
| 1091 | # 'anchor' and 'mudlib_path' components are only ever one line long) | ||
| 1092 | # In addition, the anchor line can be marked as appearing on its own line, as sharing | ||
| 1093 | # a line with the component before it, or as sharing a line with the component after | ||
| 1094 | # it | ||
| 1095 | # | ||
| 1096 | # Hash of GA::Obj::Component objects that exist (not all of them may be in use). Each | ||
| 1097 | # has a unique name (max 16 chars). Hash in the form | ||
| 1098 | # $componentHash{unique_name} = blessed_reference_to_component_object | ||
| 1099 | componentHash => {}, | ||
| 1100 | # The component lists for verbose room statements (set below). If not empty, consists of | ||
| 1101 | # GA::Obj::Component object names (keys in $self->componentHash) and/or the string | ||
| 1102 | # 'anchor'. If empty, this form of statement is not used in the world | ||
| 1103 | verboseComponentList => [], | ||
| 1104 | # The component lists for short verbose room statements (set below) | ||
| 1105 | shortComponentList => [], | ||
| 1106 | # The component lists for brief room statements (set below) | ||
| 1107 | briefComponentList => [], | ||
| 1108 | |||
| 1109 | # Some worlds (e.g. MUD1, LamdbaMOO) don't use room statements with any matchable text | ||
| 1110 | # at all; in both those cases, neither have an exit list. Because we can't use | ||
| 1111 | # regular expressions to detect a room statement, we have to assume a move was | ||
| 1112 | # successful, unless a recognisable fail exit string is encountered straight after the | ||
| 1113 | # move | ||
| 1114 | # In basic mapping mode, GA::Obj::Component objects can still be specified, typically | ||
| 1115 | # in order to process room titles, verbose descriptions, contents lists and so on. | ||
| 1116 | # However, if no components are specified, the move is still considered successful | ||
| 1117 | # In basic mapping mode, the Locator task won't use a line matching a recognisable | ||
| 1118 | # prompt ($self->cmdPromptPatternList) or an empty line as the start of a room | ||
| 1119 | # statement; so make sure ->cmdPromptPatternList has been set, if you use basic | ||
| 1120 | # mapping mode | ||
| 1121 | # If the Automapper window is open, basic mapping mode normally causes a one-way exit | ||
| 1122 | # to be drawn from the departure room to the newly-created destination room. If the | ||
| 1123 | # user wants to create 2-way exits by default, they can toggle | ||
| 1124 | # GA::Obj::WorldModel->autocompleteExitsFlag | ||
| 1125 | # Those components are specified in $self->verboseAnchorPatternList, | ||
| 1126 | # ->shortAnchorPatternList and ->briefAnchorPatternList. If specified, the first item | ||
| 1127 | # in the list(s) must be 'anchor', followed by one or more other components | ||
| 1128 | # Basic mapping mode. FALSE - don't use basic mapping (because this world's room | ||
| 1129 | # statements contain some matchable text, like a list of exits). TRUE - use basic | ||
| 1130 | # mapping (assume a move was successful, unless a recognisable fail exit string is | ||
| 1131 | # seen straight after the move) | ||
| 1132 | basicMappingFlag => FALSE, | ||
| 1133 | # The world MUD1 (British Legends) echos back movement commands. This leaves the Locator | ||
| 1134 | # unable to detect fail exit strings, and so on (in basic mapping mode) | ||
| 1135 | # A list of patterns which match a line which should NOT be checked as potential anchor | ||
| 1136 | # lines (ignored, when extracting room statement components). | ||
| 1137 | # NB The Locator uses this list regardless of whether basic mapping mode is on, or not; | ||
| 1138 | # but it's probably only useful in basic mapping mode | ||
| 1139 | notAnchorPatternList => [], | ||
| 1140 | |||
| 1141 | # Settings for 'anchor' component | ||
| 1142 | # A list of patterns which mark a line as a verbose anchor line | ||
| 1143 | verboseAnchorPatternList => [], | ||
| 1144 | # The anchor line's relationship with other components in the component list: -1 if the | ||
| 1145 | # anchor line shares a line with the component before it; +1 if the anchor line | ||
| 1146 | # shares a line with the component after it; 0 if the anchor line does not share its | ||
| 1147 | # line with any component | ||
| 1148 | verboseAnchorOffset => 1, # By default, anchor line is the list of exits | ||
| 1149 | # A list of patterns adjacent to the anchor line, used to check that we've got the | ||
| 1150 | # right one. List in groups of 2, in the form | ||
| 1151 | # (offset, pattern, offset, pattern) | ||
| 1152 | # ...where 'offset' is an integer in the range -16 to +16 describing a line above | ||
| 1153 | # (negative) or below (positive) the anchor line (if 0, the anchor line itself is | ||
| 1154 | # checked against the pattern), and 'pattern' is the regex that line must match. | ||
| 1155 | # If any of the 'pattern's in the list don't match, the line matching | ||
| 1156 | # ->verboseAnchorPatternList is not used as an anchor line. If the line | ||
| 1157 | # specified by 'offset' doesn't exist (hasn't been received yet), the anchor line | ||
| 1158 | # is not used (so if you specify any check patterns, it's better to use an anchor | ||
| 1159 | # line near the start of a room statement, not one near the end of it) | ||
| 1160 | verboseAnchorCheckList => [], | ||
| 1161 | # A list of patterns which mark a line as a short verbose anchor line | ||
| 1162 | shortAnchorPatternList => [], | ||
| 1163 | # The anchor line's relationship with other components in the component list: | ||
| 1164 | shortAnchorOffset => 1, | ||
| 1165 | # A list of patterns adjacent to the anchor line, in groups of 2 | ||
| 1166 | shortAnchorCheckList => [], | ||
| 1167 | # A list of patterns which mark a line as a brief anchor line | ||
| 1168 | briefAnchorPatternList => [], | ||
| 1169 | # The anchor line's relationship with other components in the component list: | ||
| 1170 | briefAnchorOffset => 1, | ||
| 1171 | # A list of patterns adjacent to the anchor line, in groups of 2 | ||
| 1172 | briefAnchorCheckList => [], | ||
| 1173 | |||
| 1174 | # Settings for 'verb_exit' component | ||
| 1175 | # If the exits in the 'verb_exit' component are separated by characters or strings, the | ||
| 1176 | # delimiters used. Must include whitespace, as appropriate (e.g. ' and ' / ', ' / '.') | ||
| 1177 | # Items in the list should ideally be in order of length, longest first (but the | ||
| 1178 | # Locator task sorts them before using them, anyway) | ||
| 1179 | verboseExitDelimiterList => [], # String, not a regex | ||
| 1180 | # A non-delimiter is a string which the exit list should NOT contain. This helps the | ||
| 1181 | # Locator task to work out what is a list of exits, and what is not (e.g. 'is here', | ||
| 1182 | # 'are here') | ||
| 1183 | # Items in the list can be in any order (and are not sorted by the Locator task) | ||
| 1184 | verboseExitNonDelimiterList => [], # String, not a regex | ||
| 1185 | # Alternatively, if the exits are single letters in a continuous string (e.g. NSEW), | ||
| 1186 | # set this flag to TRUE to split the string into 1-letter exits | ||
| 1187 | # NB If both delimiters and the flag are set, they are both used - delimiters are used | ||
| 1188 | # first to split the string into a list; then each item in the list is split into | ||
| 1189 | # characters | ||
| 1190 | verboseExitSplitCharFlag => FALSE, | ||
| 1191 | # If the exit list is surrounded by markers, these lists contain those markers. Every | ||
| 1192 | # marker is a regex | ||
| 1193 | # If no markers are available on this world, set them both as empty lists. The markers | ||
| 1194 | # are checked in order, so longer markers should be listed before shorter ones. Left | ||
| 1195 | # markers are checked before right ones | ||
| 1196 | # Left marker regexes should start with '^', and right marker regexes should end with | ||
| 1197 | # '$'; if they don't, the markers will be removed from the middle of a list of exits | ||
| 1198 | # (which is probably not what you want) | ||
| 1199 | # For lines like 'There are no obvious exits', create a left marker like | ||
| 1200 | # '^There are no obvious exits\.*$' | ||
| 1201 | verboseExitLeftMarkerList => [], | ||
| 1202 | verboseExitRightMarkerList => [], | ||
| 1203 | |||
| 1204 | # Settings for 'brief_exit', 'brief_title_exit' and 'brief_exit_title' components | ||
| 1205 | # If the exits in these components are separated by characters or strings, the | ||
| 1206 | # delimiters used. Must include whitespace, as appropriate (e.g. ' and ' / ', ' / '.') | ||
| 1207 | # Items in the list should ideally be in order of length, longest first (but the | ||
| 1208 | # Locator task sorts them before using them, anyway) | ||
| 1209 | briefExitDelimiterList => [], # String, not a regex | ||
| 1210 | # A non-delimiter is a string which the exit list should NOT contain. This helps the | ||
| 1211 | # Locator task to work out what is a list of exits, and what is not (e.g. 'is here', | ||
| 1212 | # 'are here') | ||
| 1213 | # Items in the list can be in any order (and are not sorted by the Locator task) | ||
| 1214 | briefExitNonDelimiterList => [], # String, not a regex | ||
| 1215 | # Alternatively, if the exits are single letters in a continuous string (e.g. NSEW), | ||
| 1216 | # set this flag to TRUE to split the string into 1-letter exits | ||
| 1217 | # NB If both delimiters and the flag are set, they are both used - delimiters are used | ||
| 1218 | # first to split the string into a list; then each item in the list is split into | ||
| 1219 | # characters | ||
| 1220 | briefExitSplitCharFlag => FALSE, | ||
| 1221 | # If the exit list is surrounded by markers, these lists contain those markers. Every | ||
| 1222 | # marker is a regex | ||
| 1223 | # If no markers are available on this world, set them both as empty lists. The markers | ||
| 1224 | # are checked in order, so longer markers should be listed before shorter ones. Left | ||
| 1225 | # markers are checked before right ones | ||
| 1226 | # Left marker regexes should start with '^', and right marker regexes should end with | ||
| 1227 | # '$'; if they don't, the markers will be removed from the middle of a list of exits | ||
| 1228 | # (which is probably not what you want) | ||
| 1229 | # For lines like 'Exits: none', create a left marker like | ||
| 1230 | # '^Exits: none\.*$' | ||
| 1231 | briefExitLeftMarkerList => [], | ||
| 1232 | briefExitRightMarkerList => [], | ||
| 1233 | |||
| 1234 | # Some worlds (especially MOOs) use an exit list like 'west (to Main Street), east (to | ||
| 1235 | # hotel), etc. The portions in brackets are not required by the Locator, so we need | ||
| 1236 | # to be able to extract them | ||
| 1237 | # An unlimited list of patterns; any matching portions of the exit are removed. In | ||
| 1238 | # addition, the first group substring (if any) is used to set GA::Obj::Exit->exitInfo | ||
| 1239 | # (otherwise, ->exitInfo remains set to 'undef') | ||
| 1240 | exitInfoPatternList => [], | ||
| 1241 | # An unlimited list of patterns; any matching portions of the exit are removed (in a | ||
| 1242 | # s/$pattern//gi operation) - case insensitive, because a 'North' exit will already | ||
| 1243 | # have become a 'north' exit, when the pattern match is done | ||
| 1244 | exitRemovePatternList => [], | ||
| 1245 | # On some worlds, the verbose list of exits indicates exit states by surrounding an exit | ||
| 1246 | # with symbols, e.g. 'Obvious exits : north, (east), west' | ||
| 1247 | # Some of these list IVs contain strings (not regexes) found at the beginning, middle | ||
| 1248 | # and/or end of a verbose exit which is open, closed, locked or impassable. | ||
| 1249 | # Other IVs contain strings (not regexes) that indicate the destination room is dark, | ||
| 1250 | # dangerous, or in some other state. | ||
| 1251 | # The final kind of exit state which is simple ignored; the colons (or whatever) are | ||
| 1252 | # removed, but GA::Obj::Exit->exitState is not modified | ||
| 1253 | # List of exit state strings (groups of 4) | ||
| 1254 | # [0] - The exit state represented, one of the values specified by | ||
| 1255 | # GA::Client->constExitStateHash ('normal', 'open', 'closed', 'locked', | ||
| 1256 | # 'secret', 'secret_open', 'secret_closed', 'secret_locked', 'impass', 'dark', | ||
| 1257 | # 'danger', 'emphasis', 'other'), or the value 'ignore', or a custom | ||
| 1258 | # string | ||
| 1259 | # - Exits which lack exit state strings (e.g. 'west') have the exit state | ||
| 1260 | # 'normal' by default, but in case some world uses exit state strings on ALL | ||
| 1261 | # exits, it's possible to specify 'normal' exit state strings here, too | ||
| 1262 | # - The exit's nominal direction (GA::Obj::Exit->dir) is the exit with its exit | ||
| 1263 | # state symbols removed (i.e. 'east'). If the exit state is a custom string, | ||
| 1264 | # then that custom string is used as the exit's assisted move. If the custom | ||
| 1265 | # string contains '@@@', that sequence is substituted for the exit with its | ||
| 1266 | # exit state symbols removed. In other words, for '(east)', if the custom | ||
| 1267 | # string is 'swim @@@', the exit's nominal direction is 'east' and the | ||
| 1268 | # assisted move is 'swim @@@' | ||
| 1269 | # - If the exit state is a custom string, the exit object's ->exitState IV is set | ||
| 1270 | # to normal (the exit object, once created, doesn't know about the custom | ||
| 1271 | # string in this IV) | ||
| 1272 | # - For an explanation of the other values, see the comments in GA::Obj::Exit->new | ||
| 1273 | # [1] - String appearing at the beginning of the exit (or an empty string), e.g. '(' | ||
| 1274 | # [2] - String appearing in the middle (or end) of the exit (or an empty string) | ||
| 1275 | # [3] - String appearing at the end of the exit (or an empty string), e.g. ')' | ||
| 1276 | # NB Axmud treats exits as case insensitive, so '(NORTH)' and '(north)' would both be | ||
| 1277 | # treated as an exit called 'north', with an exit state 'dark' | ||
| 1278 | # NB If items [2] and [3] are both non-empty strings, Axmud assumes that [2] occurs in | ||
| 1279 | # middle, and only [3] occurs at the end. If [2] is a non-empty string and [3] is an | ||
| 1280 | # empty string, Axmud assumes that [2] occurs either in the middle, or at the end | ||
| 1281 | # NB If items [1], [2] and [3] are all empty strings, Axmud will assume the exit state | ||
| 1282 | # can't be detected, and will class the exit as 'normal'. The default exit state is | ||
| 1283 | # already 'normal', so there's no need to add a group like this | ||
| 1284 | # NB The first matching set of exit state strings determine an exit's state, so a | ||
| 1285 | # duplicate set of exit state strings would never be checked | ||
| 1286 | exitStateStringList => [], | ||
| 1287 | # If exit state strings themselves contain exit delimiters (one of the strings in | ||
| 1288 | # $self->verboseExitDelimiterList and/or ->briefExitDelimiterList), exit parsing will | ||
| 1289 | # fail | ||
| 1290 | # For example, the exit delimiter appears in the exit state string meaning 'closed': | ||
| 1291 | # > Exits: north south [ west ] east | ||
| 1292 | # In that case, pattern(s) matching the whole exit, including its surrounding exit state | ||
| 1293 | # strings, can be added to this list (in the example above, we'd add the pattern | ||
| 1294 | # '\[\s\w+\s\]', and the exit delimiter list should contain the strings ' ' and ' ' | ||
| 1295 | # (two spaces, as well as one) | ||
| 1296 | # When splitting an exit list into separated exits, any portion of the text matching | ||
| 1297 | # one of these patterns is removed and treated as a single exit, before the text is | ||
| 1298 | # split into individual exits using exit delimiters | ||
| 1299 | exitStatePatternList => [], | ||
| 1300 | # As well as literal text, an exit state can be indicated by an Axmud colour tag (either | ||
| 1301 | # text or underlay). Style tags cannot be used to indicate exit states. If a bold | ||
| 1302 | # colour tag is required, it must be specified (the component object's | ||
| 1303 | # ->boldSensitiveFlag is not consulted) | ||
| 1304 | # If the colour tag applies to the first character of an exit, the corresponding exit | ||
| 1305 | # state applies to that exit | ||
| 1306 | # Hash in the form | ||
| 1307 | # $exitStateTagHash{tag} = exit_state | ||
| 1308 | # ...where 'tag' is any Axmud colour tag, and 'exit_state' is one of the values | ||
| 1309 | # described above | ||
| 1310 | exitStateTagHash => {}, | ||
| 1311 | # Some worlds use exit lists, with two or more exits represented as a single word; | ||
| 1312 | # for example, Lost Souls uses 'compass' to mean 'n w s e nw ne sw se' | ||
| 1313 | # Hash of exit aliases. The key is a pattern found in the world's exit list; the | ||
| 1314 | # corresponding value is a replacement string. The Locator task substitutes the | ||
| 1315 | # exit alias for the replacement string (in a normal regex substitution) | ||
| 1316 | # e.g. $exitAliasHash{compass} = 'n w s e nw ne sw se' | ||
| 1317 | exitAliasHash => {}, | ||
| 1318 | # An IV for worlds like Two Towers that might display the same 'east' exit twice, once | ||
| 1319 | # as a normal exit, and once as an exit for which the user must type 'swim east' or | ||
| 1320 | # something | ||
| 1321 | # If not specified, any duplicate exits are ignored. If specified, the exit's direction | ||
| 1322 | # is replaced by this string. The string must contain a '@@@' sequence, which is | ||
| 1323 | # substituted for the original exit | ||
| 1324 | # For example, use 'swim @@@' to convert a duplicate 'east' into 'swim east'. The | ||
| 1325 | # automapper will draw this as an unallocated exit; it's up to the user to decide, in | ||
| 1326 | # each room, how to draw the duplicate | ||
| 1327 | duplicateReplaceString => undef, | ||
| 1328 | |||
| 1329 | # List of patterns used in contents list which shouldn't be parsed (i.e. are not a part | ||
| 1330 | # of the object itself) | ||
| 1331 | contentPatternList => [], | ||
| 1332 | # Hash of special contents patterns, which matches any line in the 'verb_special', which | ||
| 1333 | # is normally adjacent to the 'verb_descrip' component, and which represents a part | ||
| 1334 | # of the room's contents, not part of its description. The corresponding value is | ||
| 1335 | # something that can be parsed by GA::Obj::WorldModel->parseObj. Hash in the form | ||
| 1336 | # $specialPatternHash{'There is a sign here you can read'} = 'A sign is here' | ||
| 1337 | # NB The 'verb_special' component uses the keys of this list in place of | ||
| 1338 | # the component's usual ->stopBeforeNoPatternList | ||
| 1339 | specialPatternHash => {}, | ||
| 1340 | |||
| 1341 | # Settings for 'room_cmd' component | ||
| 1342 | # If the commands in the 'room_cmd' component are separated by characters or strings, | ||
| 1343 | # the delimiters used. Must include whitespace, as appropriate (e.g. ' and ' / ', ' | ||
| 1344 | # / '.') | ||
| 1345 | # Items in the list should ideally be in order of length, longest first (but the | ||
| 1346 | # Locator task sorts them before using them, anyway) | ||
| 1347 | roomCmdDelimiterList => [], # String, not a regex | ||
| 1348 | # A non-delimiter is a string which the room command list should NOT contain. This helps | ||
| 1349 | # the Locator task to work out what is a list of room commands, and what is not | ||
| 1350 | # Items in the list can be in any order (and are not sorted by the Locator task) | ||
| 1351 | roomCmdNonDelimiterList => [], # String, not a regex | ||
| 1352 | # Alternatively, if the room commands are single letters in a continuous string (e.g. | ||
| 1353 | # HGP representing commands for harvesting, gathering and picking), set this flag to | ||
| 1354 | # TRUE to split the string into 1-letter room commands | ||
| 1355 | # NB If both delimiters and the flag are set, they are both used - delimiters are used | ||
| 1356 | # first to split the string into a list; then each item in the list is split into | ||
| 1357 | # characters | ||
| 1358 | roomCmdSplitCharFlag => FALSE, | ||
| 1359 | # If the room command list is surrounded by markers, these lists contain those markers. | ||
| 1360 | # Every marker is a regex | ||
| 1361 | # If no markers are available on this world, set them both as empty lists. The markers | ||
| 1362 | # are checked in order, so longer markers should be listed before shorter ones. Left | ||
| 1363 | # markers are checked before right ones | ||
| 1364 | # Left marker regexes should start with '^', and right marker regexes should end with | ||
| 1365 | # '$'; if they don't, the markers will be removed from the middle of a list of exits | ||
| 1366 | # (which is probably not what you want) | ||
| 1367 | # For lines like 'There are no commands in this room', create a left marker like | ||
| 1368 | # '^There are no commands in this room\.*$' | ||
| 1369 | roomCmdLeftMarkerList => [], | ||
| 1370 | roomCmdRightMarkerList => [], | ||
| 1371 | # A list of room commands for this world which should be ignored by ';roomcommand' | ||
| 1372 | roomCmdIgnoreList => [], | ||
| 1373 | |||
| 1374 | # For worlds with long(ish) room statements - especially those whose verbose | ||
| 1375 | # descriptions come after the anchor line - it's possible to define a pattern which | ||
| 1376 | # occurs after the anchor line, and whose absence means the whole room statement | ||
| 1377 | # hasn't been received yet (in which case, the Locator task waits a while) | ||
| 1378 | verboseFinalPattern => undef, | ||
| 1379 | shortFinalPattern => undef, | ||
| 1380 | briefFinalPattern => undef, | ||
| 1381 | |||
| 1382 | # For worlds using MXP's standard tag properties 'RoomName', 'RoomDesc', 'RoomExit' and | ||
| 1383 | # 'RoomNum', the Locator task is dumb, by default. It has to assume that the end of | ||
| 1384 | # the received text is the end of a statement; but if there has been a delay, a room | ||
| 1385 | # statement may be split between packets | ||
| 1386 | # These IVs can help, in that situation. For a group of tag properties representing a | ||
| 1387 | # single room statement, they represent the first/last tag property of the group. One | ||
| 1388 | # or both values can be set to the values 'RoomName', 'RoomDesc', 'RoomExit' and | ||
| 1389 | # 'RoomNum'. If both values are set to the same value, only that tag property is used | ||
| 1390 | # The tag property marking the start of the group. If the tag property marking the end | ||
| 1391 | # of the group is also set, the Locator Task will wait to receive it, before handling | ||
| 1392 | # the room statement. If not, the Locator Task will obey the usual rules (such as | ||
| 1393 | # waiting for a repeating tag property, or the end of the received text) | ||
| 1394 | # NB A new room statement cannot begin on the same line as the previous room statement | ||
| 1395 | # ended. If two sections of tagged text occur on the same line, they are combined | ||
| 1396 | mxpRoomTagStart => undef, | ||
| 1397 | # The tag property marking the end of the group. If the tag property marking the | ||
| 1398 | # beginning of the group is not set, the Locator task will check previous lines for | ||
| 1399 | # other tag properties belonging to the same group, stopping only when a previous | ||
| 1400 | # anchor line/duplicate tag property is found (max lines checked: 32) | ||
| 1401 | mxpRoomTagStop => undef, | ||
| 1402 | }; | ||
| 1403 | |||
| 1404 | # Bless the object into existence | ||
| 1405 | bless $self, $class; | ||
| 1406 | |||
| 1407 | # Import the standard hash of log preferences from the client | ||
| 1408 | $self->{logPrefHash} = {$axmud::CLIENT->constSessionLogPrefHash}; | ||
| 1409 | |||
| 1410 | return $self; | ||
| 1411 | } | ||
| 1412 | |||
| 1413 | sub clone { | ||
| 1414 | |||
| 1415 | # Creates a clone of an existing world profile | ||
| 1416 | # | ||
| 1417 | # Expected arguments | ||
| 1418 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 1419 | # $name - A unique string name for this profile (max 16 chars, containing | ||
| 1420 | # A-Za-z0-9_ - 1st char can't be number, non-Latin alphabets acceptable. | ||
| 1421 | # Must not exist as a key in the global hash of reserved names, | ||
| 1422 | # $axmud::CLIENT->constReservedHash) | ||
| 1423 | # | ||
| 1424 | # Return values | ||
| 1425 | # 'undef' on improper arguments or if $name is invalid | ||
| 1426 | # Blessed reference to the newly-created object on success | ||
| 1427 | |||
| 1428 | my ($self, $session, $name, $check) = @_; | ||
| 1429 | |||
| 1430 | # Check for improper arguments | ||
| 1431 | if (! defined $session || ! defined $name || defined $check) { | ||
| 1432 | |||
| 1433 | return $axmud::CLIENT->writeImproper($self->_objClass . '->clone', @_); | ||
| 1434 | } | ||
| 1435 | |||
| 1436 | # Check that $name is valid and not already in use by another profile | ||
| 1437 | if (! $axmud::CLIENT->nameCheck($name, 16)) { | ||
| 1438 | |||
| 1439 | return $axmud::CLIENT->writeError( | ||
| 1440 | 'Registry naming error: invalid name \'' . $name . '\'', | ||
| 1441 | $self->_objClass . '->clone', | ||
| 1442 | ); | ||
| 1443 | |||
| 1444 | } elsif ($axmud::CLIENT->ivExists('worldProfHash', $name)) { | ||
| 1445 | |||
| 1446 | return $axmud::CLIENT->writeError( | ||
| 1447 | 'Registry naming error: profile \'' . $name . '\' already exists', | ||
| 1448 | $self->_objClass . '->clone', | ||
| 1449 | ); | ||
| 1450 | } | ||
| 1451 | |||
| 1452 | # Setup | ||
| 1453 | my $clone = { | ||
| 1454 | _objName => $name, | ||
| 1455 | _objClass => $self->_objClass, | ||
| 1456 | _parentFile => $name, | ||
| 1457 | _parentWorld => undef, | ||
| 1458 | _privFlag => FALSE, # All IVs are public | ||
| 1459 | |||
| 1460 | # Standard profile IVs | ||
| 1461 | # -------------------- | ||
| 1462 | |||
| 1463 | name => $name, | ||
| 1464 | category => $self->category, | ||
| 1465 | parentWorld => undef, | ||
| 1466 | |||
| 1467 | initTaskHash => {}, # Set below | ||
| 1468 | initTaskOrderList => [], # Set below | ||
| 1469 | initTaskTotal => $self->initTaskTotal, | ||
| 1470 | initScriptHash => {$self->initScriptHash}, | ||
| 1471 | initScriptOrderList => [$self->initScriptOrderList], | ||
| 1472 | initMission => $self->initMission, | ||
| 1473 | initCmdList => [$self->initCmdList], | ||
| 1474 | |||
| 1475 | # (Although the clone hasn't actually been a current world, it does have the same cages | ||
| 1476 | # etc that the original had, so its ->setupCompleteFlag can be TRUE) | ||
| 1477 | setupCompleteFlag => $self->setupCompleteFlag, | ||
| 1478 | notepadList => [$self->notepadList], | ||
| 1479 | privateHash => {}, | ||
| 1480 | |||
| 1481 | # World profile IVs | ||
| 1482 | # ----------------- | ||
| 1483 | |||
| 1484 | noSaveFlag => FALSE, # Temp world profile can't be cloned | ||
| 1485 | connectHistoryList => [], | ||
| 1486 | |||
| 1487 | telnetOverrideHash => {}, | ||
| 1488 | mxpOverrideHash => {}, | ||
| 1489 | termOverrideHash => {}, | ||
| 1490 | sigilOverrideHash => {}, | ||
| 1491 | |||
| 1492 | profHash => {}, | ||
| 1493 | passwordHash => {}, # Passwords are not cloned | ||
| 1494 | newPasswordHash => {}, | ||
| 1495 | accountHash => {}, # Account names are not cloned | ||
| 1496 | newAccountHash => {}, | ||
| 1497 | |||
| 1498 | protocol => $self->protocol, | ||
| 1499 | |||
| 1500 | dns => $self->dns, | ||
| 1501 | ipv4 => $self->ipv4, | ||
| 1502 | ipv6 => $self->ipv6, | ||
| 1503 | port => $self->port, | ||
| 1504 | sshUserName => undef, # SSH user/password not cloned | ||
| 1505 | sshPassword => undef, | ||
| 1506 | sshPortFlag => $self->sshPortFlag, | ||
| 1507 | |||
| 1508 | lastConnectDate => undef, | ||
| 1509 | lastConnectTime => undef, | ||
| 1510 | numberConnects => 0, | ||
| 1511 | lastConnectChar => undef, | ||
| 1512 | |||
| 1513 | longName => $self->longName, | ||
| 1514 | adultFlag => $self->adultFlag, | ||
| 1515 | worldURL => $self->worldURL, | ||
| 1516 | referURL => $self->referURL, | ||
| 1517 | worldDescrip => $self->worldDescrip, | ||
| 1518 | worldHint => $self->worldHint, | ||
| 1519 | worldCharSet => $self->worldCharSet, | ||
| 1520 | |||
| 1521 | termType => $self->termType, | ||
| 1522 | columns => $self->columns, | ||
| 1523 | rows => $self->rows, | ||
| 1524 | sendSizeInfoFlag => $self->sendSizeInfoFlag, | ||
| 1525 | |||
| 1526 | msspGenericValueHash => {}, # MSSP data not cloned | ||
| 1527 | msspCustomValueHash => {}, # MSSP data not cloned | ||
| 1528 | |||
| 1529 | loginMode => $self->loginMode, | ||
| 1530 | loginCmdList => [$self->loginCmdList], | ||
| 1531 | loginObjName => $self->loginObjName, | ||
| 1532 | loginConnectPatternList => [$self->loginConnectPatternList], | ||
| 1533 | loginSuccessPatternList => [$self->loginSuccessPatternList], | ||
| 1534 | loginAccountMode => $self->loginAccountMode, | ||
| 1535 | loginSpecialList => [$self->loginSpecialList], | ||
| 1536 | |||
| 1537 | autoQuitMode => $self->autoQuitMode, | ||
| 1538 | autoQuitCmdList => [$self->autoQuitCmdList], | ||
| 1539 | autoQuitObjName => $self->autoQuitObjName, | ||
| 1540 | |||
| 1541 | autoSeparateCmdFlag => $self->autoSeparateCmdFlag, | ||
| 1542 | excessCmdLimit => $self->excessCmdLimit, | ||
| 1543 | excessCmdDelay => $self->excessCmdDelay, | ||
| 1544 | lifeStatusOverrideFlag => $self->lifeStatusOverrideFlag, | ||
| 1545 | |||
| 1546 | cmdPromptPatternList => [$self->cmdPromptPatternList], | ||
| 1547 | suppressEmptyLineCount => $self->suppressEmptyLineCount, | ||
| 1548 | suppressBeforeLoginFlag => $self->suppressBeforeLoginFlag, | ||
| 1549 | |||
| 1550 | dict => undef, # Set by ';cloneworld' | ||
| 1551 | collectUnknownWordFlag => $self->collectUnknownWordFlag, | ||
| 1552 | collectContentsFlag => $self->collectContentsFlag, | ||
| 1553 | numberedObjFlag => $self->numberedObjFlag, | ||
| 1554 | multiplePattern => $self->multiplePattern, | ||
| 1555 | |||
| 1556 | logPrefHash => {$self->logPrefHash}, | ||
| 1557 | |||
| 1558 | charAgeUnit => $self->charAgeUnit, | ||
| 1559 | weightUnit => $self->weightUnit, | ||
| 1560 | weightUnitStringList => [$self->weightUnitStringList], | ||
| 1561 | |||
| 1562 | darkRoomPatternList => [$self->darkRoomPatternList], | ||
| 1563 | failExitPatternList => [$self->failExitPatternList], | ||
| 1564 | doorPatternList => [$self->doorPatternList], | ||
| 1565 | lockedPatternList => [$self->lockedPatternList], | ||
| 1566 | involuntaryExitPatternList => [$self->involuntaryExitPatternList], | ||
| 1567 | unspecifiedRoomPatternList => [$self->unspecifiedRoomPatternList], | ||
| 1568 | followPatternList => [$self->followPatternList], | ||
| 1569 | followAnchorPatternList => [$self->followAnchorPatternList], | ||
| 1570 | transientExitPatternList => [$self->transientExitPatternList], | ||
| 1571 | |||
| 1572 | statusFormatList => [$self->statusFormatList], | ||
| 1573 | gaugeFormatList => [$self->gaugeFormatList], | ||
| 1574 | msdpStatusVarHash => {$self->msdpStatusVarHash}, | ||
| 1575 | mxpStatusVarHash => {$self->mxpStatusVarHash}, | ||
| 1576 | barPatternList => [$self->barPatternList], | ||
| 1577 | groupPatternList => [$self->groupPatternList], | ||
| 1578 | affectPatternList => [$self->affectPatternList], | ||
| 1579 | statPatternList => [$self->statPatternList], | ||
| 1580 | agePatternList => [$self->agePatternList], | ||
| 1581 | timePatternList => [$self->timePatternList], | ||
| 1582 | statusIgnorePatternList => [$self->statusIgnorePatternList], | ||
| 1583 | |||
| 1584 | deathPatternList => [$self->deathPatternList], | ||
| 1585 | resurrectPatternList => [$self->resurrectPatternList], | ||
| 1586 | passedOutPatternList => [$self->passedOutPatternList], | ||
| 1587 | comeAroundPatternList => [$self->comeAroundPatternList], | ||
| 1588 | fallAsleepPatternList => [$self->fallAsleepPatternList], | ||
| 1589 | wakeUpPatternList => [$self->wakeUpPatternList], | ||
| 1590 | questCompletePatternList => [$self->questCompletePatternList], | ||
| 1591 | |||
| 1592 | inventoryPatternList => [$self->inventoryPatternList], | ||
| 1593 | inventoryIgnorePatternList => [$self->inventoryIgnorePatternList], | ||
| 1594 | inventoryDiscardPatternList => [$self->inventoryDiscardPatternList], | ||
| 1595 | inventorySplitPatternList => [$self->inventorySplitPatternList], | ||
| 1596 | inventoryMode => $self->inventoryMode, | ||
| 1597 | |||
| 1598 | conditionPatternList => [$self->conditionPatternList], | ||
| 1599 | conditionIgnorePatternList => [$self->conditionIgnorePatternList], | ||
| 1600 | |||
| 1601 | fightStartedPatternList => [$self->fightStartedPatternList], | ||
| 1602 | cannotFindTargetPatternList => [$self->cannotFindTargetPatternList], | ||
| 1603 | targetAlreadyDeadPatternList | ||
| 1604 | => [$self->targetAlreadyDeadPatternList], | ||
| 1605 | targetKilledPatternList => [$self->targetKilledPatternList], | ||
| 1606 | fightDefeatPatternList => [$self->fightDefeatPatternList], | ||
| 1607 | wimpyEngagedPatternList => [$self->wimpyEngagedPatternList], | ||
| 1608 | noFightStartedPatternList => [$self->noFightStartedPatternList], | ||
| 1609 | noCannotFindTargetPatternList | ||
| 1610 | => [$self->noCannotFindTargetPatternList], | ||
| 1611 | noTargetAlreadyDeadPatternList | ||
| 1612 | => [$self->noTargetAlreadyDeadPatternList], | ||
| 1613 | noTargetKilledPatternList => [$self->noTargetKilledPatternList], | ||
| 1614 | noFightDefeatPatternList => [$self->noFightDefeatPatternList], | ||
| 1615 | noWimpyEngagedPatternList => [$self->noWimpyEngagedPatternList], | ||
| 1616 | |||
| 1617 | interactionStartedPatternList | ||
| 1618 | => [$self->interactionStartedPatternList], | ||
| 1619 | cannotInteractPatternList => [$self->cannotInteractPatternList], | ||
| 1620 | interactionSuccessPatternList | ||
| 1621 | => [$self->interactionSuccessPatternList], | ||
| 1622 | interactionFailPatternList => [$self->interactionFailPatternList], | ||
| 1623 | interactionFightPatternList => [$self->interactionFightPatternList], | ||
| 1624 | interactionDisasterPatternList | ||
| 1625 | => [$self->interactionDisasterPatternList], | ||
| 1626 | noInteractionStartedPatternList | ||
| 1627 | => [$self->noInteractionStartedPatternList], | ||
| 1628 | noCannotInteractPatternList => [$self->noCannotInteractPatternList], | ||
| 1629 | noInteractionSuccessPatternList | ||
| 1630 | => [$self->noInteractionSuccessPatternList], | ||
| 1631 | noInteractionFailPatternList | ||
| 1632 | => [$self->noInteractionFailPatternList], | ||
| 1633 | noInteractionFightPatternList | ||
| 1634 | => [$self->noInteractionFightPatternList], | ||
| 1635 | noInteractionDisasterPatternList | ||
| 1636 | => [$self->noInteractionDisasterPatternList], | ||
| 1637 | |||
| 1638 | targetLeavesPatternList => [$self->targetLeavesPatternList], | ||
| 1639 | targetArrivesPatternList => [$self->targetArrivesPatternList], | ||
| 1640 | noTargetLeavesPatternList => [$self->noTargetLeavesPatternList], | ||
| 1641 | noTargetArrivesPatternList => [$self->noTargetArrivesPatternList], | ||
| 1642 | |||
| 1643 | noFightsRoomPatternList => [$self->noFightsRoomPatternList], | ||
| 1644 | noInteractionsRoomPatternList | ||
| 1645 | => [$self->noInteractionsRoomPatternList], | ||
| 1646 | |||
| 1647 | getSuccessPatternList => [$self->getSuccessPatternList], | ||
| 1648 | getHeavyPatternList => [$self->getHeavyPatternList], | ||
| 1649 | getFailPatternList => [$self->getFailPatternList], | ||
| 1650 | dropSuccessPatternList => [$self->dropSuccessPatternList], | ||
| 1651 | dropForbidPatternList => [$self->dropForbidPatternList], | ||
| 1652 | dropFailPatternList => [$self->dropFailPatternList], | ||
| 1653 | |||
| 1654 | buySuccessPatternList => [$self->buySuccessPatternList], | ||
| 1655 | buyPartialPatternList => [$self->buyPartialPatternList], | ||
| 1656 | buyFailPatternList => [$self->buyFailPatternList], | ||
| 1657 | sellSuccessPatternList => [$self->sellSuccessPatternList], | ||
| 1658 | sellPartialPatternList => [$self->sellPartialPatternList], | ||
| 1659 | sellFailPatternList => [$self->sellFailPatternList], | ||
| 1660 | |||
| 1661 | advanceSuccessPatternList => [$self->advanceSuccessPatternList], | ||
| 1662 | advanceFailPatternList => [$self->advanceFailPatternList], | ||
| 1663 | |||
| 1664 | channelList => [$self->channelList], | ||
| 1665 | noChannelList => [$self->noChannelList], | ||
| 1666 | |||
| 1667 | currencyHash => {$self->currencyHash}, | ||
| 1668 | standardCurrencyUnit => $self->standardCurrencyUnit, | ||
| 1669 | currencyRounding => $self->currencyRounding, | ||
| 1670 | |||
| 1671 | missionHash => {$self->missionHash}, | ||
| 1672 | |||
| 1673 | questHash => {$self->questHash}, | ||
| 1674 | questCount => $self->questCount, | ||
| 1675 | questPointCount => $self->questPointCount, | ||
| 1676 | questXPCount => $self->questXPCount, | ||
| 1677 | questCashCount => $self->questCashCount, | ||
| 1678 | |||
| 1679 | statHash => {$self->statHash}, | ||
| 1680 | statOrderList => [$self->statOrderList], | ||
| 1681 | |||
| 1682 | statusCmdHash => {$self->statusCmdHash}, | ||
| 1683 | inventoryCmdHash => {$self->inventoryCmdHash}, | ||
| 1684 | |||
| 1685 | componentHash => {}, # Set below | ||
| 1686 | verboseComponentList => [$self->verboseComponentList], | ||
| 1687 | shortComponentList => [$self->shortComponentList], | ||
| 1688 | briefComponentList => [$self->briefComponentList], | ||
| 1689 | |||
| 1690 | basicMappingFlag => $self->basicMappingFlag, | ||
| 1691 | notAnchorPatternList => [$self->notAnchorPatternList], | ||
| 1692 | |||
| 1693 | verboseAnchorPatternList => [$self->verboseAnchorPatternList], | ||
| 1694 | verboseAnchorOffset => $self->verboseAnchorOffset, | ||
| 1695 | verboseAnchorCheckList => [$self->verboseAnchorCheckList], | ||
| 1696 | shortAnchorPatternList => [$self->shortAnchorPatternList], | ||
| 1697 | shortAnchorOffset => $self->shortAnchorOffset, | ||
| 1698 | shortAnchorCheckList => [$self->shortAnchorCheckList], | ||
| 1699 | briefAnchorPatternList => [$self->briefAnchorPatternList], | ||
| 1700 | briefAnchorOffset => $self->briefAnchorOffset, | ||
| 1701 | briefAnchorCheckList => [$self->briefAnchorCheckList], | ||
| 1702 | |||
| 1703 | verboseExitDelimiterList => [$self->verboseExitDelimiterList], | ||
| 1704 | verboseExitNonDelimiterList => [$self->verboseExitNonDelimiterList], | ||
| 1705 | verboseExitSplitCharFlag => $self->verboseExitSplitCharFlag, | ||
| 1706 | verboseExitLeftMarkerList => [$self->verboseExitLeftMarkerList], | ||
| 1707 | verboseExitRightMarkerList => [$self->verboseExitRightMarkerList], | ||
| 1708 | |||
| 1709 | briefExitDelimiterList => [$self->briefExitDelimiterList], | ||
| 1710 | briefExitNonDelimiterList => [$self->briefExitNonDelimiterList], | ||
| 1711 | briefExitSplitCharFlag => $self->briefExitSplitCharFlag, | ||
| 1712 | briefExitLeftMarkerList => [$self->briefExitLeftMarkerList], | ||
| 1713 | briefExitRightMarkerList => [$self->briefExitRightMarkerList], | ||
| 1714 | |||
| 1715 | exitInfoPatternList => [$self->exitInfoPatternList], | ||
| 1716 | exitRemovePatternList => [$self->exitRemovePatternList], | ||
| 1717 | exitStateStringList => [$self->exitStateStringList], | ||
| 1718 | exitStatePatternList => [$self->exitStatePatternList], | ||
| 1719 | exitStateTagHash => {$self->exitStateTagHash}, | ||
| 1720 | exitAliasHash => {$self->exitAliasHash}, | ||
| 1721 | duplicateReplaceString => $self->duplicateReplaceString, | ||
| 1722 | |||
| 1723 | contentPatternList => [$self->contentPatternList], | ||
| 1724 | specialPatternHash => {$self->specialPatternHash}, | ||
| 1725 | |||
| 1726 | roomCmdDelimiterList => [$self->roomCmdDelimiterList], | ||
| 1727 | roomCmdNonDelimiterList => [$self->roomCmdNonDelimiterList], | ||
| 1728 | roomCmdSplitCharFlag => $self->roomCmdSplitCharFlag, | ||
| 1729 | roomCmdLeftMarkerList => [$self->roomCmdLeftMarkerList], | ||
| 1730 | roomCmdRightMarkerList => [$self->roomCmdRightMarkerList], | ||
| 1731 | roomCmdIgnoreList => [$self->roomCmdIgnoreList], | ||
| 1732 | |||
| 1733 | verboseFinalPattern => $self->verboseFinalPattern, | ||
| 1734 | shortFinalPattern => $self->shortFinalPattern, | ||
| 1735 | briefFinalPattern => $self->briefFinalPattern, | ||
| 1736 | |||
| 1737 | mxpRoomTagStart => $self->mxpRoomTagStart, | ||
| 1738 | mxpRoomTagStop => $self->mxpRoomTagStop, | ||
| 1739 | }; | ||
| 1740 | |||
| 1741 | # Bless the cloned object into existence | ||
| 1742 | bless $clone, $self->_objClass; | ||
| 1743 | |||
| 1744 | # Also need to clone everything in the initial tasklist... | ||
| 1745 | $clone->cloneInitTaskList($self); | ||
| 1746 | # ...and the room statement component list | ||
| 1747 | $clone->cloneComponentList($session, $self); | ||
| 1748 | |||
| 1749 | return $clone; | ||
| 1750 | } | ||
| 1751 | |||
| 1752 | ################## | ||
| 1753 | # Methods | ||
| 1754 | |||
| 1755 | sub cloneComponentList { | ||
| 1756 | |||
| 1757 | # Called by $self->clone immediately after cloning this profile from another | ||
| 1758 | # Clones room statement component objects in the original profile's ->componentHash | ||
| 1759 | # | ||
| 1760 | # Expected arguments | ||
| 1761 | # $session - The calling function's GA::Session | ||
| 1762 | # $original - The original profile object, from which this object was cloned | ||
| 1763 | # | ||
| 1764 | # Return values | ||
| 1765 | # 'undef' on improper arguments | ||
| 1766 | # 1 otherwise | ||
| 1767 | |||
| 1768 | my ($self, $session, $original, $check) = @_; | ||
| 1769 | |||
| 1770 | # Local variables | ||
| 1771 | my (%hash, %newHash); | ||
| 1772 | |||
| 1773 | # Check for improper arguments | ||
| 1774 | if (! defined $session || ! defined $original || defined $check) { | ||
| 1775 | |||
| 1776 | return $axmud::CLIENT->writeImproper($self->_objClass . '->new', @_); | ||
| 1777 | } | ||
| 1778 | |||
| 1779 | # Import the hash of component objects | ||
| 1780 | %hash = $original->componentHash; | ||
| 1781 | foreach my $name (keys %hash) { | ||
| 1782 | |||
| 1783 | my ($oldObj, $newObj); | ||
| 1784 | |||
| 1785 | $oldObj = $hash{$name}; | ||
| 1786 | $newObj = $oldObj->clone($session, $self, $oldObj->name, $oldObj->type); | ||
| 1787 | if ($newObj) { | ||
| 1788 | |||
| 1789 | $newHash{$newObj->name} = $newObj; | ||
| 1790 | } | ||
| 1791 | } | ||
| 1792 | |||
| 1793 | # Update IVs (the cloned profile has no corresponding file object yet, so we can't use | ||
| 1794 | # ->ivPoke); | ||
| 1795 | $self->{componentHash} = \%newHash; | ||
| 1796 | |||
| 1797 | return 1; | ||
| 1798 | } | ||
| 1799 | |||
| 1800 | sub findProfiles { | ||
| 1801 | |||
| 1802 | # Called by GA::Cmd::ListProfile->do, or by any other code | ||
| 1803 | # $self->profHash contains a list of profiles associated with this world profile | ||
| 1804 | # Returns a list of associated profile names matching a specified category (which can be | ||
| 1805 | # 'world', 'guild', 'race', 'char' or any custom profile category) | ||
| 1806 | # | ||
| 1807 | # Expected arguments | ||
| 1808 | # (none besides $self) | ||
| 1809 | # | ||
| 1810 | # Optional arguments | ||
| 1811 | # $category - A category of profile (one of the elements of | ||
| 1812 | # GA::Client->profPriorityList). If 'undef', returns a list of names of | ||
| 1813 | # profiles whose ->category isn't 'world', 'guild', 'race' or 'char' | ||
| 1814 | # | ||
| 1815 | # Return values | ||
| 1816 | # An empty list on improper arguments | ||
| 1817 | # Otherwise, returns a list of names of the profiles whose ->category IV matches | ||
| 1818 | # $category (may be an empty list) | ||
| 1819 | |||
| 1820 | my ($self, $category, $check) = @_; | ||
| 1821 | |||
| 1822 | # Local variables | ||
| 1823 | my ( | ||
| 1824 | @emptyList, @list, | ||
| 1825 | %hash, | ||
| 1826 | ); | ||
| 1827 | |||
| 1828 | # Check for improper arguments | ||
| 1829 | if (defined $check) { | ||
| 1830 | |||
| 1831 | return $axmud::CLIENT->writeImproper($self->_objClass . '->findProfiles', @_); | ||
| 1832 | } | ||
| 1833 | |||
| 1834 | if ($category) { | ||
| 1835 | |||
| 1836 | # Find profiles matching the category | ||
| 1837 | foreach my $profName ($self->ivKeys('profHash')) { | ||
| 1838 | |||
| 1839 | my $thisCategory = $self->ivShow('profHash', $profName); | ||
| 1840 | |||
| 1841 | if ($thisCategory eq $category) { | ||
| 1842 | |||
| 1843 | push (@list, $profName); | ||
| 1844 | } | ||
| 1845 | } | ||
| 1846 | |||
| 1847 | } else { | ||
| 1848 | |||
| 1849 | # Find profiles using a custom category (i.e. profiles whose category isn't one of the | ||
| 1850 | # keys in the following hash) | ||
| 1851 | %hash = ( | ||
| 1852 | 'world' => undef, | ||
| 1853 | 'guild' => undef, | ||
| 1854 | 'race' => undef, | ||
| 1855 | 'char' => undef, | ||
| 1856 | ); | ||
| 1857 | |||
| 1858 | foreach my $profName ($self->ivKeys('profHash')) { | ||
| 1859 | |||
| 1860 | my $thisCategory = $self->ivShow('profHash', $profName); | ||
| 1861 | |||
| 1862 | if (! exists $hash{$thisCategory}) { | ||
| 1863 | |||
| 1864 | push (@list, $profName); | ||
| 1865 | } | ||
| 1866 | } | ||
| 1867 | } | ||
| 1868 | |||
| 1869 | return @list; | ||
| 1870 | } | ||
| 1871 | |||
| 1872 | sub getConnectDetails { | ||
| 1873 | |||
| 1874 | # Called by GA::Client->start, GA::Cmd::Connect->do, Reconnect->do, etc or by any other | ||
| 1875 | # function | ||
| 1876 | # Fetches the connection details specified by this world profile, just before a call to | ||
| 1877 | # GA::Session->new | ||
| 1878 | # | ||
| 1879 | # Expected arguments | ||
| 1880 | # (none besides $self) | ||
| 1881 | # | ||
| 1882 | # Optional arguments | ||
| 1883 | # $char - The name of the character profile being used (set to 'undef' if unknown) | ||
| 1884 | # | ||
| 1885 | # Return values | ||
| 1886 | # An empty list on improper arguments | ||
| 1887 | # Otherwise, returns a list in the form: | ||
| 1888 | # (host_address, host_port, char_name, char_password, char_account) | ||
| 1889 | # If 'host_address' and 'host_port' are not specified by this profile, emergency default | ||
| 1890 | # values are returned (better to return an invalid string than to return 'undef') | ||
| 1891 | # If $char is not specified, 'char_name' will be 'undef' | ||
| 1892 | # If $char is not specified or no password for the character can be found, | ||
| 1893 | # 'char_password' will be undef | ||
| 1894 | # If $char is not specified or no associated account for the character can be found, | ||
| 1895 | # 'char_account' will be undef | ||
| 1896 | |||
| 1897 | my ($self, $char, $check) = @_; | ||
| 1898 | |||
| 1899 | # Local variables | ||
| 1900 | my ( | ||
| 1901 | $host, $port, $pass, $account, | ||
| 1902 | @emptyList, | ||
| 1903 | ); | ||
| 1904 | |||
| 1905 | # Check for improper arguments | ||
| 1906 | if (defined $check) { | ||
| 1907 | |||
| 1908 | $axmud::CLIENT->writeImproper($self->_objClass . '->getConnectDetails', @_); | ||
| 1909 | return @emptyList, | ||
| 1910 | } | ||
| 1911 | |||
| 1912 | # Prefer IPV6, if specified. Otherwise, prefer 'deathmud.com' over '101.111.121.131' | ||
| 1913 | if ($self->ipv6) { | ||
| 1914 | $host = $self->ipv6; | ||
| 1915 | } elsif ($self->dns) { | ||
| 1916 | $host = $self->dns; | ||
| 1917 | } elsif ($self->ipv4) { | ||
| 1918 | $host = $self->ipv4; | ||
| 1919 | } else { | ||
| 1920 | $host = '127.0.0.1'; # Emergency default value | ||
| 1921 | } | ||
| 1922 | |||
| 1923 | if ($self->port) { | ||
| 1924 | $port = $self->port; | ||
| 1925 | } else { | ||
| 1926 | $port = 23; # Emergency default value | ||
| 1927 | } | ||
| 1928 | |||
| 1929 | if ($char) { | ||
| 1930 | |||
| 1931 | if ($self->ivExists('passwordHash', $char)) { | ||
| 1932 | |||
| 1933 | $pass = $self->ivShow('passwordHash', $char); | ||
| 1934 | |||
| 1935 | } elsif ($self->ivExists('newPasswordHash', $char)) { | ||
| 1936 | |||
| 1937 | # Character profile not created yet, but we know the password | ||
| 1938 | $pass = $self->ivShow('newPasswordHash', $char); | ||
| 1939 | } | ||
| 1940 | |||
| 1941 | if ($self->ivExists('accountHash', $char)) { | ||
| 1942 | |||
| 1943 | $account = $self->ivShow('accountHash', $char); | ||
| 1944 | |||
| 1945 | } elsif ($self->ivExists('newAccountHash', $char)) { | ||
| 1946 | |||
| 1947 | # Character profile not created yet, but we know the password | ||
| 1948 | $account = $self->ivShow('newAccountHash', $char); | ||
| 1949 | } | ||
| 1950 | } | ||
| 1951 | |||
| 1952 | return ($host, $port, $char, $pass, $account); | ||
| 1953 | } | ||
| 1954 | |||
| 1955 | sub updateQuestStats { | ||
| 1956 | |||
| 1957 | # Called by anything, any time a quest stored by this profile changes | ||
| 1958 | # Re-calculates this profile's running totals | ||
| 1959 | # | ||
| 1960 | # Expected arguements | ||
| 1961 | # $session - The calling function's GA::Session | ||
| 1962 | # | ||
| 1963 | # Return values | ||
| 1964 | # 'undef' on improper arguments | ||
| 1965 | # 1 otherwise | ||
| 1966 | |||
| 1967 | my ($self, $session, $check) = @_; | ||
| 1968 | |||
| 1969 | # Local variables | ||
| 1970 | my ($questCount, $pointCount, $xpCount, $cashCount); | ||
| 1971 | |||
| 1972 | # Check for improper arguments | ||
| 1973 | if (! defined $session || defined $check) { | ||
| 1974 | |||
| 1975 | return $axmud::CLIENT->writeImproper($self->_objClass . '->updateQuestStats', @_); | ||
| 1976 | } | ||
| 1977 | |||
| 1978 | # Go through each quest registered in $self->questHash, updating the | ||
| 1979 | # running totals wherever possible | ||
| 1980 | $questCount = 0; | ||
| 1981 | $pointCount = 0; | ||
| 1982 | $xpCount = 0; | ||
| 1983 | $cashCount = 0; | ||
| 1984 | foreach my $questObj ($self->ivValues('questHash')) { | ||
| 1985 | |||
| 1986 | $questCount++; | ||
| 1987 | |||
| 1988 | if (defined $questObj->questPoints) { | ||
| 1989 | |||
| 1990 | $pointCount += $questObj->questPoints; | ||
| 1991 | } | ||
| 1992 | |||
| 1993 | if (defined $questObj->questXP) { | ||
| 1994 | |||
| 1995 | $xpCount += $questObj->questXP; | ||
| 1996 | } | ||
| 1997 | |||
| 1998 | if (defined $questObj->questCash) { | ||
| 1999 | |||
| 2000 | $cashCount += $questObj->questCash; | ||
| 2001 | } | ||
| 2002 | } | ||
| 2003 | |||
| 2004 | # Save the totals | ||
| 2005 | $self->ivPoke('questCount', $questCount); | ||
| 2006 | $self->ivPoke('questPointCount', $pointCount); | ||
| 2007 | $self->ivPoke('questXPCount', $xpCount); | ||
| 2008 | $self->ivPoke('questCashCount', $cashCount); | ||
| 2009 | |||
| 2010 | # Now go through each character profile, and update its quest stats, too | ||
| 2011 | foreach my $profObj ($session->ivValues('profHash')) { | ||
| 2012 | |||
| 2013 | if ($profObj->category eq 'char') { | ||
| 2014 | |||
| 2015 | $profObj->updateQuestStats($session); | ||
| 2016 | } | ||
| 2017 | } | ||
| 2018 | |||
| 2019 | return 1; | ||
| 2020 | } | ||
| 2021 | |||
| 2022 | sub mergeData { | ||
| 2023 | |||
| 2024 | # Called by GA::Cmd::UpdateWorld->do | ||
| 2025 | # Merges data from an importable world profile (which hasn't been added to the list of | ||
| 2026 | # profiles in memory, or in any saved files) into this profile, as a way of updating this | ||
| 2027 | # profile | ||
| 2028 | # | ||
| 2029 | # Expected arguments | ||
| 2030 | # $otherObj - A GA::Profile::World which has been read from an importable file | ||
| 2031 | # $version - The Axmud version that saved the importable file | ||
| 2032 | # | ||
| 2033 | # Return values | ||
| 2034 | # 'undef' on improper arguments | ||
| 2035 | # 1 otherwise | ||
| 2036 | |||
| 2037 | my ($self, $otherObj, $version, $check) = @_; | ||
| 2038 | |||
| 2039 | # Local variables | ||
| 2040 | my $fileObj; | ||
| 2041 | |||
| 2042 | # Check for improper arguments | ||
| 2043 | if (! defined $otherObj || ! defined $version || defined $check) { | ||
| 2044 | |||
| 2045 | return $axmud::CLIENT->writeImproper($self->_objClass . '->mergeData', @_); | ||
| 2046 | } | ||
| 2047 | |||
| 2048 | # (Don't merge ->name, ->category or ->parentWorld) | ||
| 2049 | |||
| 2050 | # (Don't merge any initial tasks, scripts, missions or commands) | ||
| 2051 | |||
| 2052 | # (Don't merge ->setupCompleteFlag, ->notepadList or ->privateHash) | ||
| 2053 | |||
| 2054 | # (Don't merge ->noSaveFlag, ->connectHistoryList, ->telnetOverrideHash, ->mxpOverrideHash, | ||
| 2055 | # ->termOverrideHash, ->sigilOverrideHash, ->profHash, ->passwordHash, ->newPasswordHash, | ||
| 2056 | # ->accountHash or ->newAccountHash) | ||
| 2057 | |||
| 2058 | # (Don't merge ->protocol) | ||
| 2059 | |||
| 2060 | # Merge connection details, but don't merge SSH details | ||
| 2061 | $self->mergeScalar('dns', $otherObj); | ||
| 2062 | $self->mergeScalar('ipv4', $otherObj); | ||
| 2063 | $self->mergeScalar('ipv6', $otherObj); | ||
| 2064 | $self->mergeScalar('port', $otherObj); | ||
| 2065 | |||
| 2066 | # (Don't merge previous connection details) | ||
| 2067 | |||
| 2068 | # Don't merge the long name/description, but do merge URLs | ||
| 2069 | $self->mergeScalar('worldURL', $otherObj); | ||
| 2070 | $self->mergeScalar('referURL', $otherObj); | ||
| 2071 | |||
| 2072 | # (Don't merge termtype or terminal size) | ||
| 2073 | |||
| 2074 | # Don't merge login details, but do add any login success patterns | ||
| 2075 | $self->mergeList('loginConnectPatternList', $otherObj); | ||
| 2076 | $self->mergeList('loginSuccessPatternList', $otherObj); | ||
| 2077 | $self->ivPoke('loginAccountMode', $otherObj->loginAccountMode); | ||
| 2078 | $self->mergeList('loginSpecialList', $otherObj); | ||
| 2079 | |||
| 2080 | # (Don't merge auto-quit details) | ||
| 2081 | |||
| 2082 | # Merge the command and life status IVs | ||
| 2083 | $self->ivPoke('autoSeparateCmdFlag', $otherObj->autoSeparateCmdFlag); | ||
| 2084 | $self->mergeScalar('excessCmdLimit', $otherObj); | ||
| 2085 | $self->mergeScalar('excessCmdDelay', $otherObj); | ||
| 2086 | $self->ivPoke('lifeStatusOverrideFlag', $otherObj->lifeStatusOverrideFlag); | ||
| 2087 | |||
| 2088 | # Merge command prompt patterns but don't merge empty line suppression IVs | ||
| 2089 | $self->mergeList('cmdPromptPatternList', $otherObj); | ||
| 2090 | |||
| 2091 | # Don't merge the dictionary IVs but do merge the numbered objects flag | ||
| 2092 | $self->ivPoke('numberedObjFlag', $otherObj->numberedObjFlag); | ||
| 2093 | $self->ivPoke('multiplePattern', $otherObj->multiplePattern); | ||
| 2094 | |||
| 2095 | # (Don't merge logging preferences) | ||
| 2096 | |||
| 2097 | # Merge age/weight IVs | ||
| 2098 | $self->mergeScalar('charAgeUnit', $otherObj); | ||
| 2099 | $self->mergeScalar('weightUnit', $otherObj); | ||
| 2100 | $self->mergeList('weightUnitStringList', $otherObj); | ||
| 2101 | |||
| 2102 | # Merge room patterns | ||
| 2103 | $self->mergeList('darkRoomPatternList', $otherObj); | ||
| 2104 | $self->mergeList('failExitPatternList', $otherObj); | ||
| 2105 | $self->mergeList('doorPatternList', $otherObj); | ||
| 2106 | $self->mergeList('lockedPatternList', $otherObj); | ||
| 2107 | $self->mergeList('involuntaryExitPatternList', $otherObj); | ||
| 2108 | $self->mergeList('unspecifiedRoomPatternList', $otherObj); | ||
| 2109 | $self->mergeList('followPatternList', $otherObj); | ||
| 2110 | $self->mergeList('followAnchorPatternList', $otherObj); | ||
| 2111 | $self->mergeList('transientExitPatternList', $otherObj); | ||
| 2112 | |||
| 2113 | # (Don't merge the Status task's display format list - let the user keep their changes) | ||
| 2114 | |||
| 2115 | # Merge Status task patterns | ||
| 2116 | $self->mergeHash('msdpStatusVarHash', $otherObj); | ||
| 2117 | $self->mergeHash('mxpStatusVarHash', $otherObj); | ||
| 2118 | $self->mergeGroupList('barPatternList', $otherObj, 6); | ||
| 2119 | $self->mergeGroupList('groupPatternList', $otherObj, 4); | ||
| 2120 | $self->mergeGroupList('affectPatternList', $otherObj, 3); | ||
| 2121 | $self->mergeGroupList('statPatternList', $otherObj, 4); | ||
| 2122 | $self->mergeList('agePatternList', $otherObj); | ||
| 2123 | $self->mergeList('timePatternList', $otherObj); | ||
| 2124 | $self->mergeList('statusIgnorePatternList', $otherObj); | ||
| 2125 | |||
| 2126 | $self->mergeList('deathPatternList', $otherObj); | ||
| 2127 | $self->mergeList('resurrectPatternList', $otherObj); | ||
| 2128 | $self->mergeList('passedOutPatternList', $otherObj); | ||
| 2129 | $self->mergeList('comeAroundPatternList', $otherObj); | ||
| 2130 | $self->mergeList('fallAsleepPatternList', $otherObj); | ||
| 2131 | $self->mergeList('wakeUpPatternList', $otherObj); | ||
| 2132 | $self->mergeList('questCompletePatternList', $otherObj); | ||
| 2133 | |||
| 2134 | # Merge inventory/condition patterns | ||
| 2135 | $self->mergeGroupList('inventoryPatternList', $otherObj, 5); | ||
| 2136 | $self->mergeGroupList('inventoryIgnorePatternList', $otherObj, 2); | ||
| 2137 | $self->mergeList('inventoryDiscardPatternList', $otherObj); | ||
| 2138 | $self->mergeList('inventorySplitPatternList', $otherObj); | ||
| 2139 | $self->ivPoke('inventoryMode', $otherObj->inventoryMode); | ||
| 2140 | $self->mergeGroupList('conditionPatternList', $otherObj, 4); | ||
| 2141 | $self->mergeList('conditionIgnorePatternList', $otherObj); | ||
| 2142 | |||
| 2143 | # Merge fight/interaction patterns | ||
| 2144 | $self->mergeGroupList('fightStartedPatternList', $otherObj, 2); | ||
| 2145 | $self->mergeGroupList('cannotFindTargetPatternList', $otherObj, 2); | ||
| 2146 | $self->mergeGroupList('targetAlreadyDeadPatternList', $otherObj, 2); | ||
| 2147 | $self->mergeGroupList('targetKilledPatternList', $otherObj, 2); | ||
| 2148 | $self->mergeGroupList('fightDefeatPatternList', $otherObj, 2); | ||
| 2149 | $self->mergeGroupList('wimpyEngagedPatternList', $otherObj, 2); | ||
| 2150 | $self->mergeList('noFightStartedPatternList', $otherObj); | ||
| 2151 | $self->mergeList('noCannotFindTargetPatternList', $otherObj); | ||
| 2152 | $self->mergeList('noTargetAlreadyDeadPatternList', $otherObj); | ||
| 2153 | $self->mergeList('noTargetKilledPatternList', $otherObj); | ||
| 2154 | $self->mergeList('noFightDefeatPatternList', $otherObj); | ||
| 2155 | $self->mergeList('noWimpyEngagedPatternList', $otherObj); | ||
| 2156 | |||
| 2157 | $self->mergeGroupList('interactionStartedPatternList', $otherObj, 2); | ||
| 2158 | $self->mergeGroupList('cannotInteractPatternList', $otherObj, 2); | ||
| 2159 | $self->mergeGroupList('interactionSuccessPatternList', $otherObj, 2); | ||
| 2160 | $self->mergeGroupList('interactionFailPatternList', $otherObj, 2); | ||
| 2161 | $self->mergeGroupList('interactionFightPatternList', $otherObj, 2); | ||
| 2162 | $self->mergeGroupList('interactionDisasterPatternList', $otherObj, 2); | ||
| 2163 | $self->mergeList('noInteractionStartedPatternList', $otherObj); | ||
| 2164 | $self->mergeList('noCannotInteractPatternList', $otherObj); | ||
| 2165 | $self->mergeList('noInteractionSuccessPatternList', $otherObj); | ||
| 2166 | $self->mergeList('noInteractionFailPatternList', $otherObj); | ||
| 2167 | $self->mergeList('noInteractionFightPatternList', $otherObj); | ||
| 2168 | $self->mergeList('noInteractionDisasterPatternList', $otherObj); | ||
| 2169 | |||
| 2170 | $self->mergeGroupList('targetLeavesPatternList', $otherObj, 3); | ||
| 2171 | $self->mergeGroupList('targetArrivesPatternList', $otherObj, 3); | ||
| 2172 | $self->mergeList('noTargetLeavesPatternList', $otherObj); | ||
| 2173 | $self->mergeList('noTargetArrivesPatternList', $otherObj); | ||
| 2174 | |||
| 2175 | $self->mergeList('noFightsRoomPatternList', $otherObj); | ||
| 2176 | $self->mergeList('noInteractionsRoomPatternList', $otherObj); | ||
| 2177 | |||
| 2178 | # Merge get/drop patterns | ||
| 2179 | $self->mergeList('getSuccessPatternList', $otherObj); | ||
| 2180 | $self->mergeList('getHeavyPatternList', $otherObj); | ||
| 2181 | $self->mergeList('getFailPatternList', $otherObj); | ||
| 2182 | $self->mergeList('dropSuccessPatternList', $otherObj); | ||
| 2183 | $self->mergeList('dropForbidPatternList', $otherObj); | ||
| 2184 | $self->mergeList('dropFailPatternList', $otherObj); | ||
| 2185 | |||
| 2186 | # Merge buy/sell patterns | ||
| 2187 | $self->mergeList('buySuccessPatternList', $otherObj); | ||
| 2188 | $self->mergeList('buyPartialPatternList', $otherObj); | ||
| 2189 | $self->mergeList('buyFailPatternList', $otherObj); | ||
| 2190 | $self->mergeList('sellSuccessPatternList', $otherObj); | ||
| 2191 | $self->mergeList('sellPartialPatternList', $otherObj); | ||
| 2192 | $self->mergeList('sellFailPatternList', $otherObj); | ||
| 2193 | |||
| 2194 | # Merge Advance task patterns | ||
| 2195 | $self->mergeList('advanceSuccessPatternList', $otherObj); | ||
| 2196 | $self->mergeList('advanceFailPatternList', $otherObj); | ||
| 2197 | |||
| 2198 | # Merge Channels/Divert task patterns | ||
| 2199 | $self->mergeGroupList('channelList', $otherObj, 3); | ||
| 2200 | $self->mergeList('noChannelList', $otherObj); | ||
| 2201 | |||
| 2202 | # Merge currency IVs | ||
| 2203 | if ($otherObj->currencyHash) { | ||
| 2204 | |||
| 2205 | # (Replace the whole hash) | ||
| 2206 | $self->ivPoke('currencyHash', $otherObj->currencyHash); | ||
| 2207 | } | ||
| 2208 | |||
| 2209 | $self->ivPoke('standardCurrencyUnit', $otherObj->standardCurrencyUnit); | ||
| 2210 | $self->ivPoke('currencyRounding', $otherObj->currencyRounding); | ||
| 2211 | |||
| 2212 | # (Don't merge missions or quests) | ||
| 2213 | |||
| 2214 | # Merge stats | ||
| 2215 | if ($otherObj->statHash) { | ||
| 2216 | |||
| 2217 | # (Replace the whole hash) | ||
| 2218 | $self->ivPoke('statHash', $otherObj->statHash); | ||
| 2219 | } | ||
| 2220 | |||
| 2221 | if ($otherObj->statOrderList) { | ||
| 2222 | |||
| 2223 | # (Replace the whole list) | ||
| 2224 | $self->ivPoke('statOrderList', $otherObj->statOrderList); | ||
| 2225 | } | ||
| 2226 | |||
| 2227 | # (Don't merge status/inventory command hashes - let the user retain their own preferred | ||
| 2228 | # values) | ||
| 2229 | |||
| 2230 | # Merge room statement components, replacing the entire lists | ||
| 2231 | $self->mergeHash('componentHash', $otherObj); | ||
| 2232 | if ($otherObj->verboseComponentList) { | ||
| 2233 | |||
| 2234 | $self->ivPoke('verboseComponentList', $otherObj->verboseComponentList); | ||
| 2235 | } | ||
| 2236 | |||
| 2237 | if ($otherObj->shortComponentList) { | ||
| 2238 | |||
| 2239 | $self->ivPoke('shortComponentList', $otherObj->shortComponentList); | ||
| 2240 | } | ||
| 2241 | |||
| 2242 | if ($otherObj->briefComponentList) { | ||
| 2243 | |||
| 2244 | $self->ivPoke('briefComponentList', $otherObj->briefComponentList); | ||
| 2245 | } | ||
| 2246 | |||
| 2247 | # Merge basic mapping mode | ||
| 2248 | $self->ivPoke('basicMappingFlag', $otherObj->basicMappingFlag); | ||
| 2249 | $self->mergeList('notAnchorPatternList', $otherObj); | ||
| 2250 | |||
| 2251 | # Merge room statement patterns | ||
| 2252 | $self->mergeList('verboseAnchorPatternList', $otherObj); | ||
| 2253 | $self->ivPoke('verboseAnchorOffset', $otherObj->verboseAnchorOffset); | ||
| 2254 | $self->mergeList('verboseAnchorCheckList', $otherObj); | ||
| 2255 | $self->mergeList('shortAnchorPatternList', $otherObj); | ||
| 2256 | $self->ivPoke('shortAnchorOffset', $otherObj->shortAnchorOffset); | ||
| 2257 | $self->mergeList('shortAnchorCheckList', $otherObj); | ||
| 2258 | $self->mergeList('briefAnchorPatternList', $otherObj); | ||
| 2259 | $self->ivPoke('briefAnchorOffset', $otherObj->briefAnchorOffset); | ||
| 2260 | $self->mergeList('briefAnchorCheckList', $otherObj); | ||
| 2261 | |||
| 2262 | $self->mergeList('verboseExitDelimiterList', $otherObj); | ||
| 2263 | $self->mergeList('verboseExitNonDelimiterList', $otherObj); | ||
| 2264 | $self->ivPoke('verboseExitSplitCharFlag', $otherObj->verboseExitSplitCharFlag); | ||
| 2265 | $self->mergeList('verboseExitLeftMarkerList', $otherObj); | ||
| 2266 | $self->mergeList('verboseExitRightMarkerList', $otherObj); | ||
| 2267 | |||
| 2268 | $self->mergeList('briefExitDelimiterList', $otherObj); | ||
| 2269 | $self->mergeList('briefExitNonDelimiterList', $otherObj); | ||
| 2270 | $self->ivPoke('briefExitSplitCharFlag', $otherObj->briefExitSplitCharFlag); | ||
| 2271 | $self->mergeList('briefExitLeftMarkerList', $otherObj); | ||
| 2272 | $self->mergeList('briefExitRightMarkerList', $otherObj); | ||
| 2273 | |||
| 2274 | $self->mergeList('exitInfoPatternList', $otherObj); | ||
| 2275 | $self->mergeList('exitRemovePatternList', $otherObj); | ||
| 2276 | $self->mergeGroupList('exitStateStringList', $otherObj, 4); | ||
| 2277 | $self->mergeList('exitStatePatternList', $otherObj); | ||
| 2278 | $self->mergeHash('exitStateTagHash', $otherObj); | ||
| 2279 | $self->mergeHash('exitAliasHash', $otherObj); | ||
| 2280 | $self->ivPoke('duplicateReplaceString', $otherObj->duplicateReplaceString); | ||
| 2281 | |||
| 2282 | $self->mergeList('contentPatternList', $otherObj); | ||
| 2283 | $self->mergeHash('specialPatternHash', $otherObj); | ||
| 2284 | |||
| 2285 | $self->mergeList('roomCmdDelimiterList', $otherObj); | ||
| 2286 | $self->mergeList('roomCmdNonDelimiterList', $otherObj); | ||
| 2287 | $self->ivPoke('roomCmdSplitCharFlag', $otherObj->roomCmdSplitCharFlag); | ||
| 2288 | $self->mergeList('roomCmdLeftMarkerList', $otherObj); | ||
| 2289 | $self->mergeList('roomCmdRightMarkerList', $otherObj); | ||
| 2290 | $self->mergeList('roomCmdIgnoreList', $otherObj); | ||
| 2291 | |||
| 2292 | $self->ivPoke('verboseFinalPattern', $otherObj->verboseFinalPattern); | ||
| 2293 | $self->ivPoke('shortFinalPattern', $otherObj->shortFinalPattern); | ||
| 2294 | $self->ivPoke('briefFinalPattern', $otherObj->briefFinalPattern); | ||
| 2295 | |||
| 2296 | $self->ivPoke('mxpRoomTagStart', $otherObj->mxpRoomTagStart); | ||
| 2297 | $self->ivPoke('mxpRoomTagStop', $otherObj->mxpRoomTagStop); | ||
| 2298 | |||
| 2299 | # If the importable world profile was saved by a previous version of Axmud, we may need to | ||
| 2300 | # modify some of the data imported into this profile to work with the current version of | ||
| 2301 | # Axmud | ||
| 2302 | $fileObj = $axmud::CLIENT->ivShow('fileObjHash', $self->name); | ||
| 2303 | $fileObj->updateExtractedData($axmud::CLIENT->convertVersion($version)); | ||
| 2304 | |||
| 2305 | # Merge complete | ||
| 2306 | return 1; | ||
| 2307 | } | ||
| 2308 | |||
| 2309 | sub mergeScalar { | ||
| 2310 | |||
| 2311 | # Called by $self->mergeData during an ';updateworld' operation | ||
| 2312 | # Merges a single scalar IV. If the value stored in the importable world profile is defined, | ||
| 2313 | # copy it to the current world profile; otherwise, do nothing | ||
| 2314 | # | ||
| 2315 | # Expected arguments | ||
| 2316 | # $iv - The IV to merge | ||
| 2317 | # $otherObj - A GA::Profile::World which has been read from an importable file | ||
| 2318 | # | ||
| 2319 | # Return values | ||
| 2320 | # 'undef' on improper arguments | ||
| 2321 | # 1 otherwise | ||
| 2322 | |||
| 2323 | my ($self, $iv, $otherObj, $check) = @_; | ||
| 2324 | |||
| 2325 | # Check for improper arguments | ||
| 2326 | if (! defined $iv || ! defined $otherObj || defined $check) { | ||
| 2327 | |||
| 2328 | return $axmud::CLIENT->writeImproper($self->_objClass . '->mergeScalar', @_); | ||
| 2329 | } | ||
| 2330 | |||
| 2331 | if (defined $otherObj->$iv) { | ||
| 2332 | |||
| 2333 | $self->ivPoke($iv, $otherObj->$iv); | ||
| 2334 | } | ||
| 2335 | |||
| 2336 | return 1; | ||
| 2337 | } | ||
| 2338 | |||
| 2339 | sub mergeList { | ||
| 2340 | |||
| 2341 | # Called by $self->mergeData during an ';updateworld' operation | ||
| 2342 | # Merges a single list IV. Copies values stored in the importable world profile's list into | ||
| 2343 | # into the current world profile's list, unless they already exist there. (Duplicates in | ||
| 2344 | # the importable world profile's list are eliminated) | ||
| 2345 | # | ||
| 2346 | # Expected arguments | ||
| 2347 | # $iv - The IV to merge | ||
| 2348 | # $otherObj - A GA::Profile::World which has been read from an importable file | ||
| 2349 | # | ||
| 2350 | # Return values | ||
| 2351 | # 'undef' on improper arguments | ||
| 2352 | # 1 otherwise | ||
| 2353 | |||
| 2354 | my ($self, $iv, $otherObj, $check) = @_; | ||
| 2355 | |||
| 2356 | # Local variables | ||
| 2357 | my @list; | ||
| 2358 | |||
| 2359 | # Check for improper arguments | ||
| 2360 | if (! defined $iv || ! defined $otherObj || defined $check) { | ||
| 2361 | |||
| 2362 | return $axmud::CLIENT->writeImproper($self->_objClass . '->mergeList', @_); | ||
| 2363 | } | ||
| 2364 | |||
| 2365 | # Get the contents of the importable world profile's list IV | ||
| 2366 | @list = $otherObj->$iv; | ||
| 2367 | |||
| 2368 | foreach my $item (@list) { | ||
| 2369 | |||
| 2370 | # If the item doesn't already exist in the current world profile's IV... | ||
| 2371 | if (! defined $self->ivFind($iv, $item)) { | ||
| 2372 | |||
| 2373 | $self->ivPush($iv, $item); | ||
| 2374 | } | ||
| 2375 | } | ||
| 2376 | |||
| 2377 | return 1; | ||
| 2378 | } | ||
| 2379 | |||
| 2380 | sub mergeGroupList { | ||
| 2381 | |||
| 2382 | # Called by $self->mergeData during an ';updateworld' operation | ||
| 2383 | # Merges a single list IV whose items are in groups, e.g. $self->fightStartedPatternList | ||
| 2384 | # whose items are in groups of two, in the form | ||
| 2385 | # (pattern, group_substring_number, pattern, group_substring_number...) | ||
| 2386 | # Copies groups of values stored in the importable world profile's list into the current | ||
| 2387 | # world profile's list, unless the FIRST value in the importable group already exists as a | ||
| 2388 | # FIRST value in the current group. (Groups in the importable world profile's list with a | ||
| 2389 | # duplicate FIRST value are eliminated) | ||
| 2390 | # | ||
| 2391 | # Expected arguments | ||
| 2392 | # $iv - The IV to merge | ||
| 2393 | # $otherObj - A GA::Profile::World which has been read from an importable file | ||
| 2394 | # $size - The number of items in each group | ||
| 2395 | # | ||
| 2396 | # Return values | ||
| 2397 | # 'undef' on improper arguments | ||
| 2398 | # 1 otherwise | ||
| 2399 | |||
| 2400 | my ($self, $iv, $otherObj, $size, $check) = @_; | ||
| 2401 | |||
| 2402 | # Local variables | ||
| 2403 | my (@currentList, @otherList); | ||
| 2404 | |||
| 2405 | # Check for improper arguments | ||
| 2406 | if (! defined $iv || ! defined $otherObj || ! defined $size || defined $check) { | ||
| 2407 | |||
| 2408 | return $axmud::CLIENT->writeImproper($self->_objClass . '->mergeGroupList', @_); | ||
| 2409 | } | ||
| 2410 | |||
| 2411 | # Get the contents of both list IVs | ||
| 2412 | @currentList = $self->$iv; | ||
| 2413 | @otherList = $otherObj->$iv; | ||
| 2414 | |||
| 2415 | if (! @currentList) { | ||
| 2416 | |||
| 2417 | # Don't have to check that the first item in every group already exists | ||
| 2418 | $self->ivPoke($iv, @otherList); | ||
| 2419 | |||
| 2420 | } elsif (@otherList) { | ||
| 2421 | |||
| 2422 | do { | ||
| 2423 | |||
| 2424 | my ( | ||
| 2425 | $matchFlag, | ||
| 2426 | @groupList, | ||
| 2427 | ); | ||
| 2428 | |||
| 2429 | # Get a group of $size items from @otherList | ||
| 2430 | for (my $count = 0; $count < $size; $count++) { | ||
| 2431 | |||
| 2432 | push (@groupList, shift @otherList); | ||
| 2433 | } | ||
| 2434 | |||
| 2435 | # Does the first item in @groupList match the first item of any group in | ||
| 2436 | # @currentList? | ||
| 2437 | OUTER: for (my $index = 0; $index < scalar @currentList; $index += $size) { | ||
| 2438 | |||
| 2439 | if ($groupList[0] eq $currentList[$index]) { | ||
| 2440 | |||
| 2441 | $matchFlag = TRUE; | ||
| 2442 | last OUTER; | ||
| 2443 | } | ||
| 2444 | } | ||
| 2445 | |||
| 2446 | if (! $matchFlag) { | ||
| 2447 | |||
| 2448 | # The first tiem in @groupList doesn't already exist in the current world | ||
| 2449 | # profile's list IV, so copy the whole group into it | ||
| 2450 | push (@currentList, @groupList); | ||
| 2451 | } | ||
| 2452 | |||
| 2453 | } until (! @otherList); | ||
| 2454 | |||
| 2455 | |||
| 2456 | # Update the IV | ||
| 2457 | $self->ivPoke($iv, @currentList); | ||
| 2458 | } | ||
| 2459 | |||
| 2460 | return 1; | ||
| 2461 | } | ||
| 2462 | |||
| 2463 | sub mergeHash { | ||
| 2464 | |||
| 2465 | # Called by $self->mergeData during an ';updateworld' operation | ||
| 2466 | # Merges a single hash IV. Copies key-value pairs stored in the importable world profile's | ||
| 2467 | # hash into the current world profile's hash, replacing any identical keys which are | ||
| 2468 | # already there | ||
| 2469 | # (It's just a standard Perl %hash = (%hash2, %hash3) operation) | ||
| 2470 | # | ||
| 2471 | # Expected arguments | ||
| 2472 | # $iv - The IV to merge | ||
| 2473 | # $otherObj - A GA::Profile::World which has been read from an importable file | ||
| 2474 | # | ||
| 2475 | # Return values | ||
| 2476 | # 'undef' on improper arguments | ||
| 2477 | # 1 otherwise | ||
| 2478 | |||
| 2479 | my ($self, $iv, $otherObj, $check) = @_; | ||
| 2480 | |||
| 2481 | # Local variables | ||
| 2482 | my (%currentHash, %otherHash, %newHash); | ||
| 2483 | |||
| 2484 | # Check for improper arguments | ||
| 2485 | if (! defined $iv || ! defined $otherObj || defined $check) { | ||
| 2486 | |||
| 2487 | return $axmud::CLIENT->writeImproper($self->_objClass . '->mergeHash', @_); | ||
| 2488 | } | ||
| 2489 | |||
| 2490 | # Get the contents of both hash IVs | ||
| 2491 | %currentHash = $self->$iv; | ||
| 2492 | %otherHash = $otherObj->$iv; | ||
| 2493 | |||
| 2494 | # Merge the hashes | ||
| 2495 | %newHash = (%currentHash, %otherHash); | ||
| 2496 | # Update the IV | ||
| 2497 | $self->ivPoke($iv, %newHash); | ||
| 2498 | |||
| 2499 | return 1; | ||
| 2500 | } | ||
| 2501 | |||
| 2502 | ################## | ||
| 2503 | # Accessors - set | ||
| 2504 | |||
| 2505 | ################## | ||
| 2506 | # Accessors - get | ||
| 2507 | |||
| 2508 | sub noSaveFlag | ||
| 2509 | { $_[0]->{noSaveFlag} } | ||
| 2510 | sub connectHistoryList | ||
| 2511 | { my $self = shift; return @{$self->{connectHistoryList}}; } | ||
| 2512 | |||
| 2513 | sub telnetOverrideHash | ||
| 2514 | { my $self = shift; return %{$self->{telnetOverrideHash}}; } | ||
| 2515 | sub mxpOverrideHash | ||
| 2516 | { my $self = shift; return %{$self->{mxpOverrideHash}}; } | ||
| 2517 | sub termOverrideHash | ||
| 2518 | { my $self = shift; return %{$self->{termOverrideHash}}; } | ||
| 2519 | sub sigilOverrideHash | ||
| 2520 | { my $self = shift; return %{$self->{sigilOverrideHash}}; } | ||
| 2521 | |||
| 2522 | sub profHash | ||
| 2523 | { my $self = shift; return %{$self->{profHash}}; } | ||
| 2524 | sub passwordHash | ||
| 2525 | { my $self = shift; return %{$self->{passwordHash}}; } | ||
| 2526 | sub newPasswordHash | ||
| 2527 | { my $self = shift; return %{$self->{newPasswordHash}}; } | ||
| 2528 | sub accountHash | ||
| 2529 | { my $self = shift; return %{$self->{accountHash}}; } | ||
| 2530 | sub newAccountHash | ||
| 2531 | { my $self = shift; return %{$self->{newAccountHash}}; } | ||
| 2532 | |||
| 2533 | sub protocol | ||
| 2534 | { $_[0]->{protocol} } | ||
| 2535 | |||
| 2536 | sub dns | ||
| 2537 | { $_[0]->{dns} } | ||
| 2538 | sub ipv4 | ||
| 2539 | { $_[0]->{ipv4} } | ||
| 2540 | sub ipv6 | ||
| 2541 | { $_[0]->{ipv6} } | ||
| 2542 | sub port | ||
| 2543 | { $_[0]->{port} } | ||
| 2544 | sub sshUserName | ||
| 2545 | { $_[0]->{sshUserName} } | ||
| 2546 | sub sshPassword | ||
| 2547 | { $_[0]->{sshPassword} } | ||
| 2548 | sub sshPortFlag | ||
| 2549 | { $_[0]->{sshPortFlag} } | ||
| 2550 | |||
| 2551 | sub lastConnectDate | ||
| 2552 | { $_[0]->{lastConnectDate} } | ||
| 2553 | sub lastConnectTime | ||
| 2554 | { $_[0]->{lastConnectTime} } | ||
| 2555 | sub numberConnects | ||
| 2556 | { $_[0]->{numberConnects} } | ||
| 2557 | sub lastConnectChar | ||
| 2558 | { $_[0]->{lastConnectChar} } | ||
| 2559 | |||
| 2560 | sub longName | ||
| 2561 | { $_[0]->{longName} } | ||
| 2562 | sub adultFlag | ||
| 2563 | { $_[0]->{adultFlag} } | ||
| 2564 | sub worldURL | ||
| 2565 | { $_[0]->{worldURL} } | ||
| 2566 | sub referURL | ||
| 2567 | { $_[0]->{referURL} } | ||
| 2568 | sub worldDescrip | ||
| 2569 | { $_[0]->{worldDescrip} } | ||
| 2570 | sub worldHint | ||
| 2571 | { $_[0]->{worldHint} } | ||
| 2572 | sub worldCharSet | ||
| 2573 | { $_[0]->{worldCharSet} } | ||
| 2574 | |||
| 2575 | sub termType | ||
| 2576 | { $_[0]->{termType} } | ||
| 2577 | sub columns | ||
| 2578 | { $_[0]->{columns} } | ||
| 2579 | sub rows | ||
| 2580 | { $_[0]->{rows} } | ||
| 2581 | sub sendSizeInfoFlag | ||
| 2582 | { $_[0]->{sendSizeInfoFlag} } | ||
| 2583 | |||
| 2584 | sub msspGenericValueHash | ||
| 2585 | { my $self = shift; return %{$self->{msspGenericValueHash}}; } | ||
| 2586 | sub msspCustomValueHash | ||
| 2587 | { my $self = shift; return %{$self->{msspCustomValueHash}}; } | ||
| 2588 | |||
| 2589 | sub loginMode | ||
| 2590 | { $_[0]->{loginMode} } | ||
| 2591 | sub loginCmdList | ||
| 2592 | { my $self = shift; return @{$self->{loginCmdList}}; } | ||
| 2593 | sub loginObjName | ||
| 2594 | { $_[0]->{loginObjName} } | ||
| 2595 | sub loginConnectPatternList | ||
| 2596 | { my $self = shift; return @{$self->{loginConnectPatternList}}; } | ||
| 2597 | sub loginSuccessPatternList | ||
| 2598 | { my $self = shift; return @{$self->{loginSuccessPatternList}}; } | ||
| 2599 | sub loginAccountMode | ||
| 2600 | { $_[0]->{loginAccountMode} } | ||
| 2601 | sub loginSpecialList | ||
| 2602 | { my $self = shift; return @{$self->{loginSpecialList}}; } | ||
| 2603 | |||
| 2604 | sub autoQuitMode | ||
| 2605 | { $_[0]->{autoQuitMode} } | ||
| 2606 | sub autoQuitCmdList | ||
| 2607 | { my $self = shift; return @{$self->{autoQuitCmdList}}; } | ||
| 2608 | sub autoQuitObjName | ||
| 2609 | { $_[0]->{autoQuitObjName} } | ||
| 2610 | |||
| 2611 | sub autoSeparateCmdFlag | ||
| 2612 | { $_[0]->{autoSeparateCmdFlag} } | ||
| 2613 | sub excessCmdLimit | ||
| 2614 | { $_[0]->{excessCmdLimit} } | ||
| 2615 | sub excessCmdDelay | ||
| 2616 | { $_[0]->{excessCmdDelay} } | ||
| 2617 | sub lifeStatusOverrideFlag | ||
| 2618 | { $_[0]->{lifeStatusOverrideFlag} } | ||
| 2619 | |||
| 2620 | sub cmdPromptPatternList | ||
| 2621 | { my $self = shift; return @{$self->{cmdPromptPatternList}}; } | ||
| 2622 | sub suppressEmptyLineCount | ||
| 2623 | { $_[0]->{suppressEmptyLineCount} } | ||
| 2624 | sub suppressBeforeLoginFlag | ||
| 2625 | { $_[0]->{suppressBeforeLoginFlag} } | ||
| 2626 | |||
| 2627 | sub dict | ||
| 2628 | { $_[0]->{dict} } | ||
| 2629 | sub collectUnknownWordFlag | ||
| 2630 | { $_[0]->{collectUnknownWordFlag} } | ||
| 2631 | sub collectContentsFlag | ||
| 2632 | { $_[0]->{collectContentsFlag} } | ||
| 2633 | sub numberedObjFlag | ||
| 2634 | { $_[0]->{numberedObjFlag} } | ||
| 2635 | sub multiplePattern | ||
| 2636 | { $_[0]->{multiplePattern} } | ||
| 2637 | |||
| 2638 | sub logPrefHash | ||
| 2639 | { my $self = shift; return %{$self->{logPrefHash}}; } | ||
| 2640 | |||
| 2641 | sub charAgeUnit | ||
| 2642 | { $_[0]->{charAgeUnit} } | ||
| 2643 | sub weightUnit | ||
| 2644 | { $_[0]->{weightUnit} } | ||
| 2645 | sub weightUnitStringList | ||
| 2646 | { $_[0]->{weightUnitStringList} } | ||
| 2647 | |||
| 2648 | sub darkRoomPatternList | ||
| 2649 | { my $self = shift; return @{$self->{darkRoomPatternList}}; } | ||
| 2650 | sub failExitPatternList | ||
| 2651 | { my $self = shift; return @{$self->{failExitPatternList}}; } | ||
| 2652 | sub doorPatternList | ||
| 2653 | { my $self = shift; return @{$self->{doorPatternList}}; } | ||
| 2654 | sub lockedPatternList | ||
| 2655 | { my $self = shift; return @{$self->{lockedPatternList}}; } | ||
| 2656 | sub involuntaryExitPatternList | ||
| 2657 | { my $self = shift; return @{$self->{involuntaryExitPatternList}}; } | ||
| 2658 | sub unspecifiedRoomPatternList | ||
| 2659 | { my $self = shift; return @{$self->{unspecifiedRoomPatternList}}; } | ||
| 2660 | sub followPatternList | ||
| 2661 | { my $self = shift; return @{$self->{followPatternList}}; } | ||
| 2662 | sub followAnchorPatternList | ||
| 2663 | { my $self = shift; return @{$self->{followAnchorPatternList}}; } | ||
| 2664 | sub transientExitPatternList | ||
| 2665 | { my $self = shift; return @{$self->{transientExitPatternList}}; } | ||
| 2666 | |||
| 2667 | sub statusFormatList | ||
| 2668 | { my $self = shift; return @{$self->{statusFormatList}}; } | ||
| 2669 | sub gaugeFormatList | ||
| 2670 | { my $self = shift; return @{$self->{gaugeFormatList}}; } | ||
| 2671 | sub msdpStatusVarHash | ||
| 2672 | { my $self = shift; return %{$self->{msdpStatusVarHash}}; } | ||
| 2673 | sub mxpStatusVarHash | ||
| 2674 | { my $self = shift; return %{$self->{mxpStatusVarHash}}; } | ||
| 2675 | sub barPatternList | ||
| 2676 | { my $self = shift; return @{$self->{barPatternList}}; } | ||
| 2677 | sub groupPatternList | ||
| 2678 | { my $self = shift; return @{$self->{groupPatternList}}; } | ||
| 2679 | sub affectPatternList | ||
| 2680 | { my $self = shift; return @{$self->{affectPatternList}} } | ||
| 2681 | sub statPatternList | ||
| 2682 | { my $self = shift; return @{$self->{statPatternList}} } | ||
| 2683 | sub agePatternList | ||
| 2684 | { my $self = shift; return @{$self->{agePatternList}}; } | ||
| 2685 | sub timePatternList | ||
| 2686 | { my $self = shift; return @{$self->{timePatternList}}; } | ||
| 2687 | sub statusIgnorePatternList | ||
| 2688 | { my $self = shift; return @{$self->{statusIgnorePatternList}}; } | ||
| 2689 | |||
| 2690 | sub deathPatternList | ||
| 2691 | { my $self = shift; return @{$self->{deathPatternList}}; } | ||
| 2692 | sub resurrectPatternList | ||
| 2693 | { my $self = shift; return @{$self->{resurrectPatternList}}; } | ||
| 2694 | sub passedOutPatternList | ||
| 2695 | { my $self = shift; return @{$self->{passedOutPatternList}}; } | ||
| 2696 | sub comeAroundPatternList | ||
| 2697 | { my $self = shift; return @{$self->{comeAroundPatternList}}; } | ||
| 2698 | sub fallAsleepPatternList | ||
| 2699 | { my $self = shift; return @{$self->{fallAsleepPatternList}}; } | ||
| 2700 | sub wakeUpPatternList | ||
| 2701 | { my $self = shift; return @{$self->{wakeUpPatternList}}; } | ||
| 2702 | sub questCompletePatternList | ||
| 2703 | { my $self = shift; return @{$self->{questCompletePatternList}}; } | ||
| 2704 | |||
| 2705 | sub inventoryPatternList | ||
| 2706 | { my $self = shift; return @{$self->{inventoryPatternList}}; } | ||
| 2707 | sub inventoryIgnorePatternList | ||
| 2708 | { my $self = shift; return @{$self->{inventoryIgnorePatternList}}; } | ||
| 2709 | sub inventoryDiscardPatternList | ||
| 2710 | { my $self = shift; return @{$self->{inventoryDiscardPatternList}}; } | ||
| 2711 | sub inventorySplitPatternList | ||
| 2712 | { my $self = shift; return @{$self->{inventorySplitPatternList}}; } | ||
| 2713 | sub inventoryMode | ||
| 2714 | { $_[0]->{inventoryMode} } | ||
| 2715 | |||
| 2716 | sub conditionPatternList | ||
| 2717 | { my $self = shift; return @{$self->{conditionPatternList}}; } | ||
| 2718 | sub conditionIgnorePatternList | ||
| 2719 | { my $self = shift; return @{$self->{conditionIgnorePatternList}}; } | ||
| 2720 | |||
| 2721 | sub fightStartedPatternList | ||
| 2722 | { my $self = shift; return @{$self->{fightStartedPatternList}}; } | ||
| 2723 | sub cannotFindTargetPatternList | ||
| 2724 | { my $self = shift; return @{$self->{cannotFindTargetPatternList}}; } | ||
| 2725 | sub targetAlreadyDeadPatternList | ||
| 2726 | { my $self = shift; return @{$self->{targetAlreadyDeadPatternList}}; } | ||
| 2727 | sub targetKilledPatternList | ||
| 2728 | { my $self = shift; return @{$self->{targetKilledPatternList}}; } | ||
| 2729 | sub fightDefeatPatternList | ||
| 2730 | { my $self = shift; return @{$self->{fightDefeatPatternList}}; } | ||
| 2731 | sub wimpyEngagedPatternList | ||
| 2732 | { my $self = shift; return @{$self->{wimpyEngagedPatternList}}; } | ||
| 2733 | sub noFightStartedPatternList | ||
| 2734 | { my $self = shift; return @{$self->{noFightStartedPatternList}}; } | ||
| 2735 | sub noCannotFindTargetPatternList | ||
| 2736 | { my $self = shift; return @{$self->{noCannotFindTargetPatternList}}; } | ||
| 2737 | sub noTargetAlreadyDeadPatternList | ||
| 2738 | { my $self = shift; return @{$self->{noTargetAlreadyDeadPatternList}}; } | ||
| 2739 | sub noTargetKilledPatternList | ||
| 2740 | { my $self = shift; return @{$self->{noTargetKilledPatternList}}; } | ||
| 2741 | sub noFightDefeatPatternList | ||
| 2742 | { my $self = shift; return @{$self->{noFightDefeatPatternList}}; } | ||
| 2743 | sub noWimpyEngagedPatternList | ||
| 2744 | { my $self = shift; return @{$self->{noWimpyEngagedPatternList}}; } | ||
| 2745 | |||
| 2746 | sub interactionStartedPatternList | ||
| 2747 | { my $self = shift; return @{$self->{interactionStartedPatternList}}; } | ||
| 2748 | sub cannotInteractPatternList | ||
| 2749 | { my $self = shift; return @{$self->{cannotInteractPatternList}}; } | ||
| 2750 | sub interactionSuccessPatternList | ||
| 2751 | { my $self = shift; return @{$self->{interactionSuccessPatternList}}; } | ||
| 2752 | sub interactionFailPatternList | ||
| 2753 | { my $self = shift; return @{$self->{interactionFailPatternList}}; } | ||
| 2754 | sub interactionFightPatternList | ||
| 2755 | { my $self = shift; return @{$self->{interactionFightPatternList}}; } | ||
| 2756 | sub interactionDisasterPatternList | ||
| 2757 | { my $self = shift; return @{$self->{interactionDisasterPatternList}}; } | ||
| 2758 | sub noInteractionStartedPatternList | ||
| 2759 | { my $self = shift; return @{$self->{noInteractionStartedPatternList}}; } | ||
| 2760 | sub noCannotInteractPatternList | ||
| 2761 | { my $self = shift; return @{$self->{noCannotInteractPatternList}}; } | ||
| 2762 | sub noInteractionSuccessPatternList | ||
| 2763 | { my $self = shift; return @{$self->{noInteractionSuccessPatternList}}; } | ||
| 2764 | sub noInteractionFailPatternList | ||
| 2765 | { my $self = shift; return @{$self->{noInteractionFailPatternList}}; } | ||
| 2766 | sub noInteractionFightPatternList | ||
| 2767 | { my $self = shift; return @{$self->{noInteractionFightPatternList}}; } | ||
| 2768 | sub noInteractionDisasterPatternList | ||
| 2769 | { my $self = shift; return @{$self->{noInteractionDisasterPatternList}}; } | ||
| 2770 | |||
| 2771 | sub targetLeavesPatternList | ||
| 2772 | { my $self = shift; return @{$self->{targetLeavesPatternList}}; } | ||
| 2773 | sub targetArrivesPatternList | ||
| 2774 | { my $self = shift; return @{$self->{targetArrivesPatternList}}; } | ||
| 2775 | sub noTargetLeavesPatternList | ||
| 2776 | { my $self = shift; return @{$self->{noTargetLeavesPatternList}}; } | ||
| 2777 | sub noTargetArrivesPatternList | ||
| 2778 | { my $self = shift; return @{$self->{noTargetArrivesPatternList}}; } | ||
| 2779 | |||
| 2780 | sub noFightsRoomPatternList | ||
| 2781 | { my $self = shift; return @{$self->{noFightsRoomPatternList}}; } | ||
| 2782 | sub noInteractionsRoomPatternList | ||
| 2783 | { my $self = shift; return @{$self->{noInteractionsRoomPatternList}}; } | ||
| 2784 | |||
| 2785 | sub getSuccessPatternList | ||
| 2786 | { my $self = shift; return @{$self->{getSuccessPatternList}}; } | ||
| 2787 | sub getHeavyPatternList | ||
| 2788 | { my $self = shift; return @{$self->{getHeavyPatternList}}; } | ||
| 2789 | sub getFailPatternList | ||
| 2790 | { my $self = shift; return @{$self->{getFailPatternList}}; } | ||
| 2791 | sub dropSuccessPatternList | ||
| 2792 | { my $self = shift; return @{$self->{dropSuccessPatternList}}; } | ||
| 2793 | sub dropForbidPatternList | ||
| 2794 | { my $self = shift; return @{$self->{dropForbidPatternList}}; } | ||
| 2795 | sub dropFailPatternList | ||
| 2796 | { my $self = shift; return @{$self->{dropFailPatternList}}; } | ||
| 2797 | |||
| 2798 | sub buySuccessPatternList | ||
| 2799 | { my $self = shift; return @{$self->{buySuccessPatternList}}; } | ||
| 2800 | sub buyPartialPatternList | ||
| 2801 | { my $self = shift; return @{$self->{buyPartialPatternList}}; } | ||
| 2802 | sub buyFailPatternList | ||
| 2803 | { my $self = shift; return @{$self->{buyFailPatternList}}; } | ||
| 2804 | sub sellSuccessPatternList | ||
| 2805 | { my $self = shift; return @{$self->{sellSuccessPatternList}}; } | ||
| 2806 | sub sellPartialPatternList | ||
| 2807 | { my $self = shift; return @{$self->{sellPartialPatternList}}; } | ||
| 2808 | sub sellFailPatternList | ||
| 2809 | { my $self = shift; return @{$self->{sellFailPatternList}}; } | ||
| 2810 | |||
| 2811 | sub advanceSuccessPatternList | ||
| 2812 | { my $self = shift; return @{$self->{advanceSuccessPatternList}}; } | ||
| 2813 | sub advanceFailPatternList | ||
| 2814 | { my $self = shift; return @{$self->{advanceFailPatternList}}; } | ||
| 2815 | |||
| 2816 | sub channelList | ||
| 2817 | { my $self = shift; return @{$self->{channelList}}; } | ||
| 2818 | sub noChannelList | ||
| 2819 | { my $self = shift; return @{$self->{noChannelList}}; } | ||
| 2820 | |||
| 2821 | sub currencyHash | ||
| 2822 | { my $self = shift; return %{$self->{currencyHash}}; } | ||
| 2823 | sub standardCurrencyUnit | ||
| 2824 | { $_[0]->{standardCurrencyUnit} } | ||
| 2825 | sub currencyRounding | ||
| 2826 | { $_[0]->{currencyRounding} } | ||
| 2827 | |||
| 2828 | sub missionHash | ||
| 2829 | { my $self = shift; return %{$self->{missionHash}}; } | ||
| 2830 | |||
| 2831 | sub questHash | ||
| 2832 | { my $self = shift; return %{$self->{questHash}}; } | ||
| 2833 | sub questCount | ||
| 2834 | { $_[0]->{questCount} } | ||
| 2835 | sub questPointCount | ||
| 2836 | { $_[0]->{questPointCount} } | ||
| 2837 | sub questXPCount | ||
| 2838 | { $_[0]->{questXPCount} } | ||
| 2839 | sub questCashCount | ||
| 2840 | { $_[0]->{questCashCount} } | ||
| 2841 | |||
| 2842 | sub statHash | ||
| 2843 | { my $self = shift; return %{$self->{statHash}}; } | ||
| 2844 | sub statOrderList | ||
| 2845 | { my $self = shift; return @{$self->{statOrderList}}; } | ||
| 2846 | |||
| 2847 | sub statusCmdHash | ||
| 2848 | { my $self = shift; return %{$self->{statusCmdHash}}; } | ||
| 2849 | sub inventoryCmdHash | ||
| 2850 | { my $self = shift; return %{$self->{inventoryCmdHash}}; } | ||
| 2851 | |||
| 2852 | sub componentHash | ||
| 2853 | { my $self = shift; return %{$self->{componentHash}}; } | ||
| 2854 | sub verboseComponentList | ||
| 2855 | { my $self = shift; return @{$self->{verboseComponentList}}; } | ||
| 2856 | sub shortComponentList | ||
| 2857 | { my $self = shift; return @{$self->{shortComponentList}}; } | ||
| 2858 | sub briefComponentList | ||
| 2859 | { my $self = shift; return @{$self->{briefComponentList}}; } | ||
| 2860 | |||
| 2861 | sub basicMappingFlag | ||
| 2862 | { $_[0]->{basicMappingFlag} } | ||
| 2863 | sub notAnchorPatternList | ||
| 2864 | { my $self = shift; return @{$self->{notAnchorPatternList}}; } | ||
| 2865 | |||
| 2866 | sub verboseAnchorPatternList | ||
| 2867 | { my $self = shift; return @{$self->{verboseAnchorPatternList}}; } | ||
| 2868 | sub verboseAnchorOffset | ||
| 2869 | { $_[0]->{verboseAnchorOffset} } | ||
| 2870 | sub verboseAnchorCheckList | ||
| 2871 | { my $self = shift; return @{$self->{verboseAnchorCheckList}}; } | ||
| 2872 | sub shortAnchorPatternList | ||
| 2873 | { my $self = shift; return @{$self->{shortAnchorPatternList}}; } | ||
| 2874 | sub shortAnchorOffset | ||
| 2875 | { $_[0]->{shortAnchorOffset} } | ||
| 2876 | sub shortAnchorCheckList | ||
| 2877 | { my $self = shift; return @{$self->{shortAnchorCheckList}}; } | ||
| 2878 | sub briefAnchorPatternList | ||
| 2879 | { my $self = shift; return @{$self->{briefAnchorPatternList}}; } | ||
| 2880 | sub briefAnchorOffset | ||
| 2881 | { $_[0]->{briefAnchorOffset} } | ||
| 2882 | sub briefAnchorCheckList | ||
| 2883 | { my $self = shift; return @{$self->{briefAnchorCheckList}}; } | ||
| 2884 | |||
| 2885 | sub verboseExitDelimiterList | ||
| 2886 | { my $self = shift; return @{$self->{verboseExitDelimiterList}}; } | ||
| 2887 | sub verboseExitNonDelimiterList | ||
| 2888 | { my $self = shift; return @{$self->{verboseExitNonDelimiterList}}; } | ||
| 2889 | sub verboseExitSplitCharFlag | ||
| 2890 | { $_[0]->{verboseExitSplitCharFlag} } | ||
| 2891 | sub verboseExitLeftMarkerList | ||
| 2892 | { my $self = shift; return @{$self->{verboseExitLeftMarkerList}}; } | ||
| 2893 | sub verboseExitRightMarkerList | ||
| 2894 | { my $self = shift; return @{$self->{verboseExitRightMarkerList}}; } | ||
| 2895 | |||
| 2896 | sub briefExitDelimiterList | ||
| 2897 | { my $self = shift; return @{$self->{briefExitDelimiterList}}; } | ||
| 2898 | sub briefExitNonDelimiterList | ||
| 2899 | { my $self = shift; return @{$self->{briefExitNonDelimiterList}}; } | ||
| 2900 | sub briefExitSplitCharFlag | ||
| 2901 | { $_[0]->{briefExitSplitCharFlag} } | ||
| 2902 | sub briefExitLeftMarkerList | ||
| 2903 | { my $self = shift; return @{$self->{briefExitLeftMarkerList}}; } | ||
| 2904 | sub briefExitRightMarkerList | ||
| 2905 | { my $self = shift; return @{$self->{briefExitRightMarkerList}}; } | ||
| 2906 | |||
| 2907 | sub exitInfoPatternList | ||
| 2908 | { my $self = shift; return @{$self->{exitInfoPatternList}}; } | ||
| 2909 | sub exitRemovePatternList | ||
| 2910 | { my $self = shift; return @{$self->{exitRemovePatternList}}; } | ||
| 2911 | sub exitStateStringList | ||
| 2912 | { my $self = shift; return @{$self->{exitStateStringList}}; } | ||
| 2913 | sub exitStatePatternList | ||
| 2914 | { my $self = shift; return @{$self->{exitStatePatternList}}; } | ||
| 2915 | sub exitStateTagHash | ||
| 2916 | { my $self = shift; return %{$self->{exitStateTagHash}}; } | ||
| 2917 | sub exitAliasHash | ||
| 2918 | { my $self = shift; return %{$self->{exitAliasHash}}; } | ||
| 2919 | sub duplicateReplaceString | ||
| 2920 | { $_[0]->{duplicateReplaceString} } | ||
| 2921 | |||
| 2922 | sub contentPatternList | ||
| 2923 | { my $self = shift; return @{$self->{contentPatternList}}; } | ||
| 2924 | sub specialPatternHash | ||
| 2925 | { my $self = shift; return %{$self->{specialPatternHash}}; } | ||
| 2926 | |||
| 2927 | sub roomCmdDelimiterList | ||
| 2928 | { my $self = shift; return @{$self->{roomCmdDelimiterList}}; } | ||
| 2929 | sub roomCmdNonDelimiterList | ||
| 2930 | { my $self = shift; return @{$self->{roomCmdNonDelimiterList}}; } | ||
| 2931 | sub roomCmdSplitCharFlag | ||
| 2932 | { $_[0]->{roomCmdSplitCharFlag} } | ||
| 2933 | sub roomCmdLeftMarkerList | ||
| 2934 | { my $self = shift; return @{$self->{roomCmdLeftMarkerList}}; } | ||
| 2935 | sub roomCmdRightMarkerList | ||
| 2936 | { my $self = shift; return @{$self->{roomCmdRightMarkerList}}; } | ||
| 2937 | sub roomCmdIgnoreList | ||
| 2938 | { my $self = shift; return @{$self->{roomCmdIgnoreList}}; } | ||
| 2939 | |||
| 2940 | sub verboseFinalPattern | ||
| 2941 | { $_[0]->{verboseFinalPattern} } | ||
| 2942 | sub shortFinalPattern | ||
| 2943 | { $_[0]->{shortFinalPattern} } | ||
| 2944 | sub briefFinalPattern | ||
| 2945 | { $_[0]->{briefFinalPattern} } | ||
| 2946 | |||
| 2947 | sub mxpRoomTagStart | ||
| 2948 | { $_[0]->{mxpRoomTagStart} } | ||
| 2949 | sub mxpRoomTagStop | ||
| 2950 | { $_[0]->{mxpRoomTagStop} } | ||
| 2951 | } | ||
| 2952 | |||
| 2953 | { package Games::Axmud::Profile::Guild; | ||
| 2954 | |||
| 2955 | use strict; | ||
| 2956 | use warnings; | ||
| 2957 | # use diagnostics; | ||
| 2958 | |||
| 2959 | use Glib qw(TRUE FALSE); | ||
| 2960 | |||
| 2961 | our @ISA = qw(Games::Axmud::Generic::Profile Games::Axmud); | ||
| 2962 | |||
| 2963 | ################## | ||
| 2964 | # Constructors | ||
| 2965 | |||
| 2966 | sub new { | ||
| 2967 | |||
| 2968 | # Called by any function | ||
| 2969 | # Creates a new instance of the guild profile | ||
| 2970 | # | ||
| 2971 | # Expected arguments | ||
| 2972 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 2973 | # $name - A unique string name for this profile (max 16 chars, containing | ||
| 2974 | # A-Za-z0-9_ - 1st char can't be number, non-Latin alphabets acceptable. | ||
| 2975 | # Must not exist as a key in the global hash of reserved names, | ||
| 2976 | # $axmud::CLIENT->constReservedHash) | ||
| 2977 | # $parentWorld - The name of the parent world profile, with which this profile is | ||
| 2978 | # associated | ||
| 2979 | # | ||
| 2980 | # Optional arguments | ||
| 2981 | # $tempFlag - If set to TRUE, this is a temporary profile created for use with an 'edit' | ||
| 2982 | # window; $name is not checked for validity. Otherwise set to FALSE (or | ||
| 2983 | # 'undef') | ||
| 2984 | # | ||
| 2985 | # Return values | ||
| 2986 | # 'undef' on improper arguments or if $name is invalid | ||
| 2987 | # Blessed reference to the newly-created object on success | ||
| 2988 | |||
| 2989 | my ($class, $session, $name, $parentWorld, $tempFlag, $check) = @_; | ||
| 2990 | |||
| 2991 | # Check for improper arguments | ||
| 2992 | if ( | ||
| 2993 | ! defined $class || ! defined $session || ! defined $name || ! defined $parentWorld | ||
| 2994 | || defined $check | ||
| 2995 | ) { | ||
| 2996 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 2997 | } | ||
| 2998 | |||
| 2999 | if (! $tempFlag) { | ||
| 3000 | |||
| 3001 | # Check that $name is valid and not already in use by another profile | ||
| 3002 | if (! $axmud::CLIENT->nameCheck($name, 16)) { | ||
| 3003 | |||
| 3004 | return $axmud::CLIENT->writeError( | ||
| 3005 | 'Registry naming error: invalid name \'' . $name . '\'', | ||
| 3006 | $class . '->new', | ||
| 3007 | ); | ||
| 3008 | |||
| 3009 | } elsif ($session->ivExists('profHash', $name)) { | ||
| 3010 | |||
| 3011 | return $axmud::CLIENT->writeError( | ||
| 3012 | 'Registry naming error: profile \'' . $name . '\' already exists', | ||
| 3013 | $class . '->new', | ||
| 3014 | ); | ||
| 3015 | } | ||
| 3016 | } | ||
| 3017 | |||
| 3018 | # Setup | ||
| 3019 | my $self = { | ||
| 3020 | _objName => $name, | ||
| 3021 | _objClass => $class, | ||
| 3022 | _parentFile => 'otherprof', | ||
| 3023 | _parentWorld => $session->currentWorld->name, | ||
| 3024 | _privFlag => FALSE, # All IVs are public | ||
| 3025 | |||
| 3026 | # Standard profile IVs | ||
| 3027 | # -------------------- | ||
| 3028 | |||
| 3029 | name => $name, | ||
| 3030 | category => 'guild', | ||
| 3031 | # The name of parent world profile, with which this profile is associated | ||
| 3032 | parentWorld => $parentWorld, | ||
| 3033 | |||
| 3034 | # Hash of tasks that start whenever this profile is made a current profile (as soon as | ||
| 3035 | # the character is marked as 'logged in') - the profile's initial tasklist. Hash in | ||
| 3036 | # the form | ||
| 3037 | # $initTaskHash{unique_task_name} = blessed_reference_to_task_object | ||
| 3038 | initTaskHash => {}, | ||
| 3039 | # The order in which the tasks are started (not very important for tasks unless they | ||
| 3040 | # are Script tasks). List contains all the keys in $self->initTaskHash | ||
| 3041 | initTaskOrderList => [], | ||
| 3042 | # How many initial tasks have been created, in total (used to give each one a unique | ||
| 3043 | # name). Reset to 0 when the profile's initial tasklist is emptied | ||
| 3044 | initTaskTotal => 0, | ||
| 3045 | # Hash of scripts that start whenever this definiton is made a current profile (as soon | ||
| 3046 | # as the character is marked as 'logged in') - the profile's initial scriptlist. Hash | ||
| 3047 | # in the form | ||
| 3048 | # $initScriptHash{script_name} = mode | ||
| 3049 | # ...where 'script_name' matches the file from which the script is loaded, and 'mode' is | ||
| 3050 | # set to one of the following value: | ||
| 3051 | # 'no_task' - run the script without a task | ||
| 3052 | # 'run_task' - run the script from within a task | ||
| 3053 | # 'run_task_win' - run the script from within a task, in 'forced window' mode | ||
| 3054 | initScriptHash => {}, | ||
| 3055 | # The order in which the scripts are started. List contains all the keys in | ||
| 3056 | # $self->initScriptHash | ||
| 3057 | initScriptOrderList => [], | ||
| 3058 | # The name of the mission to start whenever a new session begins with this as a current | ||
| 3059 | # profile, as soon as the character is marked as logged in - but NOT when a current | ||
| 3060 | # profile is set after the login | ||
| 3061 | # Profiles are checked in priority order; only the first mission found is run. Set to | ||
| 3062 | # the name of the mission, or 'undef' | ||
| 3063 | initMission => undef, | ||
| 3064 | # A list of commands to send the the world whenever a new session begins with this as a | ||
| 3065 | # current profile, as soon as the character is marked as logged in - but NOT when a | ||
| 3066 | # current profile is set after the login | ||
| 3067 | # Profiles are checked in priority order; commands are sent from all profiles, but | ||
| 3068 | # duplicate commands are not sent | ||
| 3069 | # Commands are sent AFTER the commands specified by the current world profile's | ||
| 3070 | # ->columns, ->rows and ->sendSizeInfoFlag IVs (so this list doesn't need to include | ||
| 3071 | # them) | ||
| 3072 | initCmdList => [], | ||
| 3073 | |||
| 3074 | # Flag set to TRUE if this profile has EVER been a current profile (in which case, it | ||
| 3075 | # will have cages etc); set to FALSE if not (in which case, the parent file object | ||
| 3076 | # will set up cages etc when this profile first becomes a current profile) | ||
| 3077 | setupCompleteFlag => FALSE, | ||
| 3078 | # List containing notes written by this user for this profile, and available to the | ||
| 3079 | # Notepad task when it's running | ||
| 3080 | notepadList => [], | ||
| 3081 | # A hash to store any data your own plugins/scripts want to store (when a profile is | ||
| 3082 | # cloned, this data is not copied to the clone) | ||
| 3083 | privateHash => {}, | ||
| 3084 | |||
| 3085 | # Guild profile IVs | ||
| 3086 | # ----------------- | ||
| 3087 | |||
| 3088 | # Complete list of guild-specific commands for this guild (character-independent) | ||
| 3089 | cmdList => [], | ||
| 3090 | # List of fight patterns (e.g. 'You hit (.*) with your spear') used with this guild | ||
| 3091 | # (groups of 2) | ||
| 3092 | # [0] - the pattern to match | ||
| 3093 | # [1] - the number of the group substring that contains the assailant (set to 0 if it | ||
| 3094 | # doesn't) | ||
| 3095 | fightMsgList => [], | ||
| 3096 | # List of interaction patterns (e.g. 'You curse (.*) with your magic wand') used with | ||
| 3097 | # this guild (groups of 2) | ||
| 3098 | # [0] - the pattern to match | ||
| 3099 | # [1] - the number of the group substring that contains the victim (set to 0 if it | ||
| 3100 | # doesn't) | ||
| 3101 | interactionMsgList => [], | ||
| 3102 | |||
| 3103 | # The progression of skills. These variables store the default progression for the | ||
| 3104 | # guild; this is copied to the character profile (whenever 'factory settings' need | ||
| 3105 | # to be restored), where the character's own skill progression is stored | ||
| 3106 | # Complete list of skills for this guild | ||
| 3107 | skillList => [], | ||
| 3108 | # maximum possible level, e.g. 'fighting' => 100 | ||
| 3109 | skillMaxLevelHash => {}, | ||
| 3110 | # What method is used to advance skills | ||
| 3111 | # 'order' - advance skills in a pre-determined order | ||
| 3112 | # 'cycle' - advance skills on a repeating cycle | ||
| 3113 | # 'combo' - advance skills in the pre-determined order then, when that list is | ||
| 3114 | # exhausted, start advancing skills in the repeating cycle | ||
| 3115 | advanceMethod => 'order', | ||
| 3116 | # The pre-determined list of skills (an empty list if not used) | ||
| 3117 | advanceOrderList => [], | ||
| 3118 | # The pre-determined cycle of skills (an empty list if not used) | ||
| 3119 | advanceCycleList => [], | ||
| 3120 | }; | ||
| 3121 | |||
| 3122 | # Bless the object into existence | ||
| 3123 | bless $self, $class; | ||
| 3124 | return $self; | ||
| 3125 | } | ||
| 3126 | |||
| 3127 | sub clone { | ||
| 3128 | |||
| 3129 | # Creates a clone of an existing guild profile | ||
| 3130 | # | ||
| 3131 | # Expected arguments | ||
| 3132 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 3133 | # $name - A unique string name for this profile (max 16 chars, containing | ||
| 3134 | # A-Za-z0-9_ - 1st char can't be number, non-Latin alphabets acceptable. | ||
| 3135 | # Must not exist as a key in the global hash of reserved names, | ||
| 3136 | # $axmud::CLIENT->constReservedHash) | ||
| 3137 | # | ||
| 3138 | # Return values | ||
| 3139 | # 'undef' on improper arguments or if $name is invalid | ||
| 3140 | # Blessed reference to the newly-created object on success | ||
| 3141 | |||
| 3142 | my ($self, $session, $name, $check) = @_; | ||
| 3143 | |||
| 3144 | # Check for improper arguments | ||
| 3145 | if (! defined $session || ! defined $name || defined $check) { | ||
| 3146 | |||
| 3147 | return $axmud::CLIENT->writeImproper($self->_objClass . '->clone', @_); | ||
| 3148 | } | ||
| 3149 | |||
| 3150 | # Check that $name is valid and not already in use by another profile | ||
| 3151 | if (! $axmud::CLIENT->nameCheck($name, 16)) { | ||
| 3152 | |||
| 3153 | return $axmud::CLIENT->writeError( | ||
| 3154 | 'Registry naming error: invalid name \'' . $name . '\'', | ||
| 3155 | $self->_objClass . '->clone', | ||
| 3156 | ); | ||
| 3157 | |||
| 3158 | } elsif ($session->ivExists('profHash', $name)) { | ||
| 3159 | |||
| 3160 | return $axmud::CLIENT->writeError( | ||
| 3161 | 'Registry naming error: profile \'' . $name . '\' already exists', | ||
| 3162 | $self->_objClass . '->clone', | ||
| 3163 | ); | ||
| 3164 | } | ||
| 3165 | |||
| 3166 | # Setup | ||
| 3167 | my $clone = { | ||
| 3168 | _objName => $name, | ||
| 3169 | _objClass => $self->_objClass, | ||
| 3170 | _parentFile => 'otherprof', | ||
| 3171 | _parentWorld => $session->currentWorld->name, | ||
| 3172 | _privFlag => FALSE, # All IVs are public | ||
| 3173 | |||
| 3174 | # Standard profile IVs | ||
| 3175 | # -------------------- | ||
| 3176 | |||
| 3177 | name => $name, | ||
| 3178 | category => $self->category, | ||
| 3179 | parentWorld => undef, | ||
| 3180 | |||
| 3181 | initTaskHash => {}, # Set below | ||
| 3182 | initTaskOrderList => [], # Set below | ||
| 3183 | initTaskTotal => $self->initTaskTotal, | ||
| 3184 | initScriptHash => {}, # Set below | ||
| 3185 | initScriptOrderList => [], # Set below | ||
| 3186 | initMission => $self->initMission, | ||
| 3187 | initCmdList => [$self->initCmdList], | ||
| 3188 | |||
| 3189 | setupCompleteFlag => FALSE, # Clone never been a current profile | ||
| 3190 | notepadList => [$self->notepadList], | ||
| 3191 | privateHash => {}, | ||
| 3192 | |||
| 3193 | # Guild profile IVs | ||
| 3194 | # ----------------- | ||
| 3195 | |||
| 3196 | cmdList => [$self->cmdList], | ||
| 3197 | fightMsgList => [$self->fightMsgList], | ||
| 3198 | interactionMsgList => [$self->interactionMsgList], | ||
| 3199 | |||
| 3200 | skillList => [$self->skillList], | ||
| 3201 | skillMaxLevelHash => {$self->skillMaxLevelHash}, | ||
| 3202 | advanceMethod => $self->advanceMethod, | ||
| 3203 | advanceOrderList => [$self->advanceOrderList], | ||
| 3204 | advanceCycleList => [$self->advanceCycleList], | ||
| 3205 | }; | ||
| 3206 | |||
| 3207 | # Bless the cloned object into existence | ||
| 3208 | bless $clone, $self->_objClass; | ||
| 3209 | |||
| 3210 | # Also need to clone everything in the initial tasklist | ||
| 3211 | $clone->cloneInitTaskList($self); | ||
| 3212 | |||
| 3213 | return $clone; | ||
| 3214 | } | ||
| 3215 | |||
| 3216 | ################## | ||
| 3217 | # Methods | ||
| 3218 | |||
| 3219 | ################## | ||
| 3220 | # Accessors - set | ||
| 3221 | |||
| 3222 | ################## | ||
| 3223 | # Accessors - get | ||
| 3224 | |||
| 3225 | sub cmdList | ||
| 3226 | { my $self = shift; return @{$self->{cmdList}}; } | ||
| 3227 | sub fightMsgList | ||
| 3228 | { my $self = shift; return @{$self->{fightMsgList}}; } | ||
| 3229 | sub interactionMsgList | ||
| 3230 | { my $self = shift; return @{$self->{interactionMsgList}}; } | ||
| 3231 | |||
| 3232 | sub skillList | ||
| 3233 | { my $self = shift; return @{$self->{skillList}}; } | ||
| 3234 | sub skillMaxLevelHash | ||
| 3235 | { my $self = shift; return %{$self->{skillMaxLevelHash}}; } | ||
| 3236 | sub advanceMethod | ||
| 3237 | { $_[0]->{advanceMethod} } | ||
| 3238 | sub advanceOrderList | ||
| 3239 | { my $self = shift; return @{$self->{advanceOrderList}}; } | ||
| 3240 | sub advanceCycleList | ||
| 3241 | { my $self = shift; return @{$self->{advanceCycleList}}; } | ||
| 3242 | } | ||
| 3243 | |||
| 3244 | { package Games::Axmud::Profile::Race; | ||
| 3245 | |||
| 3246 | use strict; | ||
| 3247 | use warnings; | ||
| 3248 | # use diagnostics; | ||
| 3249 | |||
| 3250 | use Glib qw(TRUE FALSE); | ||
| 3251 | |||
| 3252 | our @ISA = qw(Games::Axmud::Generic::Profile Games::Axmud); | ||
| 3253 | |||
| 3254 | ################## | ||
| 3255 | # Constructors | ||
| 3256 | |||
| 3257 | sub new { | ||
| 3258 | |||
| 3259 | # Called by any function | ||
| 3260 | # Creates a new instance of the race profile | ||
| 3261 | # | ||
| 3262 | # Expected arguments | ||
| 3263 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 3264 | # $name - A unique string name for this profile (max 16 chars, containing | ||
| 3265 | # A-Za-z0-9_ - 1st char can't be number, non-Latin alphabets acceptable. | ||
| 3266 | # Must not exist as a key in the global hash of reserved names, | ||
| 3267 | # $axmud::CLIENT->constReservedHash) | ||
| 3268 | # $parentWorld - The name of the parent world profile, with which this profile is | ||
| 3269 | # associated | ||
| 3270 | # | ||
| 3271 | # Optional arguments | ||
| 3272 | # $tempFlag - If set to TRUE, this is a temporary profile created for use with an 'edit' | ||
| 3273 | # window; $name is not checked for validity. Otherwise set to FALSE (or | ||
| 3274 | # 'undef') | ||
| 3275 | # | ||
| 3276 | # Return values | ||
| 3277 | # 'undef' on improper arguments or if $name is invalid | ||
| 3278 | # Blessed reference to the newly-created object on success | ||
| 3279 | |||
| 3280 | my ($class, $session, $name, $parentWorld, $tempFlag, $check) = @_; | ||
| 3281 | |||
| 3282 | # Check for improper arguments | ||
| 3283 | if ( | ||
| 3284 | ! defined $class || ! defined $session || ! defined $name || ! defined $parentWorld | ||
| 3285 | || defined $check | ||
| 3286 | ) { | ||
| 3287 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 3288 | } | ||
| 3289 | |||
| 3290 | if (! $tempFlag) { | ||
| 3291 | |||
| 3292 | # Check that $name is valid and not already in use by another profile | ||
| 3293 | if (! $axmud::CLIENT->nameCheck($name, 16)) { | ||
| 3294 | |||
| 3295 | return $axmud::CLIENT->writeError( | ||
| 3296 | 'Registry naming error: invalid name \'' . $name . '\'', | ||
| 3297 | $class . '->new', | ||
| 3298 | ); | ||
| 3299 | |||
| 3300 | } elsif ($session->ivExists('profHash', $name)) { | ||
| 3301 | |||
| 3302 | return $axmud::CLIENT->writeError( | ||
| 3303 | 'Registry naming error: profile \'' . $name . '\' already exists', | ||
| 3304 | $class . '->new', | ||
| 3305 | ); | ||
| 3306 | } | ||
| 3307 | } | ||
| 3308 | |||
| 3309 | # Setup | ||
| 3310 | my $self = { | ||
| 3311 | _objName => $name, | ||
| 3312 | _objClass => $class, | ||
| 3313 | _parentFile => 'otherprof', | ||
| 3314 | _parentWorld => $session->currentWorld->name, | ||
| 3315 | _privFlag => FALSE, # All IVs are public | ||
| 3316 | |||
| 3317 | # Standard profile IVs | ||
| 3318 | # -------------------- | ||
| 3319 | |||
| 3320 | name => $name, | ||
| 3321 | category => 'race', | ||
| 3322 | # The name of parent world profile, with which this profile is associated | ||
| 3323 | parentWorld => $parentWorld, | ||
| 3324 | |||
| 3325 | # Hash of tasks that start whenever this profile is made a current profile (as soon as | ||
| 3326 | # the character is marked as 'logged in') - the profile's initial tasklist. Hash in | ||
| 3327 | # the form | ||
| 3328 | # $initTaskHash{unique_task_name} = blessed_reference_to_task_object | ||
| 3329 | initTaskHash => {}, | ||
| 3330 | # The order in which the tasks are started (not very important for tasks unless they | ||
| 3331 | # are Script tasks). List contains all the keys in $self->initTaskHash | ||
| 3332 | initTaskOrderList => [], | ||
| 3333 | # How many initial tasks have been created, in total (used to give each one a unique | ||
| 3334 | # name). Reset to 0 when the profile's initial tasklist is emptied | ||
| 3335 | initTaskTotal => 0, | ||
| 3336 | # Hash of scripts that start whenever this definiton is made a current profile (as soon | ||
| 3337 | # as the character is marked as 'logged in') - the profile's initial scriptlist. Hash | ||
| 3338 | # in the form | ||
| 3339 | # $initScriptHash{script_name} = mode | ||
| 3340 | # ...where 'script_name' matches the file from which the script is loaded, and 'mode' is | ||
| 3341 | # set to one of the following value: | ||
| 3342 | # 'no_task' - run the script without a task | ||
| 3343 | # 'run_task' - run the script from within a task | ||
| 3344 | # 'run_task_win' - run the script from within a task, in 'forced window' mode | ||
| 3345 | initScriptHash => {}, | ||
| 3346 | # The order in which the scripts are started. List contains all the keys in | ||
| 3347 | # $self->initScriptHash | ||
| 3348 | initScriptOrderList => [], | ||
| 3349 | # The name of the mission to start whenever a new session begins with this as a current | ||
| 3350 | # profile, as soon as the character is marked as logged in - but NOT when a current | ||
| 3351 | # profile is set after the login | ||
| 3352 | # Profiles are checked in priority order; only the first mission found is run. Set to | ||
| 3353 | # the name of the mission, or 'undef' | ||
| 3354 | initMission => undef, | ||
| 3355 | # A list of commands to send the the world whenever a new session begins with this as a | ||
| 3356 | # current profile, as soon as the character is marked as logged in - but NOT when a | ||
| 3357 | # current profile is set after the login | ||
| 3358 | # Profiles are checked in priority order; commands are sent from all profiles, but | ||
| 3359 | # duplicate commands are not sent | ||
| 3360 | # Commands are sent AFTER the commands specified by the current world profile's | ||
| 3361 | # ->columns, ->rows and ->sendSizeInfoFlag IVs (so this list doesn't need to include | ||
| 3362 | # them) | ||
| 3363 | initCmdList => [], | ||
| 3364 | |||
| 3365 | # Flag set to TRUE if this profile has EVER been a current profile (in which case, it | ||
| 3366 | # will have cages etc); set to FALSE if not (in which case, the parent file object | ||
| 3367 | # will set up cages etc when this profile first becomes a current profile) | ||
| 3368 | setupCompleteFlag => FALSE, | ||
| 3369 | # List containing notes written by this user for this profile, and available to the | ||
| 3370 | # Notepad task when it's running | ||
| 3371 | notepadList => [], | ||
| 3372 | # A hash to store any data your own plugins/scripts want to store (when a profile is | ||
| 3373 | # cloned, this data is not copied to the clone) | ||
| 3374 | privateHash => {}, | ||
| 3375 | |||
| 3376 | # Race profile IVs | ||
| 3377 | # ---------------- | ||
| 3378 | |||
| 3379 | # Complete list of race-specific commands for this race (character-independent) | ||
| 3380 | cmdList => [], | ||
| 3381 | # List of fight patterns (e.g. 'You hit (.*) with your spear') used with this race | ||
| 3382 | # (groups of 2) | ||
| 3383 | # [0] - the pattern to match | ||
| 3384 | # [1] - the number of the group substring that contains the assailant (set to 0 if it | ||
| 3385 | # doesn't) | ||
| 3386 | fightMsgList => [], | ||
| 3387 | # List of interaction patterns (e.g. 'You curse (.*) with your magic wand') used with | ||
| 3388 | # this race (groups of 2) | ||
| 3389 | # [0] - the pattern to match | ||
| 3390 | # [1] - the number of the group substring that contains the victim (set to 0 if it | ||
| 3391 | # doesn't) | ||
| 3392 | interactionMsgList => [], | ||
| 3393 | }; | ||
| 3394 | |||
| 3395 | # Bless the object into existence | ||
| 3396 | bless $self, $class; | ||
| 3397 | return $self; | ||
| 3398 | } | ||
| 3399 | |||
| 3400 | sub clone { | ||
| 3401 | |||
| 3402 | # Creates a clone of an existing race profile | ||
| 3403 | # | ||
| 3404 | # Expected arguments | ||
| 3405 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 3406 | # $name - A unique string name for this profile (max 16 chars, containing | ||
| 3407 | # A-Za-z0-9_ - 1st char can't be number, non-Latin alphabets acceptable. | ||
| 3408 | # Must not exist as a key in the global hash of reserved names, | ||
| 3409 | # $axmud::CLIENT->constReservedHash) | ||
| 3410 | # | ||
| 3411 | # Return values | ||
| 3412 | # 'undef' on improper arguments or if $name is invalid | ||
| 3413 | # Blessed reference to the newly-created object on success | ||
| 3414 | |||
| 3415 | my ($self, $session, $name, $check) = @_; | ||
| 3416 | |||
| 3417 | # Check for improper arguments | ||
| 3418 | if (! defined $session || ! defined $name || defined $check) { | ||
| 3419 | |||
| 3420 | return $axmud::CLIENT->writeImproper($self->_objClass . '->clone', @_); | ||
| 3421 | } | ||
| 3422 | |||
| 3423 | # Check that $name is valid and not already in use by another profile | ||
| 3424 | if (! $axmud::CLIENT->nameCheck($name, 16)) { | ||
| 3425 | |||
| 3426 | return $axmud::CLIENT->writeError( | ||
| 3427 | 'Registry naming error: invalid name \'' . $name . '\'', | ||
| 3428 | $self->_objClass . '->clone', | ||
| 3429 | ); | ||
| 3430 | |||
| 3431 | } elsif ($session->ivExists('profHash', $name)) { | ||
| 3432 | |||
| 3433 | return $axmud::CLIENT->writeError( | ||
| 3434 | 'Registry naming error: profile \'' . $name . '\' already exists', | ||
| 3435 | $self->_objClass . '->clone', | ||
| 3436 | ); | ||
| 3437 | } | ||
| 3438 | |||
| 3439 | # Setup | ||
| 3440 | my $clone = { | ||
| 3441 | _objName => $name, | ||
| 3442 | _objClass => $self->_objClass, | ||
| 3443 | _parentFile => 'otherprof', | ||
| 3444 | _parentWorld => $session->currentWorld->name, | ||
| 3445 | _privFlag => FALSE, # All IVs are public | ||
| 3446 | |||
| 3447 | # Standard profile IVs | ||
| 3448 | # -------------------- | ||
| 3449 | |||
| 3450 | name => $name, | ||
| 3451 | category => $self->category, | ||
| 3452 | parentWorld => undef, | ||
| 3453 | |||
| 3454 | initTaskHash => {}, # Set below | ||
| 3455 | initTaskOrderList => [], # Set below | ||
| 3456 | initTaskTotal => $self->initTaskTotal, | ||
| 3457 | initScriptHash => {}, # Set below | ||
| 3458 | initScriptOrderList => [], # Set below | ||
| 3459 | initMission => $self->initMission, | ||
| 3460 | initCmdList => [$self->initCmdList], | ||
| 3461 | |||
| 3462 | setupCompleteFlag => FALSE, # Clone never been a current profile | ||
| 3463 | notepadList => [$self->notepadList], | ||
| 3464 | privateHash => {}, | ||
| 3465 | |||
| 3466 | # Race profile IVs | ||
| 3467 | # ---------------- | ||
| 3468 | |||
| 3469 | cmdList => [$self->cmdList], | ||
| 3470 | fightMsgList => [$self->fightMsgList], | ||
| 3471 | interactionMsgList => [$self->interactionMsgList], | ||
| 3472 | }; | ||
| 3473 | |||
| 3474 | # Bless the cloned object into existence | ||
| 3475 | bless $clone, $self->_objClass; | ||
| 3476 | |||
| 3477 | # Also need to clone everything in the initial tasklist | ||
| 3478 | $clone->cloneInitTaskList($self); | ||
| 3479 | |||
| 3480 | return $clone; | ||
| 3481 | } | ||
| 3482 | |||
| 3483 | ################## | ||
| 3484 | # Methods | ||
| 3485 | |||
| 3486 | ################## | ||
| 3487 | # Accessors - set | ||
| 3488 | |||
| 3489 | ################## | ||
| 3490 | # Accessors - get | ||
| 3491 | |||
| 3492 | sub cmdList | ||
| 3493 | { my $self = shift; return @{$self->{cmdList}}; } | ||
| 3494 | sub fightMsgList | ||
| 3495 | { my $self = shift; return @{$self->{fightMsgList}}; } | ||
| 3496 | sub interactionMsgList | ||
| 3497 | { my $self = shift; return @{$self->{interactionMsgList}}; } | ||
| 3498 | } | ||
| 3499 | |||
| 3500 | { package Games::Axmud::Profile::Char; | ||
| 3501 | |||
| 3502 | use strict; | ||
| 3503 | use warnings; | ||
| 3504 | # use diagnostics; | ||
| 3505 | |||
| 3506 | use Glib qw(TRUE FALSE); | ||
| 3507 | |||
| 3508 | our @ISA = qw(Games::Axmud::Generic::Profile Games::Axmud); | ||
| 3509 | |||
| 3510 | ################## | ||
| 3511 | # Constructors | ||
| 3512 | |||
| 3513 | sub new { | ||
| 3514 | |||
| 3515 | # Called by any function | ||
| 3516 | # Creates a new instance of the character profile | ||
| 3517 | # | ||
| 3518 | # Expected arguments | ||
| 3519 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 3520 | # $name - A unique string name for this profile (max 16 chars, containing | ||
| 3521 | # A-Za-z0-9_ - 1st char can't be number, non-Latin alphabets acceptable. | ||
| 3522 | # Must not exist as a key in the global hash of reserved names, | ||
| 3523 | # $axmud::CLIENT->constReservedHash) | ||
| 3524 | # $parentWorld - The name of the parent world profile, with which this profile is | ||
| 3525 | # associated | ||
| 3526 | # | ||
| 3527 | # Optional arguments | ||
| 3528 | # $tempFlag - If set to TRUE, this is a temporary profile created for use with an 'edit' | ||
| 3529 | # window; $name is not checked for validity. Otherwise set to FALSE (or | ||
| 3530 | # 'undef') | ||
| 3531 | # | ||
| 3532 | # Return values | ||
| 3533 | # 'undef' on improper arguments or if $name is invalid | ||
| 3534 | # Blessed reference to the newly-created object on success | ||
| 3535 | |||
| 3536 | my ($class, $session, $name, $parentWorld, $tempFlag, $check) = @_; | ||
| 3537 | |||
| 3538 | # Check for improper arguments | ||
| 3539 | if ( | ||
| 3540 | ! defined $class || ! defined $session || ! defined $name || ! defined $parentWorld | ||
| 3541 | || defined $check | ||
| 3542 | ) { | ||
| 3543 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 3544 | } | ||
| 3545 | |||
| 3546 | if (! $tempFlag) { | ||
| 3547 | |||
| 3548 | # Check that $name is valid and not already in use by another profile | ||
| 3549 | if (! $axmud::CLIENT->nameCheck($name, 16)) { | ||
| 3550 | |||
| 3551 | return $axmud::CLIENT->writeError( | ||
| 3552 | 'Registry naming error: invalid name \'' . $name . '\'', | ||
| 3553 | $class . '->new', | ||
| 3554 | ); | ||
| 3555 | |||
| 3556 | } elsif ($session->ivExists('profHash', $name)) { | ||
| 3557 | |||
| 3558 | return $axmud::CLIENT->writeError( | ||
| 3559 | 'Registry naming error: profile \'' . $name . '\' already exists', | ||
| 3560 | $class . '->new', | ||
| 3561 | ); | ||
| 3562 | } | ||
| 3563 | } | ||
| 3564 | |||
| 3565 | # Setup | ||
| 3566 | my $self = { | ||
| 3567 | _objName => $name, | ||
| 3568 | _objClass => $class, | ||
| 3569 | _parentFile => 'otherprof', | ||
| 3570 | _parentWorld => $session->currentWorld->name, | ||
| 3571 | _privFlag => FALSE, # All IVs are public | ||
| 3572 | |||
| 3573 | # Standard profile IVs | ||
| 3574 | # -------------------- | ||
| 3575 | |||
| 3576 | name => $name, | ||
| 3577 | category => 'char', | ||
| 3578 | # The name of parent world profile, with which this profile is associated | ||
| 3579 | parentWorld => $parentWorld, | ||
| 3580 | |||
| 3581 | # Hash of tasks that start whenever this profile is made a current profile (as soon as | ||
| 3582 | # the character is marked as 'logged in') - the profile's initial tasklist. Hash in | ||
| 3583 | # the form | ||
| 3584 | # $initTaskHash{unique_task_name} = blessed_reference_to_task_object | ||
| 3585 | initTaskHash => {}, | ||
| 3586 | # The order in which the tasks are started (not very important for tasks unless they | ||
| 3587 | # are Script tasks). List contains all the keys in $self->initTaskHash | ||
| 3588 | initTaskOrderList => [], | ||
| 3589 | # How many initial tasks have been created, in total (used to give each one a unique | ||
| 3590 | # name). Reset to 0 when the profile's initial tasklist is emptied | ||
| 3591 | initTaskTotal => 0, | ||
| 3592 | # Hash of scripts that start whenever this definiton is made a current profile (as soon | ||
| 3593 | # as the character is marked as 'logged in') - the profile's initial scriptlist. Hash | ||
| 3594 | # in the form | ||
| 3595 | # $initScriptHash{script_name} = mode | ||
| 3596 | # ...where 'script_name' matches the file from which the script is loaded, and 'mode' is | ||
| 3597 | # set to one of the following value: | ||
| 3598 | # 'no_task' - run the script without a task | ||
| 3599 | # 'run_task' - run the script from within a task | ||
| 3600 | # 'run_task_win' - run the script from within a task, in 'forced window' mode | ||
| 3601 | initScriptHash => {}, | ||
| 3602 | # The order in which the scripts are started. List contains all the keys in | ||
| 3603 | # $self->initScriptHash | ||
| 3604 | initScriptOrderList => [], | ||
| 3605 | # The name of the mission to start whenever a new session begins with this as a current | ||
| 3606 | # profile, as soon as the character is marked as logged in - but NOT when a current | ||
| 3607 | # profile is set after the login | ||
| 3608 | # Profiles are checked in priority order; only the first mission found is run. Set to | ||
| 3609 | # the name of the mission, or 'undef' | ||
| 3610 | initMission => undef, | ||
| 3611 | # A list of commands to send the the world whenever a new session begins with this as a | ||
| 3612 | # current profile, as soon as the character is marked as logged in - but NOT when a | ||
| 3613 | # current profile is set after the login | ||
| 3614 | # Profiles are checked in priority order; commands are sent from all profiles, but | ||
| 3615 | # duplicate commands are not sent | ||
| 3616 | # Commands are sent AFTER the commands specified by the current world profile's | ||
| 3617 | # ->columns, ->rows and ->sendSizeInfoFlag IVs (so this list doesn't need to include | ||
| 3618 | # them) | ||
| 3619 | initCmdList => [], | ||
| 3620 | |||
| 3621 | # Flag set to TRUE if this profile has EVER been a current profile (in which case, it | ||
| 3622 | # will have cages etc); set to FALSE if not (in which case, the parent file | ||
| 3623 | # object will set up cages etc when this profile first becomes a current profile) | ||
| 3624 | setupCompleteFlag => FALSE, | ||
| 3625 | # List containing notes written by this user for this profile, and available to the | ||
| 3626 | # Notepad task when it's running | ||
| 3627 | notepadList => [], | ||
| 3628 | # A hash to store any data your own plugins/scripts want to store (when a profile is | ||
| 3629 | # cloned, this data is not copied to the clone) | ||
| 3630 | privateHash => {}, | ||
| 3631 | |||
| 3632 | # Character profile IVs | ||
| 3633 | # --------------------- | ||
| 3634 | |||
| 3635 | # The character's nickname. By default, the same as $self->name. But, unlike | ||
| 3636 | # $self->name, this string can contain any text (including spaces) | ||
| 3637 | # The nickname, not $self->name, is used in automatic logins | ||
| 3638 | nickname => $name, | ||
| 3639 | # Which guild this character is (matches a guild profile name, or 'undef' if no guild) | ||
| 3640 | guild => undef, | ||
| 3641 | # Which race this character is (matches a race profile name, or 'undef' if no race) | ||
| 3642 | race => undef, | ||
| 3643 | # A hash of current custom profiles that correspond to this character, in the form | ||
| 3644 | # $customProfHash{profile_name} = profile_category | ||
| 3645 | customProfHash => {}, | ||
| 3646 | |||
| 3647 | # Health, magic, energy, guild and social points (corresponding to those collected by | ||
| 3648 | # the Status task) | ||
| 3649 | healthPoints => 0, | ||
| 3650 | healthPointsMax => 0, | ||
| 3651 | magicPoints => 0, | ||
| 3652 | magicPointsMax => 0, | ||
| 3653 | energyPoints => 0, | ||
| 3654 | energyPointsMax => 0, | ||
| 3655 | guildPoints => 0, | ||
| 3656 | guildPointsMax => 0, | ||
| 3657 | socialPoints => 0, | ||
| 3658 | socialPointsMax => 0, | ||
| 3659 | |||
| 3660 | # Current XP, that hasn't already been used for advancing skills | ||
| 3661 | xpCurrent => 0, | ||
| 3662 | # XP to the next level | ||
| 3663 | xpNextLevel => 0, | ||
| 3664 | # Total XP earned by character (if known) | ||
| 3665 | xpTotal => 0, | ||
| 3666 | |||
| 3667 | # Current QP (Quest Points) | ||
| 3668 | qpCurrent => 0, | ||
| 3669 | # QP required for the next level | ||
| 3670 | qpNextLevel => 0, | ||
| 3671 | # Total QP earned by character (if known) | ||
| 3672 | qpTotal => 0, | ||
| 3673 | |||
| 3674 | # Spare set of IVs, used in parallel with XP and QP counts, in case the world | ||
| 3675 | # implements a similar system using a different measure. We'll call them OP (Other | ||
| 3676 | # Points) | ||
| 3677 | opCurrent => 0, | ||
| 3678 | opNextLevel => 0, | ||
| 3679 | opTotal => 0, | ||
| 3680 | |||
| 3681 | # The QP values above are designed to be updated by the Status task. This set of IVs | ||
| 3682 | # exists in parallel with the IVs with the same names in the world profile, and are | ||
| 3683 | # designed to be updated manually by the user | ||
| 3684 | # Hash of quests which have been solved by this character. Hash in the form | ||
| 3685 | # $questHash{quest_name} = undef | ||
| 3686 | questHash => {}, | ||
| 3687 | # How many quests solved by this character | ||
| 3688 | questCount => 0, | ||
| 3689 | # Number of quest points earned | ||
| 3690 | questPointCount => 0, | ||
| 3691 | # Total quest points available | ||
| 3692 | questXPCount => 0, | ||
| 3693 | # Number of quests completed | ||
| 3694 | questCashCount => 0, | ||
| 3695 | |||
| 3696 | # Character's current level (if known), e.g. 100 | ||
| 3697 | level => 0, | ||
| 3698 | # Character's current alignment (if known), usually a string | ||
| 3699 | alignment => undef, | ||
| 3700 | # Hash of spells (etc) that currently affect the character, in the form | ||
| 3701 | # $affectHash{spell} = undef | ||
| 3702 | affectHash => {}, | ||
| 3703 | |||
| 3704 | # The progression of skills. These variables store the default progression for the | ||
| 3705 | # guild; this is copied to the character profile (whenever 'factory settings' need to | ||
| 3706 | # be restored), where the character's own skill progression is stored | ||
| 3707 | # This flag is set to TRUE if a reset has been done at least once (needs to be done, in | ||
| 3708 | # order for the Advance task to work) | ||
| 3709 | resetSkillsFlag => FALSE, | ||
| 3710 | # What method is used to advance skills | ||
| 3711 | # 'order' - advance skills in a pre-determined order | ||
| 3712 | # 'cycle' - advance skills on a repeating cycle | ||
| 3713 | # 'combo' - advance skills in the pre-determined order then, when that list is | ||
| 3714 | # exhausted, start advancing skills in the repeating cycle | ||
| 3715 | advanceMethod => 'order', | ||
| 3716 | # When ->advanceMethod = 'combo', whether we are on the 'order' or 'cycle' stage (undef | ||
| 3717 | # if ->advanceMethod = 'order' or 'cycle' ) | ||
| 3718 | advanceMethodStatus => undef, | ||
| 3719 | # The pre-determined list of skills (an empty list if not used) | ||
| 3720 | advanceOrderList => [], | ||
| 3721 | # The current list of skills, emptied as it is used (refreshed from | ||
| 3722 | # $self->advanceOrderList as necessary) | ||
| 3723 | currentAdvanceOrderList => [], | ||
| 3724 | # The pre-determined cycle of skills (an empty list if not used) | ||
| 3725 | advanceCycleList => [], | ||
| 3726 | # The current cycle of skills (refreshed from ->advanceCycleList as necessary) | ||
| 3727 | currentAdvanceCycleList => [], | ||
| 3728 | |||
| 3729 | # The character's own skill progression variables. The basic list is imported from the | ||
| 3730 | # current guild with $self->resetSkills (and can be reset at any time) | ||
| 3731 | # e.g. skill and current level, e.g. 'fighting' => 10 | ||
| 3732 | skillLevelHash => {}, | ||
| 3733 | # no. times the skill has been advanced, e.g. 'fighting' => 15 | ||
| 3734 | skillAdvanceCountHash => {}, | ||
| 3735 | # Total XP spent advancing this skill (0 if unknown) | ||
| 3736 | skillTotalXPHash => {}, | ||
| 3737 | # XP required to advance this skill once more (undef if unknown) | ||
| 3738 | skillNextXPHash => {}, | ||
| 3739 | # Total cash spent advancing this skill (0 if unknown) | ||
| 3740 | skillTotalCashHash => {}, | ||
| 3741 | # Cash required to advance this skill once more (undef if unknown) | ||
| 3742 | skillNextCashHash => {}, | ||
| 3743 | |||
| 3744 | # The character's skill advance history - a list of GA::Obj::SkillHistory objects, each | ||
| 3745 | # representing an advance, in the order they were advanced | ||
| 3746 | skillHistoryList => [], | ||
| 3747 | |||
| 3748 | # Number of lives left | ||
| 3749 | lifeCount => 0, | ||
| 3750 | # Number of times killed | ||
| 3751 | deathCount => 0, | ||
| 3752 | # Total number of lives, including already used up | ||
| 3753 | lifeMax => 0, | ||
| 3754 | # 'alive', 'sleep', 'passout', 'dead' | ||
| 3755 | lifeStatus => 'alive', | ||
| 3756 | |||
| 3757 | # Many worlds have a 'wimpy' setting, allowing the char to automatically run away before | ||
| 3758 | # death | ||
| 3759 | remoteWimpy => 0, | ||
| 3760 | remoteWimpyMax => 100, | ||
| 3761 | # Axmud's local wimpy fulfills the same purpose, however the maximum value is always | ||
| 3762 | # 100 | ||
| 3763 | localWimpy => 0, | ||
| 3764 | constLocalWimpyMax => 100, | ||
| 3765 | |||
| 3766 | # The character's age (in the world's standard age unit, defined by | ||
| 3767 | # GA::Profile::World->charAgeUnit) | ||
| 3768 | age => 0, | ||
| 3769 | |||
| 3770 | # Axmud stores cash as a single currency, even if the world uses multiple coins; e.g. | ||
| 3771 | # two gold and two silver coins will be stored as 2.5 units - a unit representing gold | ||
| 3772 | # coins | ||
| 3773 | # The character's bank balance (if known) | ||
| 3774 | bankBalance => 0, | ||
| 3775 | # How much money the character has in their pockets (if known) | ||
| 3776 | purseContents => 0, | ||
| 3777 | |||
| 3778 | # Number of fights involving the character (two simultaneous opponents = 2 fights) | ||
| 3779 | fightCount => 0, | ||
| 3780 | # Total number of kills achieved by the character | ||
| 3781 | killCount => 0, | ||
| 3782 | # Number of fights that ended with the character running away when wimpy mode was | ||
| 3783 | # activated | ||
| 3784 | wimpyCount => 0, | ||
| 3785 | # Number of fights that ended in other kinds of defeat, e.g. death or loss of | ||
| 3786 | # consciousness for the character | ||
| 3787 | fightDefeatCount => 0, | ||
| 3788 | |||
| 3789 | # Some guilds don't use fights, e.g. bards might perform songs which can be successes | ||
| 3790 | # or failures. These are called 'interactions'. | ||
| 3791 | interactCount => 0, | ||
| 3792 | # How many successful interactions | ||
| 3793 | interactSuccessCount => 0, | ||
| 3794 | # How many failed interactions | ||
| 3795 | interactFailCount => 0, | ||
| 3796 | # How many failed interactions led to a fight | ||
| 3797 | interactFightCount => 0, | ||
| 3798 | # How many failed interactions that, generally, cause the character to need to run away | ||
| 3799 | # quickly | ||
| 3800 | interactDisasterCount => 0, | ||
| 3801 | |||
| 3802 | # How many fights/interactions caused a target to flee, when the character is able to | ||
| 3803 | # pursue | ||
| 3804 | fleeCount => 0, | ||
| 3805 | # How many fights/interactions ended when a target escaped, meaning the character isn't | ||
| 3806 | # able to pursue | ||
| 3807 | escapeCount => 0, | ||
| 3808 | |||
| 3809 | # A record of all the things killed, updated by the Attack task. Two hashes, one | ||
| 3810 | # containing the main noun of the victim (e.g. 'orc'), the other, the base string | ||
| 3811 | # (e.g. 'big hairy orc'). Hash in the form | ||
| 3812 | # $fightVictimHash{main_noun} = number_of_times_killed | ||
| 3813 | fightVictimHash => {}, | ||
| 3814 | # Hash in the form | ||
| 3815 | # $fightVictimStringHash{base_string} = number_of_times_killed | ||
| 3816 | fightVictimStringHash => {}, | ||
| 3817 | # A record of successful interactions, updated by the Attack task. Two hashes, one | ||
| 3818 | # containing the main noun of the victim (e.g. 'orc'), the other, the base string | ||
| 3819 | # (e.g. 'big hairy orc', in all-lower case) | ||
| 3820 | # Hash in the form | ||
| 3821 | # $interactionVictimHash{main_noun} = number_of_times_interacted_with_successfully | ||
| 3822 | interactionVictimHash => {}, | ||
| 3823 | # Hash in the form | ||
| 3824 | # $interactionVictimStringHash{base_string} = num_times_interacted_with_successfully | ||
| 3825 | interactionVictimStringHash => {}, | ||
| 3826 | |||
| 3827 | # Character's permanent stats (not including bonuses/penalties), initially inherited | ||
| 3828 | # from the world profile | ||
| 3829 | # e.g. statHash{con} = 10, statHash{dex} = 15, etc | ||
| 3830 | statHash => {}, # Set below | ||
| 3831 | |||
| 3832 | # Hash of commands the Status task should send to the world periodically (initially | ||
| 3833 | # inherited from the world profile. The Status task gets its list from the character | ||
| 3834 | # profile, not the world profile) | ||
| 3835 | statusCmdHash => {}, # Set below | ||
| 3836 | # Flag set to TRUE when the Status task should start sending these commands as soon as | ||
| 3837 | # it is initialised; FALSE if not (or 'undef' when the Status task has never run) | ||
| 3838 | statusCmdFlag => undef, | ||
| 3839 | # Hash of commands the Inventory task should send to the world periodically, initially | ||
| 3840 | # inherited from the world profile | ||
| 3841 | inventoryCmdHash => {}, # Set below, | ||
| 3842 | |||
| 3843 | # A list of GA::Obj::Protect objects which define which things enjoy semi-protection | ||
| 3844 | # from being dropped or sold, if they happen to be in the character's inventory | ||
| 3845 | protectObjList => [], | ||
| 3846 | # A list of GA::Obj::Monitor objects which define which things should not be checked | ||
| 3847 | # by the Condition task, if they happen to be in the character's inventory | ||
| 3848 | monitorObjList => [], | ||
| 3849 | }; | ||
| 3850 | |||
| 3851 | # Allow this character profile to inherit a few values from the current world profile (if | ||
| 3852 | # there is one) | ||
| 3853 | if ($session->currentWorld) { | ||
| 3854 | |||
| 3855 | $self->{statHash} = $session->currentWorld->{statHash}; | ||
| 3856 | $self->{statusCmdHash} = $session->currentWorld->{statusCmdHash}; | ||
| 3857 | $self->{inventoryCmdHash} = $session->currentWorld->{inventoryCmdHash}; | ||
| 3858 | } | ||
| 3859 | |||
| 3860 | # Bless the object into existence | ||
| 3861 | bless $self, $class; | ||
| 3862 | return $self; | ||
| 3863 | } | ||
| 3864 | |||
| 3865 | sub clone { | ||
| 3866 | |||
| 3867 | # Creates a clone of an existing character profile | ||
| 3868 | # | ||
| 3869 | # Expected arguments | ||
| 3870 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 3871 | # $name - A unique string name for this profile (max 16 chars, containing | ||
| 3872 | # A-Za-z0-9_ - 1st char can't be number, non-Latin alphabets acceptable. | ||
| 3873 | # Must not exist as a key in the global hash of reserved names, | ||
| 3874 | # $axmud::CLIENT->constReservedHash) | ||
| 3875 | # | ||
| 3876 | # Return values | ||
| 3877 | # 'undef' on improper arguments or if $name is invalid | ||
| 3878 | # Blessed reference to the newly-created object on success | ||
| 3879 | |||
| 3880 | my ($self, $session, $name, $check) = @_; | ||
| 3881 | |||
| 3882 | # Check for improper arguments | ||
| 3883 | if (! defined $session || ! defined $name || defined $check) { | ||
| 3884 | |||
| 3885 | return $axmud::CLIENT->writeImproper($self->_objClass . '->clone', @_); | ||
| 3886 | } | ||
| 3887 | |||
| 3888 | # Check that $name is valid and not already in use by another profile | ||
| 3889 | if (! $axmud::CLIENT->nameCheck($name, 16)) { | ||
| 3890 | |||
| 3891 | return $axmud::CLIENT->writeError( | ||
| 3892 | 'Registry naming error: invalid name \'' . $name . '\'', | ||
| 3893 | $self->_objClass . '->clone', | ||
| 3894 | ); | ||
| 3895 | |||
| 3896 | } elsif ($session->ivExists('profHash', $name)) { | ||
| 3897 | |||
| 3898 | return $axmud::CLIENT->writeError( | ||
| 3899 | 'Registry naming error: profile \'' . $name . '\' already exists', | ||
| 3900 | $self->_objClass . '->clone', | ||
| 3901 | ); | ||
| 3902 | } | ||
| 3903 | |||
| 3904 | # Setup | ||
| 3905 | my $clone = { | ||
| 3906 | _objName => $name, | ||
| 3907 | _objClass => $self->_objClass, | ||
| 3908 | _parentFile => 'otherprof', | ||
| 3909 | _parentWorld => $session->currentWorld->name, | ||
| 3910 | _privFlag => FALSE, # All IVs are public | ||
| 3911 | |||
| 3912 | # Standard profile IVs | ||
| 3913 | # -------------------- | ||
| 3914 | |||
| 3915 | name => $name, | ||
| 3916 | category => $self->category, | ||
| 3917 | parentWorld => undef, | ||
| 3918 | |||
| 3919 | initTaskHash => {}, # Set below | ||
| 3920 | initTaskOrderList => [], # Set below | ||
| 3921 | initTaskTotal => $self->initTaskTotal, | ||
| 3922 | initScriptHash => {}, # Set below | ||
| 3923 | initScriptOrderList => [], # Set below | ||
| 3924 | initMission => $self->initMission, | ||
| 3925 | initCmdList => [$self->initCmdList], | ||
| 3926 | |||
| 3927 | setupCompleteFlag => FALSE, # Clone never been a current profile | ||
| 3928 | notepadList => [$self->notepadList], | ||
| 3929 | privateHash => {}, | ||
| 3930 | |||
| 3931 | # Character profile IVs | ||
| 3932 | # --------------------- | ||
| 3933 | |||
| 3934 | nickname => $self->nickname, | ||
| 3935 | guild => $self->guild, | ||
| 3936 | race => $self->race, | ||
| 3937 | customProfHash => {$self->customProfHash}, | ||
| 3938 | |||
| 3939 | healthPoints => $self->healthPoints, | ||
| 3940 | healthPointsMax => $self->healthPointsMax, | ||
| 3941 | magicPoints => $self->magicPoints, | ||
| 3942 | magicPointsMax => $self->magicPointsMax, | ||
| 3943 | energyPoints => $self->energyPoints, | ||
| 3944 | energyPointsMax => $self->energyPointsMax, | ||
| 3945 | guildPoints => $self->guildPoints, | ||
| 3946 | guildPointsMax => $self->guildPointsMax, | ||
| 3947 | socialPoints => $self->socialPoints, | ||
| 3948 | socialPointsMax => $self->socialPointsMax, | ||
| 3949 | |||
| 3950 | xpCurrent => $self->xpCurrent, | ||
| 3951 | xpNextLevel => $self->xpNextLevel, | ||
| 3952 | xpTotal => $self->xpTotal, | ||
| 3953 | |||
| 3954 | qpCurrent => $self->qpCurrent, | ||
| 3955 | qpNextLevel => $self->qpNextLevel, | ||
| 3956 | qpTotal => $self->qpTotal, | ||
| 3957 | |||
| 3958 | opCurrent => $self->opCurrent, | ||
| 3959 | opNextLevel => $self->opNextLevel, | ||
| 3960 | opTotal => $self->opTotal, | ||
| 3961 | |||
| 3962 | questHash => {$self->questHash}, | ||
| 3963 | questCount => $self->questCount, | ||
| 3964 | questPointCount => $self->questPointCount, | ||
| 3965 | questXPCount => $self->questXPCount, | ||
| 3966 | questCashCount => $self->questCashCount, | ||
| 3967 | |||
| 3968 | level => $self->level, | ||
| 3969 | alignment => $self->alignment, | ||
| 3970 | affectHash => {$self->affectHash}, | ||
| 3971 | |||
| 3972 | resetSkillsFlag => $self->resetSkillsFlag, | ||
| 3973 | advanceMethod => $self->advanceMethod, | ||
| 3974 | advanceMethodStatus => $self->advanceMethodStatus, | ||
| 3975 | advanceOrderList => [$self->advanceOrderList], | ||
| 3976 | currentAdvanceOrderList => [$self->currentAdvanceOrderList], | ||
| 3977 | advanceCycleList => [$self->advanceCycleList], | ||
| 3978 | currentAdvanceCycleList => [$self->currentAdvanceCycleList], | ||
| 3979 | |||
| 3980 | skillLevelHash => {$self->skillLevelHash}, | ||
| 3981 | skillAdvanceCountHash => {$self->skillAdvanceCountHash}, | ||
| 3982 | skillTotalXPHash => {$self->skillTotalXPHash}, | ||
| 3983 | skillNextXPHash => {$self->skillNextXPHash}, | ||
| 3984 | skillTotalCashHash => {$self->skillTotalCashHash}, | ||
| 3985 | skillNextCashHash => {$self->skillNextCashHash}, | ||
| 3986 | |||
| 3987 | skillHistoryList => [$self->skillHistoryList], | ||
| 3988 | |||
| 3989 | lifeCount => $self->lifeCount, | ||
| 3990 | deathCount => $self->deathCount, | ||
| 3991 | lifeMax => $self->lifeMax, | ||
| 3992 | lifeStatus => $self->lifeStatus, | ||
| 3993 | |||
| 3994 | remoteWimpy => $self->remoteWimpy, | ||
| 3995 | remoteWimpyMax => $self->remoteWimpyMax, | ||
| 3996 | localWimpy => $self->localWimpy, | ||
| 3997 | constLocalWimpyMax => $self->constLocalWimpyMax, | ||
| 3998 | |||
| 3999 | age => $self->age, | ||
| 4000 | |||
| 4001 | bankBalance => $self->bankBalance, | ||
| 4002 | purseContents => $self->purseContents, | ||
| 4003 | |||
| 4004 | fightCount => $self->fightCount, | ||
| 4005 | killCount => $self->killCount, | ||
| 4006 | wimpyCount => $self->wimpyCount, | ||
| 4007 | fightDefeatCount => $self->fightDefeatCount, | ||
| 4008 | |||
| 4009 | interactCount => $self->interactCount, | ||
| 4010 | interactSuccessCount => $self->interactSuccessCount, | ||
| 4011 | interactFailCount => $self->interactFailCount, | ||
| 4012 | interactFightCount => $self->interactFightCount, | ||
| 4013 | interactDisasterCount => $self->interactDisasterCount, | ||
| 4014 | |||
| 4015 | fleeCount => $self->fleeCount, | ||
| 4016 | escapeCount => $self->escapeCount, | ||
| 4017 | |||
| 4018 | fightVictimHash => {$self->fightVictimHash}, | ||
| 4019 | fightVictimStringHash => {$self->fightVictimStringHash}, | ||
| 4020 | interactionVictimHash => {$self->interactionVictimHash}, | ||
| 4021 | interactionVictimStringHash | ||
| 4022 | => {$self->interactionVictimStringHash}, | ||
| 4023 | |||
| 4024 | statHash => {$self->statHash}, | ||
| 4025 | |||
| 4026 | statusCmdHash => {$self->statusCmdHash}, | ||
| 4027 | statusCmdFlag => $self->statusCmdFlag, | ||
| 4028 | inventoryCmdHash => {$self->inventoryCmdHash}, | ||
| 4029 | |||
| 4030 | protectObjList => [$self->protectObjList], | ||
| 4031 | monitorObjList => [$self->monitorObjList], | ||
| 4032 | }; | ||
| 4033 | |||
| 4034 | # Bless the cloned object into existence | ||
| 4035 | bless $clone, $self->_objClass; | ||
| 4036 | |||
| 4037 | # Also need to clone everything in the initial tasklist | ||
| 4038 | $clone->cloneInitTaskList($self); | ||
| 4039 | |||
| 4040 | return $clone; | ||
| 4041 | } | ||
| 4042 | |||
| 4043 | ################## | ||
| 4044 | # Methods | ||
| 4045 | |||
| 4046 | sub updateQuestStats { | ||
| 4047 | |||
| 4048 | # Called by anything, any time a quest stored by this profile changes | ||
| 4049 | # Re-calculates this profile's running totals | ||
| 4050 | # | ||
| 4051 | # Expected arguements | ||
| 4052 | # $session - The calling function's GA::Session | ||
| 4053 | # | ||
| 4054 | # Return values | ||
| 4055 | # 'undef' on improper arguments | ||
| 4056 | # 1 otherwise | ||
| 4057 | |||
| 4058 | my ($self, $session, $check) = @_; | ||
| 4059 | |||
| 4060 | # Local variables | ||
| 4061 | my ($questCount, $pointCount, $xpCount, $cashCount); | ||
| 4062 | |||
| 4063 | # Check for improper arguments | ||
| 4064 | if (! defined $session || defined $check) { | ||
| 4065 | |||
| 4066 | return $axmud::CLIENT->writeImproper($self->_objClass . '->updateQuestStats', @_); | ||
| 4067 | } | ||
| 4068 | |||
| 4069 | # Go through each quest registered in $self->questHash, updating the | ||
| 4070 | # running totals wherever possible | ||
| 4071 | $questCount = 0; | ||
| 4072 | $pointCount = 0; | ||
| 4073 | $xpCount = 0; | ||
| 4074 | $cashCount = 0; | ||
| 4075 | foreach my $questName ($self->ivKeys('questHash')) { | ||
| 4076 | |||
| 4077 | my $questObj = $session->currentWorld->ivShow('questHash', $questName); | ||
| 4078 | if ($questObj) { | ||
| 4079 | |||
| 4080 | $questCount++; | ||
| 4081 | |||
| 4082 | if (defined $questObj->questPoints) { | ||
| 4083 | |||
| 4084 | $pointCount += $questObj->questPoints; | ||
| 4085 | } | ||
| 4086 | |||
| 4087 | if (defined $questObj->questXP) { | ||
| 4088 | |||
| 4089 | $xpCount += $questObj->questXP; | ||
| 4090 | } | ||
| 4091 | |||
| 4092 | if (defined $questObj->questCash) { | ||
| 4093 | |||
| 4094 | $cashCount += $questObj->questCash; | ||
| 4095 | } | ||
| 4096 | } | ||
| 4097 | } | ||
| 4098 | |||
| 4099 | # Save the totals | ||
| 4100 | $self->ivPoke('questCount', $questCount); | ||
| 4101 | $self->ivPoke('questPointCount', $pointCount); | ||
| 4102 | $self->ivPoke('questXPCount', $xpCount); | ||
| 4103 | $self->ivPoke('questCashCount', $cashCount); | ||
| 4104 | |||
| 4105 | return 1; | ||
| 4106 | } | ||
| 4107 | |||
| 4108 | sub resetSkills { | ||
| 4109 | |||
| 4110 | # Can be called by anything (e.g. GA::Cmd::ResetGuildSkills->do) | ||
| 4111 | # Restores the skill IVs stored for this character to their defaults, importing some values | ||
| 4112 | # from the current guild profile | ||
| 4113 | # | ||
| 4114 | # Expected arguments | ||
| 4115 | # $session - The calling function's GA::Session | ||
| 4116 | # | ||
| 4117 | # Return values | ||
| 4118 | # 'undef' on improper arguments or if there isn't a current guild from which to import | ||
| 4119 | # values | ||
| 4120 | # 1 otherwise | ||
| 4121 | |||
| 4122 | my ($self, $session, $check) = @_; | ||
| 4123 | |||
| 4124 | # Local variables | ||
| 4125 | my ( | ||
| 4126 | $guild, | ||
| 4127 | @list, | ||
| 4128 | ); | ||
| 4129 | |||
| 4130 | # Check for improper arguments | ||
| 4131 | if (! defined $session || defined $check) { | ||
| 4132 | |||
| 4133 | return $axmud::CLIENT->writeImproper($self->_objClass . '->resetSkills', @_); | ||
| 4134 | } | ||
| 4135 | |||
| 4136 | # Check there is a current guild profile | ||
| 4137 | $guild = $session->currentGuild; | ||
| 4138 | if (! $guild) { | ||
| 4139 | |||
| 4140 | # Can't import values from non-existent profile | ||
| 4141 | return undef; | ||
| 4142 | |||
| 4143 | } else { | ||
| 4144 | |||
| 4145 | # Import values from the current guild profile | ||
| 4146 | $self->ivPoke('advanceMethod', $guild->advanceMethod); | ||
| 4147 | $self->ivPoke('advanceOrderList', $guild->advanceOrderList); | ||
| 4148 | $self->ivPoke('advanceCycleList', $guild->advanceCycleList); | ||
| 4149 | |||
| 4150 | # Set default values in this character profile | ||
| 4151 | if ($self->advanceMethod eq 'combo') { | ||
| 4152 | |||
| 4153 | # In 'combo' mode, the 'order' list is used up before the 'cycle' list | ||
| 4154 | $self->ivPoke('advanceMethodStatus', 'order'); | ||
| 4155 | } | ||
| 4156 | |||
| 4157 | $self->ivPoke('currentAdvanceOrderList', $self->advanceOrderList); | ||
| 4158 | $self->ivPoke('currentAdvanceCycleList', $self->advanceCycleList); | ||
| 4159 | |||
| 4160 | foreach my $skill ($guild->skillList) { | ||
| 4161 | |||
| 4162 | # Every skill starts at 0 | ||
| 4163 | $self->ivAdd('skillLevelHash', $skill, 0); | ||
| 4164 | # Skill never advanced | ||
| 4165 | $self->ivAdd('skillAdvanceCountHash', $skill, 0); | ||
| 4166 | # No XP used in advancing | ||
| 4167 | $self->ivAdd('skillTotalXPHash', $skill, 0); | ||
| 4168 | # XP needed to advance again unknown | ||
| 4169 | $self->ivAdd('skillNextXPHash', $skill, 0); | ||
| 4170 | # No cash used in advancing | ||
| 4171 | $self->ivAdd('skillTotalCashHash', $skill, 0); | ||
| 4172 | # Cash needed to advance again unknown | ||
| 4173 | $self->ivAdd('skillNextCashHash', $skill, 0); | ||
| 4174 | } | ||
| 4175 | |||
| 4176 | # Empty the skill history list | ||
| 4177 | $self->ivEmpty('skillHistoryList'); | ||
| 4178 | |||
| 4179 | # Mark the values as having been reset at least once | ||
| 4180 | $self->ivPoke('skillsResetFlag', TRUE); | ||
| 4181 | |||
| 4182 | # Reset complete | ||
| 4183 | return 1; | ||
| 4184 | } | ||
| 4185 | } | ||
| 4186 | |||
| 4187 | ################## | ||
| 4188 | # Accessors - set | ||
| 4189 | |||
| 4190 | ################## | ||
| 4191 | # Accessors - get | ||
| 4192 | |||
| 4193 | sub nickname | ||
| 4194 | { $_[0]->{nickname} } | ||
| 4195 | sub guild | ||
| 4196 | { $_[0]->{guild} } | ||
| 4197 | sub race | ||
| 4198 | { $_[0]->{race} } | ||
| 4199 | sub customProfHash | ||
| 4200 | { my $self = shift; return %{$self->{customProfHash}}; } | ||
| 4201 | |||
| 4202 | sub healthPoints | ||
| 4203 | { $_[0]->{healthPoints} } | ||
| 4204 | sub healthPointsMax | ||
| 4205 | { $_[0]->{healthPointsMax} } | ||
| 4206 | sub magicPoints | ||
| 4207 | { $_[0]->{magicPoints} } | ||
| 4208 | sub magicPointsMax | ||
| 4209 | { $_[0]->{magicPointsMax} } | ||
| 4210 | sub energyPoints | ||
| 4211 | { $_[0]->{energyPoints} } | ||
| 4212 | sub energyPointsMax | ||
| 4213 | { $_[0]->{energyPointsMax} } | ||
| 4214 | sub guildPoints | ||
| 4215 | { $_[0]->{guildPoints} } | ||
| 4216 | sub guildPointsMax | ||
| 4217 | { $_[0]->{guildPointsMax} } | ||
| 4218 | sub socialPoints | ||
| 4219 | { $_[0]->{socialPoints} } | ||
| 4220 | sub socialPointsMax | ||
| 4221 | { $_[0]->{socialPointsMax} } | ||
| 4222 | |||
| 4223 | sub xpCurrent | ||
| 4224 | { $_[0]->{xpCurrent} } | ||
| 4225 | sub xpNextLevel | ||
| 4226 | { $_[0]->{xpNextLevel} } | ||
| 4227 | sub xpTotal | ||
| 4228 | { $_[0]->{xpTotal} } | ||
| 4229 | |||
| 4230 | sub qpCurrent | ||
| 4231 | { $_[0]->{qpCurrent} } | ||
| 4232 | sub qpNextLevel | ||
| 4233 | { $_[0]->{qpNextLevel} } | ||
| 4234 | sub qpTotal | ||
| 4235 | { $_[0]->{qpTotal} } | ||
| 4236 | |||
| 4237 | sub opCurrent | ||
| 4238 | { $_[0]->{opCurrent} } | ||
| 4239 | sub opNextLevel | ||
| 4240 | { $_[0]->{opNextLevel} } | ||
| 4241 | sub opTotal | ||
| 4242 | { $_[0]->{opTotal} } | ||
| 4243 | |||
| 4244 | sub questHash | ||
| 4245 | { my $self = shift; return %{$self->{questHash}}; } | ||
| 4246 | sub questCount | ||
| 4247 | { $_[0]->{questCount} } | ||
| 4248 | sub questPointCount | ||
| 4249 | { $_[0]->{questPointCount} } | ||
| 4250 | sub questXPCount | ||
| 4251 | { $_[0]->{questXPCount} } | ||
| 4252 | sub questCashCount | ||
| 4253 | { $_[0]->{questCashCount} } | ||
| 4254 | |||
| 4255 | sub level | ||
| 4256 | { $_[0]->{level} } | ||
| 4257 | sub alignment | ||
| 4258 | { $_[0]->{alignment} } | ||
| 4259 | sub affectHash | ||
| 4260 | { my $self = shift; return %{$self->{affectHash}}; } | ||
| 4261 | |||
| 4262 | sub resetSkillsFlag | ||
| 4263 | { $_[0]->{resetSkillsFlag} } | ||
| 4264 | sub advanceMethod | ||
| 4265 | { $_[0]->{advanceMethod} } | ||
| 4266 | sub advanceMethodStatus | ||
| 4267 | { $_[0]->{advanceMethodStatus} } | ||
| 4268 | sub advanceOrderList | ||
| 4269 | { my $self = shift; return @{$self->{advanceOrderList}}; } | ||
| 4270 | sub currentAdvanceOrderList | ||
| 4271 | { my $self = shift; return @{$self->{currentAdvanceOrderList}}; } | ||
| 4272 | sub advanceCycleList | ||
| 4273 | { my $self = shift; return @{$self->{advanceCycleList}}; } | ||
| 4274 | sub currentAdvanceCycleList | ||
| 4275 | { my $self = shift; return @{$self->{currentAdvanceCycleList}}; } | ||
| 4276 | |||
| 4277 | sub skillLevelHash | ||
| 4278 | { my $self = shift; return %{$self->{skillLevelHash}}; } | ||
| 4279 | sub skillAdvanceCountHash | ||
| 4280 | { my $self = shift; return %{$self->{skillAdvanceCountHash}}; } | ||
| 4281 | sub skillTotalXPHash | ||
| 4282 | { my $self = shift; return %{$self->{skillTotalXPHash}}; } | ||
| 4283 | sub skillNextXPHash | ||
| 4284 | { my $self = shift; return %{$self->{skillNextXPHash}}; } | ||
| 4285 | sub skillTotalCashHash | ||
| 4286 | { my $self = shift; return %{$self->{skillTotalCashHash}}; } | ||
| 4287 | sub skillNextCashHash | ||
| 4288 | { my $self = shift; return %{$self->{skillNextCashHash}}; } | ||
| 4289 | |||
| 4290 | sub skillHistoryList | ||
| 4291 | { my $self = shift; return @{$self->{skillHistoryList}}; } | ||
| 4292 | |||
| 4293 | sub lifeCount | ||
| 4294 | { $_[0]->{lifeCount} } | ||
| 4295 | sub deathCount | ||
| 4296 | { $_[0]->{deathCount} } | ||
| 4297 | sub lifeMax | ||
| 4298 | { $_[0]->{lifeMax} } | ||
| 4299 | sub lifeStatus | ||
| 4300 | { $_[0]->{lifeStatus} } | ||
| 4301 | |||
| 4302 | sub remoteWimpy | ||
| 4303 | { $_[0]->{remoteWimpy} } | ||
| 4304 | sub remoteWimpyMax | ||
| 4305 | { $_[0]->{remoteWimpyMax} } | ||
| 4306 | sub localWimpy | ||
| 4307 | { $_[0]->{localWimpy} } | ||
| 4308 | sub constLocalWimpyMax | ||
| 4309 | { $_[0]->{constLocalWimpyMax} } | ||
| 4310 | |||
| 4311 | sub age | ||
| 4312 | { $_[0]->{age} } | ||
| 4313 | |||
| 4314 | sub bankBalance | ||
| 4315 | { $_[0]->{bankBalance} } | ||
| 4316 | sub purseContents | ||
| 4317 | { $_[0]->{purseContents} } | ||
| 4318 | |||
| 4319 | sub fightCount | ||
| 4320 | { $_[0]->{fightCount} } | ||
| 4321 | sub killCount | ||
| 4322 | { $_[0]->{killCount} } | ||
| 4323 | sub wimpyCount | ||
| 4324 | { $_[0]->{wimpyCount} } | ||
| 4325 | sub fightDefeatCount | ||
| 4326 | { $_[0]->{fightDefeatCount} } | ||
| 4327 | |||
| 4328 | sub interactCount | ||
| 4329 | { $_[0]->{interactCount} } | ||
| 4330 | sub interactSuccessCount | ||
| 4331 | { $_[0]->{interactSuccessCount} } | ||
| 4332 | sub interactFailCount | ||
| 4333 | { $_[0]->{interactFailCount} } | ||
| 4334 | sub interactFightCount | ||
| 4335 | { $_[0]->{interactFightCount} } | ||
| 4336 | sub interactDisasterCount | ||
| 4337 | { $_[0]->{interactDisasterCount} } | ||
| 4338 | |||
| 4339 | sub fleeCount | ||
| 4340 | { $_[0]->{fleeCount} } | ||
| 4341 | sub escapeCount | ||
| 4342 | { $_[0]->{escapeCount} } | ||
| 4343 | |||
| 4344 | sub fightVictimHash | ||
| 4345 | { my $self = shift; return %{$self->{fightVictimHash}}; } | ||
| 4346 | sub fightVictimStringHash | ||
| 4347 | { my $self = shift; return %{$self->{fightVictimStringHash}}; } | ||
| 4348 | sub interactionVictimHash | ||
| 4349 | { my $self = shift; return %{$self->{interactionVictimHash}}; } | ||
| 4350 | sub interactionVictimStringHash | ||
| 4351 | { my $self = shift; return %{$self->{interactionVictimStringHash}}; } | ||
| 4352 | |||
| 4353 | sub statHash | ||
| 4354 | { my $self = shift; return %{$self->{statHash}}; } | ||
| 4355 | |||
| 4356 | sub statusCmdHash | ||
| 4357 | { my $self = shift; return %{$self->{statusCmdHash}}; } | ||
| 4358 | sub statusCmdFlag | ||
| 4359 | { $_[0]->{statusCmdFlag} } | ||
| 4360 | sub inventoryCmdHash | ||
| 4361 | { my $self = shift; return %{$self->{inventoryCmdHash}}; } | ||
| 4362 | |||
| 4363 | sub protectObjList | ||
| 4364 | { my $self = shift; return @{$self->{protectObjList}}; } | ||
| 4365 | sub monitorObjList | ||
| 4366 | { my $self = shift; return @{$self->{monitorObjList}}; } | ||
| 4367 | } | ||
| 4368 | |||
| 4369 | { package Games::Axmud::Profile::Template; | ||
| 4370 | |||
| 4371 | use strict; | ||
| 4372 | use warnings; | ||
| 4373 | # use diagnostics; | ||
| 4374 | |||
| 4375 | use Glib qw(TRUE FALSE); | ||
| 4376 | |||
| 4377 | our @ISA = qw(Games::Axmud::Generic::Profile Games::Axmud); | ||
| 4378 | |||
| 4379 | ################## | ||
| 4380 | # Constructors | ||
| 4381 | |||
| 4382 | sub new { | ||
| 4383 | |||
| 4384 | # Called by GA::Cmd::AddTemplate->do, ListProperty->do or by the data viewer window | ||
| 4385 | # Creates a new kind of custom profile, called a 'profile template' | ||
| 4386 | # Call ->new to create the bare bones of a custom profile - the instance variables that | ||
| 4387 | # all custom profile must have | ||
| 4388 | # Use the ->createScalarProperty, ->createListProperty and ->createHashProperty methods to | ||
| 4389 | # give it instance variables that make this kind of custom profile unique | ||
| 4390 | # ('favourite_colour', 'size', 'bank_balance' etc) | ||
| 4391 | # Use ->removeProperty to remove one, if necessary | ||
| 4392 | # Then call ->spawn to create an instance of the GA::Profile::Custom object, using all of | ||
| 4393 | # these instance variables | ||
| 4394 | # Once call->spawn is used for the first time, the instance variables are fixed and cannot | ||
| 4395 | # be changed (but call ->clone to create a clone of the template can be created, which | ||
| 4396 | # is still able to spawn) | ||
| 4397 | # | ||
| 4398 | # Expected arguments | ||
| 4399 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 4400 | # $category - What kind of profile this is (must not be one of the four standard | ||
| 4401 | # categories, 'world', 'guild', 'race' and 'char', nor the category for | ||
| 4402 | # any existing profile template) (max 16 chars, containing A-Za-z0-9_ - | ||
| 4403 | # 1st char can't be number, non-Latin alphabets acceptable. Must not exist | ||
| 4404 | # as a key in the global hash of reserved names, | ||
| 4405 | # $axmud::CLIENT->constReservedHash) | ||
| 4406 | # | ||
| 4407 | # Optional arguments | ||
| 4408 | # $tempFlag - If set to TRUE, this is a temporary profile template created for use with | ||
| 4409 | # an 'edit' window; $category is not checked for validity. Otherwise set | ||
| 4410 | # to FALSE (or 'undef') | ||
| 4411 | # | ||
| 4412 | # Return values | ||
| 4413 | # 'undef' on improper arguments or if $category is invalid | ||
| 4414 | # Blessed reference to the newly-created object on success | ||
| 4415 | |||
| 4416 | my ($class, $session, $category, $tempFlag, $check) = @_; | ||
| 4417 | |||
| 4418 | # Check for improper arguments | ||
| 4419 | if (! defined $class || ! defined $session || ! defined $category || defined $check) { | ||
| 4420 | |||
| 4421 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 4422 | } | ||
| 4423 | |||
| 4424 | if (! $tempFlag) { | ||
| 4425 | |||
| 4426 | # Check that $category is valid and not already in use by another profile template | ||
| 4427 | if (! $axmud::CLIENT->nameCheck($category, 16)) { | ||
| 4428 | |||
| 4429 | return $axmud::CLIENT->writeError( | ||
| 4430 | 'Registry naming error: invalid category \'' . $category . '\'', | ||
| 4431 | $class . '->new', | ||
| 4432 | ); | ||
| 4433 | |||
| 4434 | } elsif ($session->ivExists('templateHash', $category)) { | ||
| 4435 | |||
| 4436 | return $axmud::CLIENT->writeError( | ||
| 4437 | 'Registry naming error: profile template for the category \'' . $category | ||
| 4438 | . '\' already exists', | ||
| 4439 | $class . '->new', | ||
| 4440 | ); | ||
| 4441 | |||
| 4442 | # Check it's not a standard category ('world', 'guild', 'race', 'char') | ||
| 4443 | } elsif (defined $axmud::CLIENT->ivFind('constProfPriorityList', $category)) { | ||
| 4444 | |||
| 4445 | return $axmud::CLIENT->writeError( | ||
| 4446 | 'Registry naming error: the category \'' . $category . '\' is a standard' | ||
| 4447 | . ' category, so profile templates can\'t be created for it', | ||
| 4448 | $class . '->new', | ||
| 4449 | ); | ||
| 4450 | } | ||
| 4451 | } | ||
| 4452 | |||
| 4453 | # Setup | ||
| 4454 | my $self = { | ||
| 4455 | _objName => $category, | ||
| 4456 | _objClass => $class, | ||
| 4457 | _parentFile => 'otherprof', | ||
| 4458 | _parentWorld => $session->currentWorld->name, | ||
| 4459 | _privFlag => FALSE, # All IVs are public | ||
| 4460 | |||
| 4461 | # Template IVs | ||
| 4462 | # ------------ | ||
| 4463 | |||
| 4464 | # The category of profile created from this template | ||
| 4465 | category => $category, | ||
| 4466 | # Flag set to TRUE the first time ->spawn is called, after which no more IVs can be | ||
| 4467 | # added or deleted (the initial underline prevents anything from modifying its | ||
| 4468 | # contents via the usual ->ivPoke (etc) methods) | ||
| 4469 | constFixedFlag => FALSE, | ||
| 4470 | }; | ||
| 4471 | |||
| 4472 | # Bless the object into existence | ||
| 4473 | bless $self, $class; | ||
| 4474 | return $self; | ||
| 4475 | } | ||
| 4476 | |||
| 4477 | sub clone { | ||
| 4478 | |||
| 4479 | # Creates a clone of this template, but with its ->constFixedFlag reset back to FALSE, so | ||
| 4480 | # that the copy can be given new IVs | ||
| 4481 | # | ||
| 4482 | # Expected arguments | ||
| 4483 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 4484 | # $category - What kind of profile the copy will be (must not be one of the four | ||
| 4485 | # standard categories, 'world', 'guild', 'race' and 'char', nor the | ||
| 4486 | # category for any existing profile template) (max 16 chars, containing | ||
| 4487 | # A-Za-z0-9_ - 1st char can't be number, non-Latin alphabets acceptable. | ||
| 4488 | # Must not exist as a key in the global hash of reserved names, | ||
| 4489 | # $axmud::CLIENT->constReservedHash) | ||
| 4490 | # | ||
| 4491 | # Return values | ||
| 4492 | # 'undef' on improper arguments or if $name is invalid | ||
| 4493 | # Blessed reference to the newly-created object on success | ||
| 4494 | |||
| 4495 | my ($self, $session, $category, $check) = @_; | ||
| 4496 | |||
| 4497 | # Check for improper arguments | ||
| 4498 | if (! defined $session || ! defined $category || defined $check) { | ||
| 4499 | |||
| 4500 | return $axmud::CLIENT->writeImproper($self->_objClass . '->clone', @_); | ||
| 4501 | } | ||
| 4502 | |||
| 4503 | # Check that $category is valid and not already in use by another profile template | ||
| 4504 | if (! $axmud::CLIENT->nameCheck($category, 16)) { | ||
| 4505 | |||
| 4506 | return $axmud::CLIENT->writeError( | ||
| 4507 | 'Registry naming error: invalid category \'' . $category . '\'', | ||
| 4508 | $self->_objClass . '->clone', | ||
| 4509 | ); | ||
| 4510 | |||
| 4511 | } elsif ($session->ivExists('templateHash', $category)) { | ||
| 4512 | |||
| 4513 | return $axmud::CLIENT->writeError( | ||
| 4514 | 'Registry naming error: profile template for the category \'' . $category | ||
| 4515 | . '\' already exists', | ||
| 4516 | $self->_objClass . '->clone', | ||
| 4517 | ); | ||
| 4518 | |||
| 4519 | # Check it's not a standard category ('world', 'guild', 'race', 'char') | ||
| 4520 | } elsif (defined $axmud::CLIENT->ivFind('constProfPriorityList', $category)) { | ||
| 4521 | |||
| 4522 | return $axmud::CLIENT->writeError( | ||
| 4523 | 'Registry naming error: the category \'' . $category . '\' is a standard category,' | ||
| 4524 | . ' so profile templates can\'t be created for it', | ||
| 4525 | $self->_objClass . '->clone', | ||
| 4526 | ); | ||
| 4527 | } | ||
| 4528 | |||
| 4529 | # Setup | ||
| 4530 | my $clone = { | ||
| 4531 | _objName => $category, | ||
| 4532 | _objClass => $self->_objClass, | ||
| 4533 | _parentFile => 'otherprof', | ||
| 4534 | _parentWorld => $session->currentWorld->name, | ||
| 4535 | _privFlag => FALSE, # All IVs are public | ||
| 4536 | |||
| 4537 | # Template IVs | ||
| 4538 | # ------------ | ||
| 4539 | |||
| 4540 | # The category of profile created from this template | ||
| 4541 | category => $category, | ||
| 4542 | # Flag set to TRUE the first time ->spawn is called, after which no more IVs can be | ||
| 4543 | # added or deleted (the initial underline prevents anything from modifying its | ||
| 4544 | # contents via the usual ->ivPoke (etc) methods) | ||
| 4545 | constFixedFlag => FALSE, | ||
| 4546 | }; | ||
| 4547 | |||
| 4548 | # Bless the cloned object into existence | ||
| 4549 | bless $clone, $self->_objClass; | ||
| 4550 | |||
| 4551 | # Clone the instance variables for this profile template | ||
| 4552 | OUTER: foreach my $iv ($self->ivList) { | ||
| 4553 | |||
| 4554 | # Don't clone any IVs specified by the GA::Client registry hash | ||
| 4555 | if (! $axmud::CLIENT->ivExists('constProfStandardHash', $iv)) { | ||
| 4556 | |||
| 4557 | $clone->{$iv} = $self->{$iv}; | ||
| 4558 | } | ||
| 4559 | } | ||
| 4560 | |||
| 4561 | return $clone; | ||
| 4562 | } | ||
| 4563 | |||
| 4564 | ################## | ||
| 4565 | # Methods | ||
| 4566 | |||
| 4567 | sub spawn { | ||
| 4568 | |||
| 4569 | # Called by any function | ||
| 4570 | # Creates an instance of the GA::Profile::Custom object using this object's properties (IVs) | ||
| 4571 | # If successful, sets $self->constFixedFlag to TRUE, so that no more changes can be made to | ||
| 4572 | # the template's properties | ||
| 4573 | # | ||
| 4574 | # Expected arguments | ||
| 4575 | # $session - The GA::Session which called this function | ||
| 4576 | # $name - A unique string name for this profile (max 16 chars, containing | ||
| 4577 | # A-Za-z0-9_ - 1st char can't be number, non-Latin alphabets acceptable. | ||
| 4578 | # Must not exist as a key in the global hash of reserved names, | ||
| 4579 | # $axmud::CLIENT->constReservedHash) | ||
| 4580 | # $parentWorld - The name of the parent world profile, with which this profile is | ||
| 4581 | # associated | ||
| 4582 | # | ||
| 4583 | # Optional arguments | ||
| 4584 | # $tempFlag - If set to TRUE, the new profile is a temporary profile created for use | ||
| 4585 | # with an 'edit' window; this object's $self->constFixedFlag is not set to | ||
| 4586 | # TRUE. Otherwise set to FALSE (or 'undef') | ||
| 4587 | # | ||
| 4588 | # Return values | ||
| 4589 | # 'undef' on improper arguments or if the spawned custom profile can't be created | ||
| 4590 | # Blessed reference to the newly-created object on success | ||
| 4591 | |||
| 4592 | my ($self, $session, $name, $parentWorld, $tempFlag, $check) = @_; | ||
| 4593 | |||
| 4594 | # Local variables | ||
| 4595 | my ($spawnObj, $templObj); | ||
| 4596 | |||
| 4597 | # Check for improper arguments | ||
| 4598 | if (! defined $session || ! defined $name || ! defined $parentWorld || defined $check) { | ||
| 4599 | |||
| 4600 | return $axmud::CLIENT->writeImproper($self->_objClass . '->spawn', @_); | ||
| 4601 | } | ||
| 4602 | |||
| 4603 | # Create the spawned custom profile | ||
| 4604 | $spawnObj = Games::Axmud::Profile::Custom->new( | ||
| 4605 | $session, | ||
| 4606 | $name, | ||
| 4607 | $parentWorld, | ||
| 4608 | $self->category, | ||
| 4609 | $tempFlag, | ||
| 4610 | ); | ||
| 4611 | |||
| 4612 | if (! $spawnObj) { | ||
| 4613 | |||
| 4614 | # (Error message already displayed) | ||
| 4615 | return undef; | ||
| 4616 | } | ||
| 4617 | |||
| 4618 | # Export all the IVs for this category of custom profile | ||
| 4619 | OUTER: foreach my $iv ($self->ivList) { | ||
| 4620 | |||
| 4621 | # Don't export any IVs specified by the GA::Client registry hash | ||
| 4622 | if (! $axmud::CLIENT->ivExists('constProfStandardHash', $iv)) { | ||
| 4623 | |||
| 4624 | $spawnObj->{$iv} = $self->{$iv}; | ||
| 4625 | } | ||
| 4626 | } | ||
| 4627 | |||
| 4628 | if (! $tempFlag) { | ||
| 4629 | |||
| 4630 | # This template object should now be marked as 'fixed' (no more changes can be made to | ||
| 4631 | # its properties) | ||
| 4632 | # We need to use the $self->{...} form, because IVs beginning 'const...' can't be | ||
| 4633 | # modified with ->ivPoke... | ||
| 4634 | $self->{constFixedFlag} = TRUE; | ||
| 4635 | # ...but the parent file still needs to have its ->modifyFlag set... | ||
| 4636 | $session->setModifyFlag($self->_parentFile, TRUE, $self->_objClass . '->spawn'); | ||
| 4637 | } | ||
| 4638 | |||
| 4639 | # Spawning complete | ||
| 4640 | return $spawnObj; | ||
| 4641 | } | ||
| 4642 | |||
| 4643 | sub createScalarProperty { | ||
| 4644 | |||
| 4645 | # Gives the template a new scalar property (IV) | ||
| 4646 | # | ||
| 4647 | # Expected arguments | ||
| 4648 | # $name - The property name | ||
| 4649 | # | ||
| 4650 | # Optional arguments | ||
| 4651 | # $scalar - The property is set to this value (otherwise it is set to 'undef') | ||
| 4652 | # | ||
| 4653 | # Return values | ||
| 4654 | # 'undef' on improper arguments, or if the property $name already exists, or if the | ||
| 4655 | # template has been 'fixed' (no new properties are allowed) | ||
| 4656 | # 1 on success | ||
| 4657 | |||
| 4658 | my ($self, $name, $scalar, $check) = @_; | ||
| 4659 | |||
| 4660 | # Check for improper arguments | ||
| 4661 | if (! defined $name || defined $check) { | ||
| 4662 | |||
| 4663 | return $axmud::CLIENT->writeImproper($self->_objClass . '->createScalarProperty', @_); | ||
| 4664 | } | ||
| 4665 | |||
| 4666 | if ( | ||
| 4667 | # Check the property doesn't already exist | ||
| 4668 | exists $self->{$name} | ||
| 4669 | # Check the template hasn't already been 'fixed' | ||
| 4670 | || $self->constFixedFlag | ||
| 4671 | # Check that the property isn't one of those specified by the GA::Client registry hash | ||
| 4672 | || $axmud::CLIENT->ivExists('constProfStandardHash', $name) | ||
| 4673 | ) { | ||
| 4674 | return undef; | ||
| 4675 | |||
| 4676 | } else { | ||
| 4677 | |||
| 4678 | # Add the property as a new instance variable | ||
| 4679 | $self->ivCreate($name, 'scalar'); | ||
| 4680 | $self->ivPoke($name, $scalar); | ||
| 4681 | } | ||
| 4682 | |||
| 4683 | return 1; | ||
| 4684 | } | ||
| 4685 | |||
| 4686 | sub createListProperty { | ||
| 4687 | |||
| 4688 | # Gives the template a new array property (IV) | ||
| 4689 | # | ||
| 4690 | # Expected arguments | ||
| 4691 | # $name - The property name | ||
| 4692 | # | ||
| 4693 | # Optional arguments | ||
| 4694 | # @list - The property is set to this list (otherwise it is set to an empty list) | ||
| 4695 | # | ||
| 4696 | # Return values | ||
| 4697 | # 'undef' on improper arguments, or if the property $name already exists, or if the | ||
| 4698 | # template has been 'fixed' (no new properties are allowed) | ||
| 4699 | # 1 on success | ||
| 4700 | |||
| 4701 | my ($self, $name, @list) = @_; | ||
| 4702 | |||
| 4703 | # Check for improper arguments | ||
| 4704 | if (! defined $name) { | ||
| 4705 | |||
| 4706 | return $axmud::CLIENT->writeImproper($self->_objClass . '->createListProperty', @_); | ||
| 4707 | } | ||
| 4708 | |||
| 4709 | if ( | ||
| 4710 | # Check the property doesn't already exist | ||
| 4711 | exists $self->{$name} | ||
| 4712 | # Check the template hasn't already been 'fixed' | ||
| 4713 | || $self->constFixedFlag | ||
| 4714 | # Check that the property isn't one of those specified by the GA::Client registry hash | ||
| 4715 | || $axmud::CLIENT->ivExists('constProfStandardHash', $name) | ||
| 4716 | ) { | ||
| 4717 | return undef; | ||
| 4718 | |||
| 4719 | } else { | ||
| 4720 | |||
| 4721 | # Add the property as a new instance variable | ||
| 4722 | $self->ivCreate($name, 'list'); | ||
| 4723 | $self->ivPoke($name, @list); | ||
| 4724 | } | ||
| 4725 | |||
| 4726 | return 1; | ||
| 4727 | } | ||
| 4728 | |||
| 4729 | sub createHashProperty { | ||
| 4730 | |||
| 4731 | # Gives the template a new hash property (IV) | ||
| 4732 | # | ||
| 4733 | # Expected arguments | ||
| 4734 | # $name - The property name | ||
| 4735 | # | ||
| 4736 | # Optional arguments | ||
| 4737 | # %hash - The property is set to this hash (otherwise it is set to an empty hash) | ||
| 4738 | # | ||
| 4739 | # Return values | ||
| 4740 | # 'undef' on improper arguments, or if the property $name already exists, or if the | ||
| 4741 | # template has been 'fixed' (no new properties are allowed) | ||
| 4742 | # 1 on success | ||
| 4743 | |||
| 4744 | my ($self, $name, %hash) = @_; | ||
| 4745 | |||
| 4746 | # Check for improper arguments | ||
| 4747 | if (! defined $name) { | ||
| 4748 | |||
| 4749 | return $axmud::CLIENT->writeImproper($self->_objClass . '->createHashProperty', @_); | ||
| 4750 | } | ||
| 4751 | |||
| 4752 | if ( | ||
| 4753 | # Check the property doesn't already exist | ||
| 4754 | exists $self->{$name} | ||
| 4755 | # Check the template hasn't already been 'fixed' | ||
| 4756 | || $self->constFixedFlag | ||
| 4757 | # Check that the property isn't one of those specified by the GA::Client registry hash | ||
| 4758 | || $axmud::CLIENT->ivExists('constProfStandardHash', $name) | ||
| 4759 | ) { | ||
| 4760 | return undef; | ||
| 4761 | |||
| 4762 | } else { | ||
| 4763 | |||
| 4764 | # Add the property as a new instance variable | ||
| 4765 | $self->ivCreate($name, 'hash'); | ||
| 4766 | $self->ivPoke($name, %hash); | ||
| 4767 | } | ||
| 4768 | |||
| 4769 | return 1; | ||
| 4770 | } | ||
| 4771 | |||
| 4772 | sub removeProperty { | ||
| 4773 | |||
| 4774 | # Removes one of the properties (IVs) that were created with $self->createScalarProperty, | ||
| 4775 | # ->createArrayProperty or ->createHashProperty | ||
| 4776 | # (You can't use this function to remove any of the properties which exist as keys in | ||
| 4777 | # the GA::Client registry hash, or any property whose name begins with an underline) | ||
| 4778 | # | ||
| 4779 | # Expected arguments | ||
| 4780 | # $name - The name of the property to remove | ||
| 4781 | # | ||
| 4782 | # Return values | ||
| 4783 | # 'undef' if the property doesn't exist, if the property couldn't be removed, or on | ||
| 4784 | # improper arguments | ||
| 4785 | # 1 on success | ||
| 4786 | |||
| 4787 | my ($self, $name, $check) = @_; | ||
| 4788 | |||
| 4789 | # Check for improper arguments | ||
| 4790 | if (! defined $name || defined $check) { | ||
| 4791 | |||
| 4792 | return $axmud::CLIENT->writeImproper($self->_objClass . '->removeProperty', @_); | ||
| 4793 | } | ||
| 4794 | |||
| 4795 | if ( | ||
| 4796 | # Check the property already exists | ||
| 4797 | ! exists $self->{$name} | ||
| 4798 | # Check the template hasn't already been 'fixed' | ||
| 4799 | || $self->constFixedFlag | ||
| 4800 | # Check that the property isn't one of the standard ones (which can't therefore be | ||
| 4801 | # destroyed) | ||
| 4802 | || $axmud::CLIENT->ivExists('constProfStandardHash', $name) | ||
| 4803 | || substr($name, 0, 1) eq '_' | ||
| 4804 | ) { | ||
| 4805 | return undef; | ||
| 4806 | |||
| 4807 | } else { | ||
| 4808 | |||
| 4809 | # Destroy the property by destroying its instance variable | ||
| 4810 | return $self->ivDestroy($name); | ||
| 4811 | } | ||
| 4812 | } | ||
| 4813 | |||
| 4814 | ################## | ||
| 4815 | # Accessors - set | ||
| 4816 | |||
| 4817 | ################## | ||
| 4818 | # Accessors - get | ||
| 4819 | |||
| 4820 | sub category | ||
| 4821 | { $_[0]->{category} } | ||
| 4822 | sub constFixedFlag | ||
| 4823 | { $_[0]->{constFixedFlag} } | ||
| 4824 | } | ||
| 4825 | |||
| 4826 | { package Games::Axmud::Profile::Custom; | ||
| 4827 | |||
| 4828 | use strict; | ||
| 4829 | use warnings; | ||
| 4830 | # use diagnostics; | ||
| 4831 | |||
| 4832 | use Glib qw(TRUE FALSE); | ||
| 4833 | |||
| 4834 | our @ISA = qw(Games::Axmud::Generic::Profile Games::Axmud); | ||
| 4835 | |||
| 4836 | ################## | ||
| 4837 | # Constructors | ||
| 4838 | |||
| 4839 | sub new { | ||
| 4840 | |||
| 4841 | # Called by GA::Profile::Template->spawn | ||
| 4842 | # Creates a new instance of a custom profile | ||
| 4843 | # THIS METHOD SHOULD NOT BE CALLED DIRECTLY. Instead, call GA::Profile::Template->spawn | ||
| 4844 | # | ||
| 4845 | # Expected arguments | ||
| 4846 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 4847 | # $name - A unique string name for this profile (max 16 chars, containing | ||
| 4848 | # A-Za-z0-9_ - 1st char can't be number, non-Latin alphabets acceptable. | ||
| 4849 | # Must not exist as a key in the global hash of reserved names, | ||
| 4850 | # $axmud::CLIENT->constReservedHash) | ||
| 4851 | # $parentWorld - The name of the parent world profile, with which this profile is | ||
| 4852 | # associated | ||
| 4853 | # $category - What kind of profile this is. Matches the ->category of a | ||
| 4854 | # GA::Profile::Template (equivalent to 'world', 'race', 'guild', 'char') | ||
| 4855 | # | ||
| 4856 | # Optional arguments | ||
| 4857 | # $tempFlag - If set to TRUE, this is a temporary profile created for use with an 'edit' | ||
| 4858 | # window; $name is not checked for validity. Otherwise set to FALSE (or | ||
| 4859 | # 'undef') | ||
| 4860 | # | ||
| 4861 | # Return values | ||
| 4862 | # 'undef' on improper arguments or if $name is invalid | ||
| 4863 | # Blessed reference to the newly-created object on success | ||
| 4864 | |||
| 4865 | my ($class, $session, $name, $parentWorld, $category, $tempFlag, $check) = @_; | ||
| 4866 | |||
| 4867 | # Check for improper arguments | ||
| 4868 | if ( | ||
| 4869 | ! defined $class || ! defined $session || ! defined $name || ! defined $parentWorld | ||
| 4870 | || ! defined $category || defined $check | ||
| 4871 | ) { | ||
| 4872 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 4873 | } | ||
| 4874 | |||
| 4875 | if (! $tempFlag) { | ||
| 4876 | |||
| 4877 | # Check that $name is valid and not already in use by another profile | ||
| 4878 | if (! $axmud::CLIENT->nameCheck($name, 16)) { | ||
| 4879 | |||
| 4880 | return $axmud::CLIENT->writeError( | ||
| 4881 | 'Registry naming error: invalid name \'' . $name . '\'', | ||
| 4882 | $class . '->new', | ||
| 4883 | ); | ||
| 4884 | |||
| 4885 | } elsif ($session->ivExists('profHash', $name)) { | ||
| 4886 | |||
| 4887 | return $axmud::CLIENT->writeError( | ||
| 4888 | 'Registry naming error: profile \'' . $name . '\' already exists', | ||
| 4889 | $class . '->new', | ||
| 4890 | ); | ||
| 4891 | } | ||
| 4892 | |||
| 4893 | # Check that a matching template profile exists | ||
| 4894 | if (! $session->ivExists('templateHash', $category)) { | ||
| 4895 | |||
| 4896 | return $axmud::CLIENT->writeError( | ||
| 4897 | 'Registry naming error: no profile template of the category \'' . $category | ||
| 4898 | . '\' exists', | ||
| 4899 | $class . '->new', | ||
| 4900 | ); | ||
| 4901 | } | ||
| 4902 | } | ||
| 4903 | |||
| 4904 | # Setup | ||
| 4905 | my $self = { | ||
| 4906 | _objName => $name, | ||
| 4907 | _objClass => $class, | ||
| 4908 | _parentFile => 'otherprof', | ||
| 4909 | _parentWorld => $session->currentWorld->name, | ||
| 4910 | _privFlag => FALSE, # All IVs are public | ||
| 4911 | |||
| 4912 | # Standard profile IVs | ||
| 4913 | # -------------------- | ||
| 4914 | |||
| 4915 | name => $name, | ||
| 4916 | category => $category, | ||
| 4917 | # The name of parent world profile, with which this profile is associated | ||
| 4918 | parentWorld => $parentWorld, | ||
| 4919 | |||
| 4920 | # Hash of tasks that start whenever this profile is made a current profile (as soon as | ||
| 4921 | # the character is marked as 'logged in') - the profile's initial tasklist. Hash in | ||
| 4922 | # the form | ||
| 4923 | # $initTaskHash{unique_task_name} = blessed_reference_to_task_object | ||
| 4924 | initTaskHash => {}, | ||
| 4925 | # The order in which the tasks are started (not very important for tasks unless they | ||
| 4926 | # are Script tasks). List contains all the keys in $self->initTaskHash | ||
| 4927 | initTaskOrderList => [], | ||
| 4928 | # How many initial tasks have been created, in total (used to give each one a unique | ||
| 4929 | # name). Reset to 0 when the profile's initial tasklist is emptied | ||
| 4930 | initTaskTotal => 0, | ||
| 4931 | # Hash of scripts that start whenever this definiton is made a current profile (as soon | ||
| 4932 | # as the character is marked as 'logged in') - the profile's initial scriptlist. Hash | ||
| 4933 | # in the form | ||
| 4934 | # $initScriptHash{script_name} = mode | ||
| 4935 | # ...where 'script_name' matches the file from which the script is loaded, and 'mode' is | ||
| 4936 | # set to one of the following value: | ||
| 4937 | # 'no_task' - run the script without a task | ||
| 4938 | # 'run_task' - run the script from within a task | ||
| 4939 | # 'run_task_win' - run the script from within a task, in 'forced window' mode | ||
| 4940 | initScriptHash => {}, | ||
| 4941 | # The order in which the scripts are started. List contains all the keys in | ||
| 4942 | # $self->initScriptHash | ||
| 4943 | initScriptOrderList => [], | ||
| 4944 | # The name of the mission to start whenever a new session begins with this as a current | ||
| 4945 | # profile, as soon as the character is marked as logged in - but NOT when a current | ||
| 4946 | # profile is set after the login | ||
| 4947 | # Profiles are checked in priority order; only the first mission found is run. Set to | ||
| 4948 | # the name of the mission, or 'undef' | ||
| 4949 | initMission => undef, | ||
| 4950 | # A list of commands to send the the world whenever a new session begins with this as a | ||
| 4951 | # current profile, as soon as the character is marked as logged in - but NOT when a | ||
| 4952 | # current profile is set after the login | ||
| 4953 | # Profiles are checked in priority order; commands are sent from all profiles, but | ||
| 4954 | # duplicate commands are not sent | ||
| 4955 | # Commands are sent AFTER the commands specified by the current world profile's | ||
| 4956 | # ->columns, ->rows and ->sendSizeInfoFlag IVs (so this list doesn't need to include | ||
| 4957 | # them) | ||
| 4958 | initCmdList => [], | ||
| 4959 | |||
| 4960 | # Flag set to TRUE if this profile has EVER been a current profile (in which case, it | ||
| 4961 | # will have cages etc); set to FALSE if not (in which case, the parent file object | ||
| 4962 | # will set up cages etc when this profile first becomes a current profile) | ||
| 4963 | setupCompleteFlag => FALSE, | ||
| 4964 | # List containing notes written by this user for this profile, and available to the | ||
| 4965 | # Notepad task when it's running | ||
| 4966 | notepadList => [], | ||
| 4967 | # A hash to store any data your own plugins/scripts want to store (when a profile is | ||
| 4968 | # cloned, this data is not copied to the clone) | ||
| 4969 | privateHash => {}, | ||
| 4970 | |||
| 4971 | # The remaining instance variables - those which are unique to every category of custom | ||
| 4972 | # profile - are set by the calling function, GA::Profile::Template->spawn | ||
| 4973 | }; | ||
| 4974 | |||
| 4975 | # Bless the object into existence | ||
| 4976 | bless $self, $class; | ||
| 4977 | return $self; | ||
| 4978 | } | ||
| 4979 | |||
| 4980 | sub clone { | ||
| 4981 | |||
| 4982 | # Creates a clone of an existing custom profile | ||
| 4983 | # | ||
| 4984 | # Expected arguments | ||
| 4985 | # $session - The GA::Session which called this function (not stored as an IV) | ||
| 4986 | # $name - A unique string name for this profile (max 16 chars, containing | ||
| 4987 | # A-Za-z0-9_ - 1st char can't be number, non-Latin alphabets acceptable. | ||
| 4988 | # Must not exist as a key in the global hash of reserved names, | ||
| 4989 | # $axmud::CLIENT->constReservedHash) | ||
| 4990 | # | ||
| 4991 | # Return values | ||
| 4992 | # 'undef' on improper arguments or if $name is invalid | ||
| 4993 | # Blessed reference to the newly-created object on success | ||
| 4994 | |||
| 4995 | my ($self, $session, $name, $check) = @_; | ||
| 4996 | |||
| 4997 | # Local variables | ||
| 4998 | my $templObj; | ||
| 4999 | |||
| 5000 | # Check for improper arguments | ||
| 5001 | if (! defined $session || ! defined $name || defined $check) { | ||
| 5002 | |||
| 5003 | return $axmud::CLIENT->writeImproper($self->_objClass . '->clone', @_); | ||
| 5004 | } | ||
| 5005 | |||
| 5006 | # Check that $name is valid and not already in use by another profile | ||
| 5007 | if (! $axmud::CLIENT->nameCheck($name, 16)) { | ||
| 5008 | |||
| 5009 | return $axmud::CLIENT->writeError( | ||
| 5010 | 'Registry naming error: invalid name \'' . $name . '\'', | ||
| 5011 | $self->_objClass . '->clone', | ||
| 5012 | ); | ||
| 5013 | |||
| 5014 | } elsif ($session->ivExists('profHash', $name)) { | ||
| 5015 | |||
| 5016 | return $axmud::CLIENT->writeError( | ||
| 5017 | 'Registry naming error: profile \'' . $name . '\' already exists', | ||
| 5018 | $self->_objClass . '->clone', | ||
| 5019 | ); | ||
| 5020 | } | ||
| 5021 | |||
| 5022 | # Setup | ||
| 5023 | my $clone = { | ||
| 5024 | _objName => $name, | ||
| 5025 | _objClass => $self->_objClass, | ||
| 5026 | _parentFile => 'otherprof', | ||
| 5027 | _parentWorld => $session->currentWorld->name, | ||
| 5028 | _privFlag => FALSE, # All IVs are public | ||
| 5029 | |||
| 5030 | # Standard profile IVs | ||
| 5031 | # -------------------- | ||
| 5032 | |||
| 5033 | name => $name, | ||
| 5034 | category => $self->category, | ||
| 5035 | parentWorld => undef, | ||
| 5036 | |||
| 5037 | initTaskHash => {}, # Set below | ||
| 5038 | initTaskOrderList => [], # Set below | ||
| 5039 | initTaskTotal => $self->initTaskTotal, | ||
| 5040 | initScriptHash => {}, # Set below | ||
| 5041 | initScriptOrderList => [], # Set below | ||
| 5042 | initMission => $self->initMission, | ||
| 5043 | initCmdList => [$self->initCmdList], | ||
| 5044 | |||
| 5045 | setupCompleteFlag => FALSE, # Clone never been a current profile | ||
| 5046 | notepadList => [$self->notepadList], | ||
| 5047 | privateHash => {}, | ||
| 5048 | }; | ||
| 5049 | |||
| 5050 | # Bless the cloned object into existence | ||
| 5051 | bless $clone, $self->_objClass; | ||
| 5052 | |||
| 5053 | # Get the parent template object | ||
| 5054 | $templObj = $session->ivShow('templateHash', $self->category); | ||
| 5055 | |||
| 5056 | # Clone the instance variables for this category of custom profile | ||
| 5057 | OUTER: foreach my $iv ($self->ivList) { | ||
| 5058 | |||
| 5059 | # Don't use standard profile IVs specified by the GA::Client registry hash | ||
| 5060 | if (! $axmud::CLIENT->ivExists('constProfStandardHash', $iv)) { | ||
| 5061 | |||
| 5062 | $clone->{$iv} = $self->{$iv}; | ||
| 5063 | } | ||
| 5064 | } | ||
| 5065 | |||
| 5066 | # Also need to clone everything in the initial tasklist | ||
| 5067 | $clone->cloneInitTaskList($self); | ||
| 5068 | |||
| 5069 | return $clone; | ||
| 5070 | } | ||
| 5071 | |||
| 5072 | ################## | ||
| 5073 | # Methods | ||
| 5074 | |||
| 5075 | ################## | ||
| 5076 | # Accessors - set | ||
| 5077 | |||
| 5078 | ################## | ||
| 5079 | # Accessors - get | ||
| 5080 | } | ||
| 5081 | |||
| 5082 | # Package must return a true value | ||
| 5083 | 1 |