Games-Axmud

 view release on metacpan or  search on metacpan

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        #   Blessed reference to the newly-created object on success

        my ($self, $session, $taskType, $profName, $profCategory, $check) = @_;

        # Check for improper arguments
        if (
            ! defined $session || ! defined $taskType || defined $check
            || ($taskType ne 'current' && $taskType ne 'initial')
            || ($taskType eq 'initial' && (! defined $profName || ! defined $profCategory))
        ) {
            return $axmud::CLIENT->writeImproper($self->_objClass . '->clone', @_);
        }

        # For initial tasks, check that $profName exists
        if (
            $taskType eq 'initial'
            && defined $profName
            && ! $session->ivExists('profHash', $profName)
        ) {
            return $axmud::CLIENT->writeError(
                'Can\'t create cloned task because \'' . $profName . '\' profile doesn\'t exist',
                $self->_objClass . '->clone',
            );
        }

        # Check that the task doesn't belong to a disabled plugin (in which case, it can't be
        #   cloned)
        if (! $self->checkPlugins()) {

            return undef;
        }

        # Create the new task, using default settings and parameters
        my $clone = $self->_objClass->new($session, $taskType, $profName, $profCategory);

        # Most of the cloned task's settings have default values, but a few are copied from the
        #   original
        $self->cloneTaskSettings($clone);

        # Give the new (cloned) task the same initial parameters as the original one
        $clone->{skillList}             = [$self->skillList];
        $clone->{currentSkill}          = $self->currentSkill;
        $clone->{currentSkillNum}       = $self->currentSkillNum;

        $clone->{advanceMode}           = $self->advanceMode;
        $clone->{advanceSuccessFlag}    = $self->advanceSuccessFlag;
        $clone->{advanceFailFlag}       = $self->advanceFailFlag;
        $clone->{waitTime}              = $self->waitTime;
        $clone->{nextCheckTime}         = $self->nextCheckTime;

        $clone->{warningFlag}           = $self->warningFlag;

        # Cloning complete
        return $clone;
    }

#   sub preserve {}             # Inherited from generic task

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub main {}                 # Inherited from generic task

#   sub doShutdown {}           # Inherited from generic task

#   sub doReset {}              # Inherited from generic task

#   sub doFirstStage {}         # Inherited from generic task

    sub doStage {

        # Called by $self->main to process all stages (except stage 1)
        #
        # Expected arguments
        #   (none besides $self)
        #
        # Return values
        #   'undef' on improper arguments or if this function sets that task's ->status IV to
        #       'finished' or sets its ->shutdownFlag to TRUE
        #   Otherwise, we normally return the new value of $self->stage

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doStage', @_);
        }

        if ($self->stage == 2) {

            my ($worldObj, $charObj);

            # No point in continuing if there is no current guild or character
            if (! $self->session->currentGuild || ! $self->session->currentChar) {

                if (! $self->session->currentGuild) {

                    $self->writeError(
                        'Advance task halting because there is no current guild profile',
                        $self->_objClass . '->doStage',
                    );

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        # Create the new task, using default settings and parameters
        my $clone = $self->_objClass->new($session, $taskType, $profName, $profCategory);

        # Most of the cloned task's settings have default values, but a few are copied from the
        #   original
        $self->cloneTaskSettings($clone);

        # Give the new (cloned) task the same initial parameters as the original one
        $clone->{fightCmdList}          = [$self->fightCmdList];
        $clone->{interactCmdList}       = [$self->interactCmdList];
        $clone->{announceFlag}          = $self->announceFlag;

        # Cloning complete
        return $clone;
    }

    sub preserve {

        # Called by $self->main whenever this task is reset, in order to preserve some if its task
        #   parameters (but not necessarily all of them)
        #
        # Expected arguments
        #   $newTask    - The new task which has been created, to which some of this task's instance
        #                   variables might have to be transferred
        #
        # Return values
        #   'undef' on improper arguments, or if $newTask isn't in the GA::Session's current
        #       tasklist
        #   1 on success

        my ($self, $newTask, $check) = @_;

        # Check for improper arguments
        if (! defined $newTask || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->preserve', @_);
        }

        # Check the task is in the current tasklist
        if (! $self->session->ivExists('currentTaskHash', $newTask->uniqueName)) {

            return $self->writeWarning(
                '\'' . $self->uniqueName . '\' task missing from the current tasklist',
                $self->_objClass . '->preserve',
            );
        }

        # Preserve some task parameters (the others are left with their default settings, some of
        #   which will be re-initialised in stage 2)

        # Preserve the command lists
        $newTask->ivPoke('fightCmdList', $self->fightCmdList);
        $newTask->ivPoke('interactCmdList', $self->interactCmdList);
        $newTask->ivPoke('announceFlag', $self->announceFlag);

        return 1;
    }

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub init {}                 # Inherited from generic task

    sub doInit {

        # Called by $self->init, just before the task completes its setup ($self->init)
        #
        # Expected arguments
        #   (none besides $self)
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doInit', @_);
        }

        # If triggers have already been created for this task, remove them before replacing them
        #   with new triggers
        $self->session->tidyInterfaces($self);

        # Set up dependent triggers for fights
        $self->resetFightTriggers();
        # Set up dependent triggers for interactions
        $self->resetInteractionTriggers();

        return 1;
    }

#   sub doShutdown {}           # Inherited from generic task

#   sub doReset {}              # Inherited from generic task

    sub resetFightTriggers {

        # Called by $self->doInit to set up triggers for fights, based on the patterns stored in the
        #   current world profile

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        # Cloning complete
        return $clone;
    }

    sub preserve {

        # Called by $self->main whenever this task is reset, in order to preserve some if its task
        #   parameters (but not necessarily all of them)
        #
        # Expected arguments
        #   $newTask    - The new task which has been created, to which some of this task's instance
        #                   variables might have to be transferred
        #
        # Return values
        #   'undef' on improper arguments, or if $newTask isn't in the GA::Session's current
        #       tasklist
        #   1 on success

        my ($self, $newTask, $check) = @_;

        # Check for improper arguments
        if (! defined $newTask || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->preserve', @_);
        }

        # Check the task is in the current tasklist
        if (! $self->session->ivExists('currentTaskHash', $newTask->uniqueName)) {

            return $self->writeWarning(
                '\'' . $self->uniqueName . '\' task missing from the current tasklist',
                $self->_objClass . '->preserve',
            );
        }

        # Preserve some task parameters (the others are left with their default settings, some of
        #   which will be re-initialised in stage 2)

        # Preserve summary channel IVs
        $newTask->ivPoke('summaryMode', $self->summaryMode);
        $newTask->ivPoke('summaryChannel', $self->summaryChannel);

        # Preserve initial and ignorable channels
        $newTask->ivPoke('initChannelList', $self->initChannelList);
        $newTask->ivPoke('ignoreChannelList', $self->ignoreChannelList);

        # Preserve sound effect and urgency settings
        $newTask->ivPoke('soundEffectHash', $self->soundEffectHash);
        $newTask->ivPoke('urgencyHash', $self->urgencyHash);

        # Preserve other customisation settings
        $newTask->ivPoke('tabCloseButtonFlag', $self->tabCloseButtonFlag);
        $newTask->ivPoke('capitaliseFlag', $self->capitaliseFlag);
        $newTask->ivPoke('useColourStyleFlag', $self->useColourStyleFlag);

        return 1;
    }

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub init {}                 # Inherited from generic task

    sub doInit {

        # Called by $self->init, just before the task completes its setup ($self->init)
        #
        # Expected arguments
        #   (none besides $self)
        #
        # Return values
        #   'undef' on improper arguments or if a Divert task is running
        #   1 otherwise

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doInit', @_);
        }

        # The Channels and Divert tasks can't run at the same time
        if ($self->session->divertTask) {

            $self->writeError(
                'The Channels and Divert tasks cannot run at the same time, so halting the'
                . ' Channels task',
                $self->_objClass . '->doStage',
            );

            # Mark the task to be shutdown
            $self->ivPoke('shutdownFlag', TRUE);
            return undef;
        }

        # If triggers have already been created for this task, remove them before replacing them
        #   with new triggers
        $self->session->tidyInterfaces($self);

        if (! $self->resetTriggers()) {

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        $clone->{helpList}              = [$self->helpList];

        # Cloning complete
        return $clone;
    }

    sub preserve {

        # Called by $self->main whenever this task is reset, in order to preserve some if its task
        #   parameters (but not necessarily all of them)
        #
        # Expected arguments
        #   $newTask    - The new task which has been created, to which some of this task's instance
        #                   variables might have to be transferred
        #
        # Return values
        #   'undef' on improper arguments, or if $newTask isn't in the GA::Session's current
        #       tasklist
        #   1 on success

        my ($self, $newTask, $check) = @_;

        # Check for improper arguments
        if (! defined $newTask || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->preserve', @_);
        }

        # Check the task is in the current tasklist
        if (! $self->session->ivExists('currentTaskHash', $newTask->uniqueName)) {

            return $self->writeWarning(
                '\'' . $self->uniqueName . '\' task missing from the current tasklist',
                $self->_objClass . '->preserve',
            );
        }

        # Preserve some task parameters (the others are left with their default settings, some of
        #   which will be re-initialised in stage 2)

        # Preserve the flag that says whether this is the lead chat task, or not
        $newTask->ivPoke('leadTaskFlag', $self->leadTaskFlag);
        # Preserve the GA::Obj::ChatContact, if there is one
        $newTask->ivPoke('chatContactObj', $self->chatContactObj);
        # Preserve colours
        $newTask->ivPoke('chatOutColour', $self->chatOutColour);
        $newTask->ivPoke('chatInColour', $self->chatInColour);
        $newTask->ivPoke('chatEchoColour', $self->chatEchoColour);
        $newTask->ivPoke('systemColour', $self->systemColour);
        $newTask->ivPoke('remoteColour', $self->remoteColour);
        $newTask->ivPoke('snoopColour', $self->snoopColour);
        # Preserve the smiley settings
        $newTask->ivPoke('allowSmileyFlag', $self->allowSmileyFlag);
        $newTask->ivPoke('smileySizeFactor', $self->smileySizeFactor);

        return 1;
    }

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

    sub ttsSwitchFlagAttrib {

        # Called by GA::Cmd::Switch->do and PermSwitch->do
        # Users can use the client command ';switch' to interact with individual tasks, typically
        #   telling them to turn on/off the automatic reading out of information (e.g. the Locator
        #   task can be told to start or stop reading out room titles as they are received from
        #   the world)
        # The ';switch' command is in the form ';switch <flag_attribute>'. The ';switch' command
        #   looks up the <flag_attribute> (which is a string, not a TRUE/FALSE value) in
        #   GA::Client->ttsFlagAttribHash, which tells it which task to call
        #
        # Expected arguments
        #   $flagAttrib - The TTS flag attribute specified by the calling function. Must be one of
        #                   the keys in $self->ttsFlagAttribHash
        #
        # Optional arguments
        #   $noSpecialFlag
        #               - Set to TRUE when called by GA::Cmd::PermSwitch->do, in which case only
        #                   this task's hash of flag attributes is updated. Otherwise set to FALSE
        #                   (or 'undef'), in which case other things can happen when a flag
        #                   attribute is switched. For all built-in tasks, there is no difference
        #                   in behaviour
        #
        # Return values
        #   'undef' on improper arguments or if the $flagAttrib doesn't exist in this task's
        #       ->ttsFlagAttribHash
        #   Otherwise returns a confirmation message for the calling function to display

        my ($self, $flagAttrib, $noSpecialFlag, $check) = @_;

        # Local variables
        my $msg;

        # Check for improper arguments
        if (! defined $flagAttrib || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->ttsSwitchFlagAttrib', @_);
        }

        # TTS flag attributes are case-insensitive
        $flagAttrib = lc($flagAttrib);

        # Check that the specified flag attribute is actually used by this task (';switch' or
        #   ';permswitch' should carry out this check, but better safe than sorry)
        if (! $self->ivExists('ttsFlagAttribHash', $flagAttrib)) {

            return undef;

        } else {

            # If a current task performs some kind of action, when a flag attribute is switched,
            #   the code for the action should be placed here. (Tasks in the global initial
            #   tasklist can't perform an action, of course.)
            if (! $noSpecialFlag) {

                # (no actions to perform)
            }

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        # Check for improper arguments
        if (
            ! defined $session || ! defined $taskType || defined $check
            || ($taskType ne 'current' && $taskType ne 'initial')
            || ($taskType eq 'initial' && (! defined $profName || ! defined $profCategory))
        ) {
            return $axmud::CLIENT->writeImproper($self->_objClass . '->clone', @_);
        }

        # For initial tasks, check that $profName exists
        if (
            $taskType eq 'initial'
            && defined $profName
            && ! $session->ivExists('profHash', $profName)
        ) {
            return $axmud::CLIENT->writeError(
                'Can\'t create cloned task because \'' . $profName . '\' profile doesn\'t exist',
                $self->_objClass . '->clone',
            );
        }

        # Check that the task doesn't belong to a disabled plugin (in which case, it can't be
        #   cloned)
        if (! $self->checkPlugins()) {

            return undef;
        }

        # Create the new task, using default settings and parameters
        my $clone = $self->_objClass->new($session, $taskType, $profName, $profCategory);

        # Most of the cloned task's settings have default values, but a few are copied from the
        #   original
        $self->cloneTaskSettings($clone);

        # Give the new (cloned) task the same initial parameters as the original one
        $clone->{enabledFlag}           = $self->enabledFlag;
        $clone->{compassHash}           = {$self->compassHash};
        $clone->{cmdHash}               = {$self->cmdHash};
        $clone->{cmdKeycodeHash}        = {$self->cmdKeycodeHash};

        $clone->{radioTableObj}         = $self->radioTableObj;
        $clone->{radioTableObj2}        = $self->radioTableObj2;
        $clone->{comboTableObj}         = $self->comboTableObj;

        $clone->{macroList}             = [$self->macroList];
        $clone->{macroHash}             = {$self->macroHash};

        $clone->{keypadDirHash}         = {$self->keypadDirHash};
        $clone->{keypadCmdHash}         = {$self->keypadCmdHash};
        $clone->{keypadHintHash}        = {$self->keypadHintHash};

        # Cloning complete
        return $clone;
    }

#   sub preserve {}             # Inherited from generic task

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub init {}                 # Inherited from generic task

    sub doInit {

        # Called by $self->init, just before the task completes its setup ($self->init)
        #
        # Expected arguments
        #   (none besides $self)
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doInit', @_);
        }

        # Set up the keyboard macros
        $self->resetMacros();

        # If the task has recently been updated, quickest way to update the window is to remove all
        #   the current table objects, before creating new ones
        if ($self->hasResetFlag) {

            if (! defined $self->winObj->tableStripObj->removeAllTableObjs()) {

                # Operation failed; task must close
                $self->ivPoke('shutdownFlag', TRUE);
                return 1;
            }
        }

        # Draw widgets for the task window
        $self->createWidgets();

        # If the task window should start enabled, then enable it (by pseudo-clicking the second
        #   radio button)

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        $clone->{sensitivity}           = $self->sensitivity;

        $clone->{firstCheckTime}        = $self->firstCheckTime;
        $clone->{waitTime}              = $self->waitTime;
        $clone->{nextCheckTime}         = $self->nextCheckTime;
        $clone->{ignoreCheckFlag}       = $self->ignoreCheckFlag;

        $clone->{maxObjTime}            = $self->maxObjTime;
        $clone->{nextObjTime}           = $self->nextObjTime;

        # Cloning complete
        return $clone;
    }

    sub preserve {

        # Called by $self->main whenever this task is reset, in order to preserve some if its task
        #   parameters (but not necessarily all of them)
        #
        # Expected arguments
        #   $newTask    - The new task which has been created, to which some of this task's instance
        #                   variables might have to be transferred
        #
        # Return values
        #   'undef' on improper arguments, or if $newTask isn't in the GA::Session's current
        #       tasklist
        #   1 on success

        my ($self, $newTask, $check) = @_;

        # Check for improper arguments
        if (! defined $newTask || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->preserve', @_);
        }

        # Check the task is in the current tasklist
        if (! $self->session->ivExists('currentTaskHash', $newTask->uniqueName)) {

            return $self->writeWarning(
                '\'' . $self->uniqueName . '\' task missing from the current tasklist',
                $self->_objClass . '->preserve',
            );
        }

        # Preserve some task parameters (the others are left with their default settings, some of
        #   which will be re-initialised in stage 2)

        $newTask->ivPoke('checkOnceFlag', $self->checkOnceFlag);
        $newTask->ivPoke('sensitivity', $self->sensitivity);
        $newTask->ivPoke('firstCheckTime', $self->firstCheckTime);
        $newTask->ivPoke('waitTime', $self->waitTime);
        $newTask->ivPoke('ignoreCheckFlag', $self->ignoreCheckFlag);
        $newTask->ivPoke('maxObjTime', $self->maxObjTime);

        return 1;
    }

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub main {}                 # Inherited from generic task

#   sub doShutdown {}           # Inherited from generic task

#   sub doReset {}              # Inherited from generic task

#   sub doFirstStage {          # Inherited from generic task

    sub doStage {

        # Called by $self->main to process all stages (except stage 1)
        #
        # Expected arguments
        #   (none besides $self)
        #
        # Return values
        #   'undef' on improper arguments or if this function sets that task's ->status IV to
        #       'finished' or sets its ->shutdownFlag to TRUE
        #   Otherwise, we normally return the new value of $self->stage

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doStage', @_);
        }

        if ($self->stage == 2) {

            # Can't do anything until the current character has been set, the user has logged
            #   in to the world and the Inventory task has started
            if (
                ! $self->session->currentChar
                || ! $self->session->loginFlag
                || ! $self->session->inventoryTask
                || ! $self->session->inventoryTask->activeFlag
            ) {
                # Repeat this stage indefinitely
                return $self->ivPoke('stage', 2);
            }

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        # Create the new task, using default settings and parameters
        my $clone = $self->_objClass->new($session, $taskType, $profName, $profCategory);

        # Most of the cloned task's settings have default values, but a few are copied from the
        #   original
        $self->cloneTaskSettings($clone);

        # Give the new (cloned) task the same initial parameters as the original one
        $clone->{showInfoFlag}          = $self->showInfoFlag;
        $clone->{useMacrosFlag}         = {$self->useMacrosFlag};
        $clone->{macroMode}             = {$self->macroMode};

        # Cloning complete
        return $clone;
    }

    sub preserve {

        # Called by $self->main whenever this task is reset, in order to preserve some if its task
        #   parameters (but not necessarily all of them)
        #
        # Expected arguments
        #   $newTask    - The new task which has been created, to which some of this task's instance
        #                   variables might have to be transferred
        #
        # Return values
        #   'undef' on improper arguments, or if $newTask isn't in the GA::Session's current
        #       tasklist
        #   1 on success

        my ($self, $newTask, $check) = @_;

        # Check for improper arguments
        if (! defined $newTask || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->preserve', @_);
        }

        # Check the task is in the current tasklist
        if (! $self->session->ivExists('currentTaskHash', $newTask->uniqueName)) {

            return $self->writeWarning(
                '\'' . $self->uniqueName . '\' task missing from the current tasklist',
                $self->_objClass . '->preserve',
            );
        }

        # Preserve some task parameters (the others are left with their default settings, some of
        #   which will be re-initialised in stage 2)

        # Preserve the command lists
        $newTask->ivPoke('showInfoFlag', $self->showInfoFlag);
        $newTask->ivPoke('useMacrosFlag', $self->useMacrosFlag);
        $newTask->ivPoke('macroMode', $self->macroMode);

        return 1;
    }

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub main {}                 # Inherited from generic task

#   sub doShutdown {}           # Inherited from generic task

#   sub doReset {}              # Inherited from generic task

#   sub doFirstStage {}         # Inherited from generic task

    sub doStage {

        # Called by $self->main to process all stages (except stage 1)
        #
        # Expected arguments
        #   (none besides $self)
        #
        # Return values
        #   'undef' on improper arguments or if this function sets that task's ->status IV to
        #       'finished' or sets its ->shutdownFlag to TRUE
        #   Otherwise, we normally return the new value of $self->stage

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doStage', @_);
        }

        if ($self->stage == 2) {

            # Create macros to intercept CTRL+1, CTRL+2 ... CTRL+9
            if (! $self->resetMacros()) {

                $self->writeError(
                    'Could not create macros for the ' . $self->prettyName . ' task, so halting',
                    $self->_objClass . '->doStage',
                );

                # Mark the task to be shutdown
                $self->ivPoke('shutdownFlag', TRUE);
                return undef;

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        #   Gtk3::TextView and its surrounding area
        $self->{previousColour}         = undef;

        # The operating mode - 'default' when no time is visible, 'up' when counting up, 'down'
        #   when counting down
        $self->{countMode}              = 'default';
        # Flag set to TRUE when the 'Pause' button has been pressed
        $self->{pausedFlag}             = FALSE;
        # The time (matches GA::Session->sessionTime) at which the clock started
        $self->{clockStart}             = undef;
        # The time (matches GA::Session->sessionTime) at which the clock should stop
        $self->{clockStop}              = undef;
        # The time (matches GA::Session->sessionTime) at which the clock was paused; set back to
        #   'undef' when the clock resumes ticking
        $self->{clockFreeze}            = undef;
        # How long the clock runs. ->clockTarget is the time in seconds; ->clockShow is the number
        #   of seconds left
        $self->{clockTarget}            = undef;
        $self->{clockLeft}              = undef;
        # What time (matches ->clockLeft) at which to show a warning
        $self->{clockWarning}           = undef;

        # Sound effects. If 'undef', an empty string or an unrecognised sound effect, or if sound is
        #   turned off, nothing is played
        $self->{stopEffect}             = 'alert';
        $self->{warningEffect}          = 'bell';

        # Bless task
        bless $self, $class;

        # For all tasks that aren't temporary...
        if ($taskType) {

            # Check that the task doesn't belong to a disabled plugin (in which case, it can't be
            #   added to any current, initial or custom tasklist)
            if (! $self->checkPlugins()) {

                return undef;
            }

            # Set the parent file object
            $self->setParentFileObj($session, $taskType, $profName, $profCategory);

            # Create entries in tasklists, if possible
            if (! $self->updateTaskLists($session)) {

                return undef;
            }
        }

        # Task creation complete
        return $self;
    }

#   sub clone {}                # Inherited from generic task

#   sub preserve {}             # Inherited from generic task

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub main {}                 # Inherited from generic task

#   sub doShutdown {}           # Inherited from generic task

#   sub doReset {}              # Inherited from generic task

#   sub doFirstStage {}         # Inherited from generic task

    sub doStage {

        # Called by $self->main to process all stages (except stage 1)
        #
        # Expected arguments
        #   (none besides $self)
        #
        # Return values
        #   'undef' on improper arguments or if this function sets that task's ->status IV to
        #       'finished' or sets its ->shutdownFlag to TRUE
        #   Otherwise, we normally return the new value of $self->stage

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doStage', @_);
        }

        if ($self->stage == 2) {

            # Draw widgets for the task window
            $self->createWidgets();

            # If initialisation IVs were set, we can start the clock immediately
            if (defined $self->initMode) {

                $self->startClock($self->initMode, $self->initTime);
            }

            return $self->ivPoke('stage', 3);

lib/Games/Axmud/Task.pm  view on Meta::CPAN


            return $axmud::CLIENT->writeImproper($self->_objClass . '->preserve', @_);
        }

        # Check the task is in the current tasklist
        if (! $self->session->ivExists('currentTaskHash', $newTask->uniqueName)) {

            return $self->writeWarning(
                '\'' . $self->uniqueName . '\' task missing from the current tasklist',
                $self->_objClass . '->preserve',
            );
        }

        # Preserve some task parameters (the others are left with their default settings, some of
        #   which will be re-initialised in stage 2)

        # Preserve the default colour
        $newTask->ivPoke('defaultColour', $self->defaultColour);
        # Preserve the background colours
        $newTask->ivPoke('tellAlertColour', $self->tellAlertColour);
        $newTask->ivPoke('socialAlertColour', $self->socialAlertColour);
        $newTask->ivPoke('customAlertColour', $self->customAlertColour);
        $newTask->ivPoke('warningAlertColour', $self->warningAlertColour);
        $newTask->ivPoke('otherAlertColour', $self->otherAlertColour);
        # Preserve intervals before resetting the background colour
        $newTask->ivPoke('tellAlertInterval', $self->tellAlertInterval);
        $newTask->ivPoke('socialAlertInterval', $self->socialAlertInterval);
        $newTask->ivPoke('customAlertInterval', $self->customAlertInterval);
        $newTask->ivPoke('warningAlertInterval', $self->warningAlertInterval);
        $newTask->ivPoke('otherAlertInterval', $self->otherAlertInterval);
        # Preserve sound effects
        $newTask->ivPoke('tellAlertSound', $self->tellAlertSound);
        $newTask->ivPoke('socialAlertSound', $self->socialAlertSound);
        $newTask->ivPoke('customAlertSound', $self->customAlertSound);
        $newTask->ivPoke('warningAlertSound', $self->warningAlertSound);
        $newTask->ivPoke('otherAlertSound', $self->otherAlertSound);
        # Preserve character limits
        $newTask->ivPoke('tellCharLimit', $self->tellCharLimit);
        $newTask->ivPoke('socialCharLimit', $self->socialCharLimit);
        $newTask->ivPoke('customCharLimit', $self->customCharLimit);
        $newTask->ivPoke('warningCharLimit', $self->warningCharLimit);
        $newTask->ivPoke('otherCharLimit', $self->otherCharLimit);
        # Preserve room flags
        $newTask->ivPoke('tellRoomFlag', $self->tellRoomFlag);
        $newTask->ivPoke('socialRoomFlag', $self->socialRoomFlag);
        $newTask->ivPoke('customRoomFlag', $self->customRoomFlag);
        $newTask->ivPoke('warningRoomFlag', $self->warningRoomFlag);
        $newTask->ivPoke('otherRoomFlag', $self->otherRoomFlag);
        # Preserve urgency hint flags
        $newTask->ivPoke('tellUrgencyFlag', $self->tellUrgencyFlag);
        $newTask->ivPoke('socialUrgencyFlag', $self->socialUrgencyFlag);
        $newTask->ivPoke('customUrgencyFlag', $self->customUrgencyFlag);
        $newTask->ivPoke('warningUrgencyFlag', $self->warningUrgencyFlag);
        $newTask->ivPoke('otherUrgencyFlag', $self->otherUrgencyFlag);

        return 1;
    }

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

    sub ttsSwitchFlagAttrib {

        # Called by GA::Cmd::Switch->do and PermSwitch->do
        # Users can use the client command ';switch' to interact with individual tasks, typically
        #   telling them to turn on/off the automatic reading out of information (e.g. the Locator
        #   task can be told to start or stop reading out room titles as they are received from
        #   the world)
        # The ';switch' command is in the form ';switch <flag_attribute>'. The ';switch' command
        #   looks up the <flag_attribute> (which is a string, not a TRUE/FALSE value) in
        #   GA::Client->ttsFlagAttribHash, which tells it which task to call
        #
        # Expected arguments
        #   $flagAttrib - The TTS flag attribute specified by the calling function. Must be one of
        #                   the keys in $self->ttsFlagAttribHash
        #
        # Optional arguments
        #   $noSpecialFlag
        #               - Set to TRUE when called by GA::Cmd::PermSwitch->do, in which case only
        #                   this task's hash of flag attributes is updated. Otherwise set to FALSE
        #                   (or 'undef'), in which case other things can happen when a flag
        #                   attribute is switched. For all built-in tasks, there is no difference
        #                   in behaviour
        #
        # Return values
        #   'undef' on improper arguments or if the $flagAttrib doesn't exist in this task's
        #       ->ttsFlagAttribHash
        #   Otherwise returns a confirmation message for the calling function to display

        my ($self, $flagAttrib, $noSpecialFlag, $check) = @_;

        # Local variables
        my $msg;

        # Check for improper arguments
        if (! defined $flagAttrib || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->ttsSwitchFlagAttrib', @_);
        }

        # TTS flag attributes are case-insensitive
        $flagAttrib = lc($flagAttrib);

        # Check that the specified attribute flag is actually used by this task (';switch' should
        #   carry out this check, but better safe than sorry)
        if (! $self->ivExists('ttsFlagAttribHash', $flagAttrib)) {

            return undef;

        } else {

            # If a current task performs some kind of action, when a flag attribute is switched,
            #   the code for the action should be placed here. (Tasks in the global initial
            #   tasklist can't perform an action, of course.)
            if (! $noSpecialFlag) {

                # (no actions to perform)
            }

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        # Create the new task, using default settings and parameters
        my $clone = $self->_objClass->new($session, $taskType, $profName, $profCategory);

        # Most of the cloned task's settings have default values, but a few are copied from the
        #   original
        $self->cloneTaskSettings($clone);

        # Give the new (cloned) task the same initial parameters as the original one
#        $clone->{frameObj}              = $self->frameObj;

        # Cloning complete
        return $clone;
    }

    sub preserve {

        # Called by $self->main whenever this task is reset, in order to preserve some if its task
        #   parameters (but not necessarily all of them)
        #
        # Expected arguments
        #   $newTask    - The new task which has been created, to which some of this task's instance
        #                   variables might have to be transferred
        #
        # Return values
        #   'undef' on improper arguments, or if $newTask isn't in the GA::Session's current
        #       tasklist
        #   1 on success

        my ($self, $newTask, $check) = @_;

        # Check for improper arguments
        if (! defined $newTask || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->preserve', @_);
        }

        # Check the task is in the current tasklist
        if (! $self->session->ivExists('currentTaskHash', $newTask->uniqueName)) {

            return $self->writeWarning(
                '\'' . $self->uniqueName . '\' task missing from the current tasklist',
                $self->_objClass . '->preserve',
            );
        }

        # Preserve some task parameters (the others are left with their default settings, some of
        #   which will be re-initialised in stage 2)

        # Preserve the GA::Mxp::Frame object and the window's preferred size/position
        $newTask->ivPoke('frameObj', $self->frameObj);
        $newTask->ivPoke('leftPixels', $self->leftPixels);
        $newTask->ivPoke('topPixels', $self->topPixels);
        $newTask->ivPoke('widthPixels', $self->widthPixels);
        $newTask->ivPoke('heightPixels', $self->heightPixels);

        return 1;
    }

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

    sub openWin {

        # Called by the task's ->main method or by its ->toggleWin method
        # Tries to open each type of task window in $self->winPreferList, halting at the first
        #   successful attempt (or when all attempts fail)
        #
        # Expected arguments
        #   (none besides self)
        #
        # Optional arguments
        #   $winmap     - Ignored if specified
        #   @preferList - Ignored if specified
        #
        # Return values
        #   'undef' on improper arguments or if a task window is not opened
        #   1 if a window is opened

        my ($self, $winmap, @preferList) = @_;

        # Local variables
        my ($winObj, $workspaceObj, $gridObj, $layer);

        # (No improper arguments to check)

        # We want to open the window at a preferred size and position, so we use our own code,
        #   rather than code in the generic task
        # Also, if $winmap / @preferList are specified, they is ignored; this function only opens a
        #   'grid' window using a 'basic_fill' winmap
        # Only the workspace used by the session's 'main' window is used; if the task window can't
        #   be opened there, it's not opened at all

        # If $self->frameObj isn't set, there's no point in opening a task window
        if (! $self->frameObj) {

            return undef;
        }

        # Set the task IV to enable/disable scrolling
        if (! $self->frameObj->scrollingFlag) {

            $self->ivPoke('noScrollFlag', TRUE);
        }

        # Prepare arguments
        $workspaceObj = $self->session->mainWin->workspaceObj;
        $gridObj = $workspaceObj->findWorkspaceGrid($self->session);

        # Use the layer one higher than the highest window (ignoring other Frame task windows, of

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        $clone->{startFlag}             = $self->startFlag;
        $clone->{startLineTextList}     = [$self->startLineTextList];
        $clone->{useLineList}           = [$self->useLineList];
        $clone->{lastLine}              = $self->lastLine;

        $clone->{inventoryList}         = [$self->inventoryList];
        $clone->{previousList}          = [$self->previousList];
        $clone->{sensitivity}           = $self->sensitivity;

        $clone->{refreshWinFlag}        = $self->refreshWinFlag;

        # Cloning complete
        return $clone;
    }

    sub preserve {

        # Called by $self->main whenever this task is reset, in order to preserve some if its task
        #   parameters (but not necessarily all of them)
        #
        # Expected arguments
        #   $newTask    - The new task which has been created, to which some of this task's instance
        #                   variables might have to be transferred
        #
        # Return values
        #   'undef' on improper arguments, or if $newTask isn't in the GA::Session's current
        #       tasklist
        #   1 on success

        my ($self, $newTask, $check) = @_;

        # Check for improper arguments
        if (! defined $newTask || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->preserve', @_);
        }

        # Check the task is in the current tasklist
        if (! $self->session->ivExists('currentTaskHash', $newTask->uniqueName)) {

            return $self->writeWarning(
                '\'' . $self->uniqueName . '\' task missing from the current tasklist',
                $self->_objClass . '->preserve',
            );
        }

        # Preserve some task parameters (the others are left with their default settings, some of
        #   which will be re-initialised in stage 2)

        # Preserve the inventory lists so we don't lose track of what we have in containers (like
        #   sacks). Don't preserve the previous inventory
        $newTask->ivPoke('inventoryList', $self->inventoryList);
        # Preserve the sensitivity at which objects are compared
        $newTask->ivPoke('sensitivity', $self->sensitivity);

        return 1;
    }

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub main {}                 # Inherited from generic task

    sub doShutdown {

        # Called by $self->main, just before the task completes a shutdown
        #
        # Expected arguments
        #   (none besides $self)
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doShutdown', @_);
        }

        # Destroy the independent timer interfaces created by this task (which aren't destroyed
        #   automatically when the task finishes)
        foreach my $obj ($self->ivValues('timerHash')) {

            # Delete the timer. The TRUE argument means 'don't show an error message if the
            #   interface has already been deleted (probably during a disconnection)'
            $self->session->deleteInterface($obj->name, TRUE);
        }

        return 1;
    }

#   sub doReset {}              # Inherited from generic task

    sub doFirstStage {

        # Called by $self->main, just before the task completes the first stage ($self->stage)
        #
        # Expected arguments
        #   (none besides $self)

lib/Games/Axmud/Task.pm  view on Meta::CPAN

                    'Couldn\'t create trigger for current world profile\'s'
                    . ' ->inventoryPatternList IV',
                    $self->_objClass . '->resetInterfaces',
                );

                last OUTER;

            } else {

                # Store the trigger
                $self->ivPush('triggerList', $interfaceObj);

                # Give the trigger some properties that will help $self->triggerSeen to decide
                #   what to do when the trigger fires
                $interfaceObj->ivAdd('propertyHash', 'grp_num', $grpNum);
                $interfaceObj->ivAdd('propertyHash', 'inv_type', $type);
                $interfaceObj->ivAdd('propertyHash', 'position', $posn);
            }
        }

        # Import the hash of commands to send periodically
        %cmdHash = $self->cmdHash;
        OUTER: foreach my $cmd (keys %cmdHash) {

            my ($interval, $interfaceObj);

            # The interval is how many seconds to wait before re-sending the same command
            $interval = $cmdHash{$cmd};

            # Each command should be sent for the first time right now
            $self->session->worldCmd($cmd);

            # Create independent timers to send the command to the world every few seconds
            $interfaceObj = $self->session->createIndependentInterface(
                'timer',
                $interval,          # Stimulus
                $cmd,               # Response
            );

            if (! $interfaceObj) {

                $self->writeWarning(
                    'Couldn\'t create timer for current character profile\'s'
                    . ' ->inventoryCmdHash IV',
                    $self->_objClass . '->resetInterfaces',
                );

                last OUTER;

            } else {

                # Store the timer
                $self->ivAdd('timerHash', $cmd, $interfaceObj);
            }
        }

        # Reset complete
        return 1;
    }

    sub updateInventory {

        # Called by $self->doStage at task stage 3 to update the character's inventory based on
        #   the information stored in $self->startStopList
        #
        # Expected arguments
        #   $worldObj   - The current world profile object
        #
        # Return values
        #   'undef' on improper arguments or if there is an error
        #   1 otherwise

        my ($self, $worldObj, $check) = @_;

        # Local variables
        my @startStopList;

        # Check for improper arguments
        if (! defined $worldObj || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->updateInventory', @_);
        }

        # In GA::Profile::World->inventoryMode 'start_stop', $self->startStopList is in the form
        #   ('start', start_line_num, start_line_text, 'stop', stop_line_num, stop_line_text...)
        # In ->inventoryMode 'start_empty', $self->startStopList is in the form
        #   ('start', start_line_num, start_line_text...)
        # Import $self->startStopList
        @startStopList = $self->startStopList;

        do {

            my (
                $startType, $startLineNum, $startLineText, $stopType, $stopLineNum, $stopLineText,
                $matchFlag, $lineNum, $exitFlag,
                @lineTextList,
            );

            # Remove the 'start' line data
            $startType = shift @startStopList;
            $startLineNum = shift @startStopList;
            $startLineText = shift @startStopList;

            if ($startType ne 'start') {

                # List is corrupted
                return undef;
            }

            # Remove the 'stop' line data, if it exists
            if (@startStopList && $startStopList[0] eq 'stop') {

                $stopType = shift @startStopList;
                $stopLineNum = shift @startStopList;
                $stopLineText = shift @startStopList;
            }

            # This function may have to cope with several inventory lists, one after the other. For
            #   example, the user might type 'money;i' which sends us two inventory lists, which
            #   must be combined. The user might also type 'i;i;i' which sends us three identical
            #   inventory lists; each successive 'i' overwrites the ->inventoryList compiled by the

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        $self->{requireWinFlag}         = TRUE;
        $self->{startWithWinFlag}       = TRUE;
        $self->{winPreferList}          = ['pseudo', 'grid'];
        $self->{winmap}                 = 'basic_empty';
        $self->{winUpdateFunc}          = 'createWidgets';
        $self->{tabMode}                = undef;
        $self->{monochromeFlag}         = FALSE;
        $self->{noScrollFlag}           = FALSE;
        $self->{ttsFlag}                = FALSE;
        $self->{ttsConfig}              = undef;
        $self->{ttsAttribHash}          = {};
        $self->{ttsFlagAttribHash}      = {};
        $self->{ttsAlertAttribHash}     = {};
        $self->{status}                 = 'wait_init';
#       $self->{activeFlag}             = TRUE;             # Task can't be activated/disactivated

        # Task parameters
        #
        # Table object handling the GA::Obj::SimpleList
        $self->{slTableObj}             = undef;
        # A hash of scripts displayed in the window, in the form
        #   $fileHash{script_name} = full_file_path
        # ...where 'script_name' is the file name, e.g. 'wumpus.bas'
        $self->{fileHash}               = {};

        # Bless task
        bless $self, $class;

        # For all tasks that aren't temporary...
        if ($taskType) {

            # Check that the task doesn't belong to a disabled plugin (in which case, it can't be
            #   added to any current, initial or custom tasklist)
            if (! $self->checkPlugins()) {

                return undef;
            }

            # Set the parent file object
            $self->setParentFileObj($session, $taskType, $profName, $profCategory);

            # Create entries in tasklists, if possible
            if (! $self->updateTaskLists($session)) {

                return undef;
            }
        }

        # Task creation complete
        return $self;
    }

#   sub clone {}                # Inherited from generic task

#   sub preserve {}             # Inherited from generic task

#   sub preserve {}             # Inherited from generic task

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub init {}                 # Inherited from generic task

    sub doInit {

        # Called by $self->init, just before the task completes its setup ($self->init)
        #
        # Expected arguments
        #   (none besides $self)
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doInit', @_);
        }

        # If the task has recently been updated, quickest way to update the window is to remove all
        #   the current table objects, before creating new ones
        if ($self->hasResetFlag) {

            if (! defined $self->winObj->tableStripObj->removeAllTableObjs()) {

                # Operation failed; task must close
                $self->ivPoke('shutdownFlag', TRUE);
                return 1;
            }
        }

        # Create widgets for the task window
        $self->createWidgets();

        # Display the list of available scripts in the task window's simple list
        $self->populateList();

        return 1;
    }

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        $clone->{autoLookMode}          = $self->autoLookMode;

        $clone->{winDescripLimit}       = $self->winDescripLimit;
        $clone->{combineCorpseFlag}     = $self->combineCorpseFlag;
        $clone->{combineBodyPartFlag}   = $self->combineBodyPartFlag;

        # Cloning complete
        return $clone;
    }

    sub preserve {

        # Called by $self->main whenever this task is reset, in order to preserve some if its task
        #   parameters (but not necessarily all of them)
        #
        # Expected arguments
        #   $newTask    - The new task which has been created, to which some of this task's instance
        #                   variables might have to be transferred
        #
        # Return values
        #   'undef' on improper arguments, or if $newTask isn't in the GA::Session's current
        #       tasklist
        #   1 on success

        my ($self, $newTask, $check) = @_;

        # Check for improper arguments
        if (! defined $newTask || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->preserve', @_);
        }

        # Check the task is in the current tasklist
        if (! $self->session->ivExists('currentTaskHash', $newTask->uniqueName)) {

            return $self->writeWarning(
                '\'' . $self->uniqueName . '\' task missing from the current tasklist',
                $self->_objClass . '->preserve',
            );
        }

        # Preserve some task parameters (the others are left with their default settings, some of
        #   which will be re-initialised in stage 2)

        # Preserve the flag that indicates a manual reset
        $newTask->ivPoke('manualResetFlag', $self->manualResetFlag);
        $newTask->ivPoke('autoLookMode', $self->autoLookMode);
        # Preserve the description size limit
        $newTask->ivPoke('winDescripLimit', $self->winDescripLimit);
        # Preserve the corpse/body part flags
        $newTask->ivPoke('combineCorpseFlag', $self->combineCorpseFlag);
        $newTask->ivPoke('combineBodyPartFlag', $self->combineBodyPartFlag);
        $newTask->ivPoke('showParsedFlag', $self->showParsedFlag);
        $newTask->ivPoke('autoLookMode', $self->autoLookMode);

        return 1;
    }

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

    sub ttsReadAttrib {

        # Called by GA::Cmd::Read->do and PermRead->do
        # Users can use the client command ';read' to interact with individual tasks, typically
        #   getting them to read out information (e.g. the Status task can read out current health
        #   points)
        # The ';read' command is in the form ';read <attribute>' or ';read <attribute> <value>'.
        #   The ';read' command looks up the <attribute> in GA::Client->ttsAttribHash, which tells
        #   it which task to call
        #
        # Expected arguments
        #   $attrib     - The TTS attribute specified by the calling function. Must be one of the
        #                   keys in $self->ttsAttribHash
        #
        # Optional arguments
        #   $value      - The value specified by the calling function (or 'undef' if none was
        #                   specified)
        #   $noReadFlag - Set to TRUE when called by GA::Cmd::PermRead->do, in which case only this
        #                   task's hash of attributes is updated. If set to FALSE (or 'undef'),
        #                   something is usually read aloud, too
        #
        # Return values
        #   'undef' on improper arguments or if the $attrib doesn't exist in this task's
        #       ->ttsConfig
        #   1 otherwise

        my ($self, $attrib, $value, $noReadFlag, $check) = @_;

        # Local variables
        my ($string, $number);

        # Check for improper arguments
        if (! defined $attrib || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->ttsReadAttrib', @_);
        }

        # TTS attributes are case-insensitive
        $attrib = lc($attrib);

        # Check that the specified attribute is actually used by this task (';read' or ';permread'
        #   should carry out this check, but better safe than sorry)
        if (! $self->ivExists('ttsAttribHash', $attrib)) {

            return undef;

        } elsif ($noReadFlag) {

            # When called by GA::Cmd::PermRead->do, don't read out anything, just update the hash of
            #   attributes (when appropriate)

            # (no attributes require an update)

            return 1;

        } else {

            # Custom behaviour for this task

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        $self->{category}               = 'process';
        $self->{descrip}                = 'Display summary of automapper window drawing activities';
        $self->{jealousyFlag}           = TRUE;
        $self->{requireLocatorFlag}     = FALSE;
        $self->{profSensitivityFlag}    = FALSE;
        $self->{storableFlag}           = TRUE;
        $self->{delayTime}              = 0;
        $self->{allowWinFlag}           = TRUE;
        $self->{requireWinFlag}         = TRUE;
        $self->{startWithWinFlag}       = TRUE;
        $self->{winPreferList}          = ['pane', 'grid'];
        $self->{winmap}                 = 'basic_fill';
        $self->{winUpdateFunc}          = undef;
        $self->{tabMode}                = 'simple';
        $self->{monochromeFlag}         = FALSE;
        $self->{noScrollFlag}           = TRUE;
        $self->{ttsFlag}                = FALSE;
        $self->{ttsConfig}              = undef;
        $self->{ttsAttribHash}          = {};
        $self->{ttsFlagAttribHash}      = {};
        $self->{ttsAlertAttribHash}     = {};
        $self->{status}                 = 'wait_init';
#       $self->{activeFlag}             = TRUE;             # Task can't be activated/disactivated

        # Task parameters
        #   (none for this task)

        # Bless task
        bless $self, $class;

        # For all tasks that aren't temporary...
        if ($taskType) {

            # Check that the task doesn't belong to a disabled plugin (in which case, it can't be
            #   added to any current, initial or custom tasklist)
            if (! $self->checkPlugins()) {

                return undef;
            }

            # Set the parent file object
            $self->setParentFileObj($session, $taskType, $profName, $profCategory);

            # Create entries in tasklists, if possible
            if (! $self->updateTaskLists($session)) {

                return undef;
            }
        }

        # Task creation complete
        return $self;
    }

#   sub clone {}                # Inherited from generic task

#   sub preserve {}             # Inherited from generic task

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub main {}                 # Inherited from generic task

#   sub doShutdown {}           # Inherited from generic task

#   sub doReset {}              # Inherited from generic task

#   sub doFirstStage {}         # Inherited from generic task

    sub doStage {

        # Called by $self->main to process all stages (except stage 1)
        #
        # Expected arguments
        #   (none besides $self)
        #
        # Return values
        #   'undef' on improper arguments or if this function sets that task's ->status IV to
        #       'finished' or sets its ->shutdownFlag to TRUE
        #   Otherwise, we normally return the new value of $self->stage

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doStage', @_);
        }

        if ($self->stage == 2) {

            if (! $self->session->mapWin) {

                # Continue waiting
                return $self->ivPoke('stage', 2);

            } else {

                return $self->ivPoke('stage', 3);
            }

        } elsif ($self->stage == 3) {

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        #                   existing task is stored
        #   $profCategory
        #               - ($taskType = 'initial') which category the profile falls under (i.e.
        #                   'world', 'race', 'char', etc)
        #
        # Return values
        #   'undef' on improper arguments or if the task can't be cloned
        #   Blessed reference to the newly-created object on success

        my ($self, $session, $taskType, $profName, $profCategory, $check) = @_;

        # Check for improper arguments
        if (
            ! defined $session || ! defined $taskType || defined $check
            || ($taskType ne 'current' && $taskType ne 'initial')
            || ($taskType eq 'initial' && (! defined $profName || ! defined $profCategory))
        ) {
            return $axmud::CLIENT->writeImproper($self->_objClass . '->clone', @_);
        }

        # For initial tasks, check that $profName exists
        if (
            $taskType eq 'initial'
            && defined $profName
            && ! $session->ivExists('profHash', $profName)
        ) {
            return $axmud::CLIENT->writeError(
                'Can\'t create cloned task because \'' . $profName . '\' profile doesn\'t exist',
                $self->_objClass . '->clone',
            );
        }

        # Check that the task doesn't belong to a disabled plugin (in which case, it can't be
        #   cloned)
        if (! $self->checkPlugins()) {

            return undef;
        }

        # Create the new task, using default settings and parameters
        my $clone = $self->_objClass->new($session, $taskType, $profName, $profCategory);

        # Most of the cloned task's settings have default values, but a few are copied from the
        #   original
        $self->cloneTaskSettings($clone);

        # Give the new (cloned) task the same initial parameters as the original one
        $clone->{textTableObj}          = $self->textTableObj;
        $clone->{comboTableObj}         = $self->comboTableObj;

        $clone->{profNoteHash}          = {$self->profNoteHash};

        # Cloning complete
        return $clone;
    }

#   sub preserve {}             # Inherited from generic task

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub init {}                 # Inherited from generic task

    sub doInit {

        # Called by $self->init, just before the task completes its setup ($self->init)
        #
        # Expected arguments
        #   (none besides $self)
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doInit', @_);
        }

        # Store the current state of all current profiles' ->notepadList, so that if the user clicks
        #   the 'Restore notes' button, the contents of the textview can be magically reset to what
        #   it was, when the task started
        foreach my $profObj ($self->session->ivValues('currentProfHash')) {

            my @list = $profObj->notepadList;

            $self->ivAdd('profNoteHash', $profObj->name, \@list);
        }

        # If the task has recently been updated, quickest way to update the window is to remove all
        #   the current table objects, before creating new ones
        if ($self->hasResetFlag) {

            if (! defined $self->winObj->tableStripObj->removeAllTableObjs()) {

                # Operation failed; task must close
                $self->ivPoke('shutdownFlag', TRUE);
                return 1;
            }

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        $self->{category}               = 'activity';
        $self->{descrip}                = 'Displays all incoming text, including escape sequences';
        $self->{jealousyFlag}           = TRUE;
        $self->{requireLocatorFlag}     = FALSE;
        $self->{profSensitivityFlag}    = FALSE;
        $self->{storableFlag}           = TRUE;
        $self->{delayTime}              = 0;
        $self->{allowWinFlag}           = TRUE;
        $self->{requireWinFlag}         = TRUE;
        $self->{startWithWinFlag}       = TRUE;
        $self->{winPreferList}          = ['pane', 'grid'];
        $self->{winmap}                 = 'basic_fill';
        $self->{winUpdateFunc}          = undef;
        $self->{tabMode}                = 'simple';
        $self->{monochromeFlag}         = FALSE;
        $self->{noScrollFlag}           = FALSE;
        $self->{ttsFlag}                = FALSE;
        $self->{ttsConfig}              = undef;
        $self->{ttsAttribHash}          = {};
        $self->{ttsFlagAttribHash}      = {};
        $self->{ttsAlertAttribHash}     = {};
        $self->{status}                 = 'wait_init';
#       $self->{activeFlag}             = TRUE;             # Task can't be activated/disactivated

        # Task parameters
        #   (none)

        # Bless task
        bless $self, $class;

        # For all tasks that aren't temporary...
        if ($taskType) {

            # Check that the task doesn't belong to a disabled plugin (in which case, it can't be
            #   added to any current, initial or custom tasklist)
            if (! $self->checkPlugins()) {

                return undef;
            }

            # Set the parent file object
            $self->setParentFileObj($session, $taskType, $profName, $profCategory);

            # Create entries in tasklists, if possible
            if (! $self->updateTaskLists($session)) {

                return undef;
            }
        }

        # Task creation complete
        return $self;
    }

#   sub clone {}                # Inherited from generic task

#   sub preserve {}             # Inherited from generic task

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub init {}                 # Inherited from generic task

    sub doInit {

        # Called by $self->init, just before the task completes its setup ($self->init)
        # If raw text (from before the login sequence was completed) is waiting to be displayed in
        #   this task's window, display it
        #
        # Expected arguments
        #   (none besides $self)
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

        my ($self, $check) = @_;

        # Local variables
        my @list;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doInit', @_);
        }

        @list = $self->session->rawTextBufferList;

        if ($self->winObj && @list) {

            do {

                my ($count, $packetText);

                $count = shift @list;
                $packetText = shift @list;

                $self->insertText('<' . $count . '>', 'WHITE', 'ul_red', 'echo');

                foreach my $string (split(m/\n/, $packetText)) {

lib/Games/Axmud/Task.pm  view on Meta::CPAN


        $clone->{taskWinGaugeStripObj}  = $self->taskWinGaugeStripObj;
        $clone->{taskWinGaugeLevel}     = $self->taskWinGaugeLevel;
        $clone->{taskWinGaugeHash}      = {$self->taskWinGaugeHash};
        $clone->{taskWinStatusBarHash}  = {$self->taskWinStatusBarHash};

        $clone->{forcedWinFlag}         = $self->forcedWinFlag;

        # Cloning complete
        return $clone;
    }

    sub preserve {

        # Called by $self->main whenever this task is reset, in order to preserve some if its task
        #   parameters (but not necessarily all of them)
        #
        # Expected arguments
        #   $newTask    - The new task which has been created, to which some of this task's instance
        #                   variables might have to be transferred
        #
        # Return values
        #   'undef' on improper arguments, or if $newTask isn't in the GA::Session's current
        #       tasklist
        #   1 on success

        my ($self, $newTask, $check) = @_;

        # Check for improper arguments
        if (! defined $newTask || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->preserve', @_);
        }

        # Check the task is in the current tasklist
        if (! $self->session->ivExists('currentTaskHash', $newTask->uniqueName)) {

            return $self->writeWarning(
                '\'' . $self->uniqueName . '\' task missing from the current tasklist',
                $self->_objClass . '->preserve',
            );
        }

        # Preserve some task parameters (the others are left with their default settings, some of
        #   which will be re-initialised in stage 2)

        # Preserve the maximum number of steps per task loop
        $newTask->ivPoke('stepMax', $self->stepMax);
        # Preserve the name of the Axbasic script to run (from the beginning)
        $newTask->ivPoke('scriptName', $self->scriptName);

        # Preserve 'forced window' mode; if the old task was started with a ';runscripttask -w', the
        #   new task should also be forced to open a task window
        $newTask->ivPoke('forcedWindowFlag', $self->forcedWindowFlag);

        return 1;
    }

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

    sub openWin {

        # Called by the task's ->main method or by its ->toggleWin method
        # Tries to open each type of task window in $self->winPreferList, halting at the first
        #   successful attempt (or when all attempts fail)
        #
        # Expected arguments
        #   (none besides self)
        #
        # Optional arguments
        #   $winmap     - The winmap to use in a 'grid' window or a pseudo-window (matches a key in
        #                   GA::Client->winmapHash). If 'undef', $self->winmap is used
        #   @preferList - The types of task window to try to open. If not an empty list, this list
        #                   is used rather than $self->winPreferList
        #
        # Return values
        #   'undef' on improper arguments, if $winmap doesn't exist (when specified, checked even if
        #       a 'grid' window isn't opened) or if a task window is not opened
        #   1 if a window is opened

        my ($self, $winmap, @preferList) = @_;

        # (No improper arguments to check)

        # Most of the code is in the generic function
        if ($self->Games::Axmud::Generic::Task::openWin($winmap, @preferList)) {

            # Set a customised window title
            $self->setTitle();

            return 1;

        } else {

            return undef;
        }
    }

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub main {}                 # Inherited from generic task

    sub doShutdown {

        # Called just before the task completes a shutdown

lib/Games/Axmud/Task.pm  view on Meta::CPAN

    sub preserve {

        # Called by $self->main whenever this task is reset, in order to preserve some if its task
        #   parameters (but not necessarily all of them)
        #
        # Expected arguments
        #   $newTask    - The new task which has been created, to which some of this task's instance
        #                   variables might have to be transferred
        #
        # Return values
        #   'undef' on improper arguments, or if $newTask isn't in the GA::Session's current
        #       tasklist
        #   1 on success

        my ($self, $newTask, $check) = @_;

        # Check for improper arguments
        if (! defined $newTask || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->preserve', @_);
        }

        # Check the task is in the current tasklist
        if (! $self->session->ivExists('currentTaskHash', $newTask->uniqueName)) {

            return $self->writeWarning(
                '\'' . $self->uniqueName . '\' task missing from the current tasklist',
                $self->_objClass . '->preserve',
            );
        }

        # Preserve some task parameters (the others are left with their default settings, some of
        #   which will be re-initialised in stage 2)

        # Preserve the list of commands to send
        $newTask->ivPoke('cmdHash', $self->cmdHash);
        # Preserve the background colour scheme
        $newTask->ivPoke('allowColourFlag', $self->allowColourFlag);
        $newTask->ivPoke('aliveColour', $self->aliveColour);
        $newTask->ivPoke('alive50Colour', $self->alive50Colour);
        $newTask->ivPoke('alive30Colour', $self->alive30Colour);
        $newTask->ivPoke('alive10Colour', $self->alive10Colour);
        $newTask->ivPoke('asleepColour', $self->asleepColour);
        $newTask->ivPoke('passedOutColour', $self->passedOutColour);
        $newTask->ivPoke('deadColour', $self->deadColour);
        # Preserve the counters
        $newTask->ivPoke('counterVarHash', $self->counterVarHash);
        $newTask->ivPoke('counterBaseHash', $self->counterBaseHash);
        $newTask->ivPoke('fightCountFlag', $self->fightCountFlag);
        $newTask->ivPoke('interactCountFlag', $self->interactCountFlag);
        $newTask->ivPoke('counterStartTime', $self->counterStartTime);
        # Preserve some gauge variables
        $newTask->ivPoke('gaugeFlag', $self->gaugeFlag);
        $newTask->ivPoke('gaugeValueFlag', $self->gaugeFlag);

        return 1;
    }

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

    sub ttsReadAttrib {

        # Called by GA::Cmd::Read->do and PermRead->do
        # Users can use the client command ';read' to interact with individual tasks, typically
        #   getting them to read out information (e.g. the Status task can read out current health
        #   points)
        # The ';read' command is in the form ';read <attribute>' or ';read <attribute> <value>'.
        #   The ';read' command looks up the <attribute> in GA::Client->ttsAttribHash, which tells
        #   it which task to call
        #
        # Expected arguments
        #   $attrib     - The TTS attribute specified by the calling function. Must be one of the
        #                   keys in $self->ttsAttribHash
        #
        # Optional arguments
        #   $value      - The value specified by the calling function (or 'undef' if none was
        #                   specified)
        #   $noReadFlag - Set to TRUE when called by GA::Cmd::PermRead->do, in which case only this
        #                   task's hash of attributes is updated. If set to FALSE (or 'undef'),
        #                   something is usually read aloud, too
        #
        # Return values
        #   'undef' on improper arguments, if the current character profile isn't set or if the
        #       $attrib doesn't exist in this task's ->ttsConfig
        #   1 otherwise

        my ($self, $attrib, $value, $noReadFlag, $check) = @_;

        # Local variables
        my ($charObj, $string, $iv, $ivMax, $time);

        # Check for improper arguments
        if (! defined $attrib || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->ttsReadAttrib', @_);
        }

        # Import the current character
        $charObj = $self->session->currentChar;
        if (! $charObj) {

            return undef;
        }

        # TTS attributes are case-insensitive
        $attrib = lc($attrib);

        # Check that the specified attribute is actually used by this task (';read' or ';permread'
        #   should carry out this check, but better safe than sorry)
        if (! $self->ivExists('ttsAttribHash', $attrib)) {

            return undef;

        } elsif ($noReadFlag) {

            # When called by GA::Cmd::PermRead->do, don't read out anything, just update the hash
            #   of attributes (when appropriate)

            # (no attributes require an update)

lib/Games/Axmud/Task.pm  view on Meta::CPAN

    }

    sub inc_interactDisasterCount {

        my ($self, $check) = @_;

        # Local variables
        my $charObj;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper(
                $self->_objClass . '->inc_interactDisasterCount',
                @_,
            );
        }

        $charObj = $self->session->currentChar;
        if ($charObj) {

            # These are fixed variables, so update the current character profile directly
            $charObj->ivIncrement('interactCount');
            $charObj->ivIncrement('interactDisasterCount');

            # Update counters (if the right counter is running)
            if ($self->interactCountFlag) {

                $self->ivIncHash('counterVarHash', 'temp_interact_count');
                $self->ivIncHash('counterVarHash', 'temp_interact_disaster_count');
            }

            # Update the task window
            $self->ivPoke('updateFlag', TRUE);
        }

        # Update the task window
        $self->ivPoke('updateFlag', TRUE);

        return 1;
    }

    sub set_lifeStatusChangeFlag {

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper(
                $self->_objClass . '->set_lifeStatusChangeFlag',
                @_,
            );
        }

        $self->ivPoke('lifeStatusChangeFlag', TRUE);

        return 1;
    }

    sub update_profiles {

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->update_profiles', @_);
        }

        if ($self->fightCountFlag || $self->interactCountFlag) {

            $self->reset_counters('a');
            $self->set_fightCountFlag(FALSE);
            $self->set_interactCountFlag(FALSE);
        }

        return 1;
    }

    sub set_updateFlag {

        my ($self, $flag, $check) = @_;

        # Check for improper arguments
        if (! defined $flag || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->set_updateFlag', @_);
        }

        if ($flag) {
            $self->ivPoke('updateFlag', TRUE);
        } else {
            $self->ivPoke('updateFlag', FALSE);
        }

        return 1;
    }

    sub set_updateFromMsdp {

        # Called by GA::Session->processMsdpData
        # When the server (world) reports an MSDP variable and its value, the session calls this
        #   function, so that we can update the Status task's variables (where appropriate)
        # The task's variables are updated even if the task is disactivated (but only at stage 4)
        #
        # Expected arguments
        #   $var    - An MSDP variable, e.g. EXPERIENCE
        #   $val    - The corresponding value; may be a scalar, or a list/hash reference
        #   $flag   - Set to TRUE if this is a generic MSDP variable, FALSE if it is a custom
        #               MSDP variable
        #
        # Return values
        #   'undef' on improper arguments
        #   1 on success

        my ($self, $var, $val, $flag, $check) = @_;

        # Local variables
        my (
            $mode,

lib/Games/Axmud/Task.pm  view on Meta::CPAN

            } elsif ($var eq 'ALIGNMENT' && ! $mode) {
                $self->setValue('alignment', $val);
            } elsif ($var eq 'EXPERIENCE' && ! $mode) {
                $self->setValue('xp_current', $val);
            } elsif ($var eq 'EXPERIENCE_MAX' && ! $mode) {
                $self->setValue('xp_total', $val);
            } elsif ($var eq 'EXPERIENCE_TNL' && ! $mode) {
                $self->setValue('xp_next_level', $val);
            } elsif ($var eq 'EXPERIENCE_TNL_MAX' && ! $mode) {
                $self->setValue('xp_total', $val);
            } elsif ($var eq 'HEALTH' && ! $mode) {
                $self->setValue('health_points', $val);
            } elsif ($var eq 'HEALTH_MAX' && ! $mode) {
                $self->setValue('health_points_max', $val);
            } elsif ($var eq 'LEVEL' && ! $mode) {
                $self->setValue('level', $val);
            } elsif ($var eq 'MANA' && ! $mode) {
                $self->setValue('magic_points', $val);
            } elsif ($var eq 'MANA_MAX' && ! $mode) {
                $self->setValue('magic_points_max', $val);
            } elsif ($var eq 'MONEY' && ! $mode) {
                $self->setValue('purse_contents', $val);
            } elsif ($var eq 'MOVEMENT' && ! $mode) {
                $self->setValue('energy_points', $val);
            } elsif ($var eq 'MOVEMENT_MAX' && ! $mode) {
                $self->setValue('energy_points_max', $val);
            } elsif ($var eq 'OPPONENT_LEVEL' && ! $mode) {
                $self->setValue('opp_level', $val);
            } elsif ($var eq 'OPPONENT_HEALTH' && ! $mode) {
                $self->setValue('opp_health', $val);
            } elsif ($var eq 'OPPONENT_HEALTH_MAX' && ! $mode) {
                $self->setValue('opp_health_max', $val);
            } elsif ($var eq 'OPPONENT_NAME' && ! $mode) {
                $self->setValue('opp_name', $val);
            } elsif ($var eq 'OPPONENT_STRENGTH' && ! $mode) {
                $self->setValue('opp_strength', $val);
            } elsif ($var eq 'WORLD_TIME' && ! $mode) {
                $self->setValue('time', $val);
            }
        }

        # (Regardless of whether an IV was updated, or not, mark the task window to be updated)
        $self->ivPoke('updateFlag', TRUE);

        return 1;
    }

    ##################
    # Accessors - task settings - get

    # The accessors for task settings are inherited from the generic task

    ##################
    # Accessors - task parameters - get

    sub cmdHash
        { my $self = shift; return %{$self->{cmdHash}}; }
    sub timerHash
        { my $self = shift; return %{$self->{timerHash}}; }

    sub updateFlag
        { $_[0]->{updateFlag} }
    sub lifeStatusChangeFlag
        { $_[0]->{lifeStatusChangeFlag} }
    sub healthChangeFlag
        { $_[0]->{healthChangeFlag} }
    sub convertTimeFlag
        { $_[0]->{convertTimeFlag} }

    sub allowColourFlag
        { $_[0]->{allowColourFlag} }
    sub aliveColour
        { $_[0]->{aliveColour} }
    sub alive50Colour
        { $_[0]->{alive50Colour} }
    sub alive30Colour
        { $_[0]->{alive30Colour} }
    sub alive10Colour
        { $_[0]->{alive10Colour} }
    sub asleepColour
        { $_[0]->{asleepColour} }
    sub passedOutColour
        { $_[0]->{passedOutColour} }
    sub deadColour
        { $_[0]->{deadColour} }

    sub constCharVarHash
        { my $self = shift; return %{$self->{constCharVarHash}}; }
    sub constFixedVarHash
        { my $self = shift; return %{$self->{constFixedVarHash}}; }
    sub constPseudoVarHash
        { my $self = shift; return %{$self->{constPseudoVarHash}}; }
    sub constLocalVarHash
        { my $self = shift; return %{$self->{constLocalVarHash}}; }
    sub constCounterVarHash
        { my $self = shift; return %{$self->{constCounterVarHash}}; }
    sub constCounterRevHash
        { my $self = shift; return %{$self->{constCounterRevHash}}; }
    sub constPointHash
        { my $self = shift; return %{$self->{constPointHash}}; }

    sub localVarHash
        { my $self = shift; return %{$self->{localVarHash}}; }
    sub customVarHash
        { my $self = shift; return %{$self->{customVarHash}}; }

    sub counterVarHash
        { my $self = shift; return %{$self->{counterVarHash}}; }
    sub counterBaseHash
        { my $self = shift; return %{$self->{counterBaseHash}}; }
    sub fightCountFlag
        { $_[0]->{fightCountFlag} }
    sub interactCountFlag
        { $_[0]->{interactCountFlag} }
    sub counterStartTime
        { $_[0]->{counterStartTime} }

    sub affectHash
        { my $self = shift; return %{$self->{affectHash}}; }
    sub statHash
        { my $self = shift; return %{$self->{statHash}}; }

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        $clone->{systemMode}            = $self->systemMode;
        $clone->{errorMode}             = $self->errorMode;
        $clone->{warningMode}           = $self->warningMode;
        $clone->{debugMode}             = $self->debugMode;
        $clone->{improperMode}          = $self->improperMode;

        $clone->{colourFlag}            = $self->colourFlag;

        # Cloning complete
        return $clone;
    }

    sub preserve {

        # Called by $self->main whenever this task is reset, in order to preserve some if its task
        #   parameters (but not necessarily all of them)
        #
        # Expected arguments
        #   $newTask    - The new task which has been created, to which some of this task's instance
        #                   variables might have to be transferred
        #
        # Return values
        #   'undef' on improper arguments, or if $newTask isn't in the GA::Session's current
        #       tasklist
        #   1 on success

        my ($self, $newTask, $check) = @_;

        # Check for improper arguments
        if (! defined $newTask || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->preserve', @_);
        }

        # Check the task is in the current tasklist
        if (! $self->session->ivExists('currentTaskHash', $newTask->uniqueName)) {

            return $self->writeWarning(
                '\'' . $self->uniqueName . '\' task missing from the current tasklist',
                $self->_objClass . '->preserve',
            );
        }

        # Preserve some task parameters (the others are left with their default settings, some of
        #   which will be re-initialised in stage 2)

        # Preserve display modes
        $newTask->ivPoke('systemMode', $self->systemMode);
        $newTask->ivPoke('errorMode', $self->errorMode);
        $newTask->ivPoke('warningMode', $self->warningMode);
        $newTask->ivPoke('debugMode', $self->debugMode);
        $newTask->ivPoke('improperMode', $self->improperMode);

        $newTask->ivPoke('colourFlag', $self->colourFlag);

        return 1;
    }

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub init {}                 # Inherited from generic task

    sub doInit {

        # Called by $self->init, just before the task completes its setup ($self->init)
        #
        # Expected arguments
        #   (none besides $self)
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doInit', @_);
        }

        # GA::Obj::TextView->showSystemText can be called several times to display parts of a
        #   system message line; for example, to include a link in a part of it
        # To make those calls the same in both the 'main' and task windows, we've got to use the
        #   same setting of ->newLineDefault that 'main' windows use
        $self->defaultTabObj->textViewObj->set_newLineDefault('after');

        return 1;
    }

#   sub doShutdown {}           # Inherited from generic task

#   sub doReset {}              # Inherited from generic task

    ##################
    # Response methods

    sub showSystemText {

        # Called by GA::Obj::TextView->showSystemText
        # Displays an odrinary system message in the task window (in addition to, or instead of,

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        $self->{category}               = 'process';
        $self->{descrip}                = 'Display a constantly-updated list of current tasks';
        $self->{jealousyFlag}           = TRUE;
        $self->{requireLocatorFlag}     = FALSE;
        $self->{profSensitivityFlag}    = FALSE;
        $self->{storableFlag}           = TRUE;
        $self->{delayTime}              = 0;
        $self->{allowWinFlag}           = TRUE;
        $self->{requireWinFlag}         = TRUE;
        $self->{startWithWinFlag}       = TRUE;
        $self->{winPreferList}          = ['pane', 'grid'];
        $self->{winmap}                 = 'basic_fill';
        $self->{winUpdateFunc}          = undef;
        $self->{tabMode}                = 'simple';
        $self->{monochromeFlag}         = FALSE;
        $self->{noScrollFlag}           = TRUE;
        $self->{ttsFlag}                = FALSE;
        $self->{ttsConfig}              = undef;
        $self->{ttsAttribHash}          = {};
        $self->{ttsFlagAttribHash}      = {};
        $self->{ttsAlertAttribHash}     = {};
        $self->{status}                 = 'wait_init';
#       $self->{activeFlag}             = TRUE;             # Task can't be activated/disactivated

        # Task parameters
        #   (none for this task)

        # Bless task
        bless $self, $class;

        # For all tasks that aren't temporary...
        if ($taskType) {

            # Check that the task doesn't belong to a disabled plugin (in which case, it can't be
            #   added to any current, initial or custom tasklist)
            if (! $self->checkPlugins()) {

                return undef;
            }

            # Set the parent file object
            $self->setParentFileObj($session, $taskType, $profName, $profCategory);

            # Create entries in tasklists, if possible
            if (! $self->updateTaskLists($session)) {

                return undef;
            }
        }

        # Task creation complete
        return $self;
    }

#   sub clone {}                # Inherited from generic task

#   sub preserve {}             # Inherited from generic task

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub main {}                 # Inherited from generic task

#   sub doShutdown {}           # Inherited from generic task

#   sub doReset {}              # Inherited from generic task

#   sub doFirstStage {}         # Inherited from generic task

    sub doStage {

        # Called by $self->main to process all stages (except stage 1)
        #
        # Expected arguments
        #   (none besides $self)
        #
        # Return values
        #   'undef' on improper arguments or if this function sets that task's ->status IV to
        #       'finished' or sets its ->shutdownFlag to TRUE
        #   Otherwise, we normally return the new value of $self->stage

        my ($self, $check) = @_;

        # Check for improper arguments
        if (defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doStage', @_);
        }

        if ($self->stage == 2) {

            # Stage 2 normally checks that the character has logged in to the world, and then sets
            #   some IVs to initial values
            # There's nothing for the TaskList task to do on stage 2, so move on to the next stage
            return $self->ivPoke('stage', 3);

        } elsif ($self->stage == 3) {

            my @lineList;

            # On every spin of the task loop, update the task window (if it is still open)
            if ($self->taskWinFlag) {

lib/Games/Axmud/Task.pm  view on Meta::CPAN

        $clone->{channelsAlertInterval} = $self->channelsAlertInterval;
        $clone->{chatAlertInterval}     = $self->chatAlertInterval;
        $clone->{divertAlertInterval}   = $self->divertAlertInterval;

        $clone->{resetTime}             = $self->resetTime;
        $clone->{firstTextFlag}         = $self->firstTextFlag;

        # Cloning complete
        return $clone;
    }

    sub preserve {

        # Called by $self->main whenever this task is reset, in order to preserve some if its task
        #   parameters (but not necessarily all of them)
        #
        # Expected arguments
        #   $newTask    - The new task which has been created, to which some of this task's instance
        #                   variables might have to be transferred
        #
        # Return values
        #   'undef' on improper arguments, or if $newTask isn't in the GA::Session's current
        #       tasklist
        #   1 on success

        my ($self, $newTask, $check) = @_;

        # Check for improper arguments
        if (! defined $newTask || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->preserve', @_);
        }

        # Check the task is in the current tasklist
        if (! $self->session->ivExists('currentTaskHash', $newTask->uniqueName)) {

            return $self->writeWarning(
                '\'' . $self->uniqueName . '\' task missing from the current tasklist',
                $self->_objClass . '->preserve',
            );
        }

        # Preserve some task parameters (the others are left with their default settings, some of
        #   which will be re-initialised in stage 2)

        # Preserve the background colours
        $newTask->ivPoke('defaultColour', $self->defaultColour);
        $newTask->ivPoke('channelsAlertColour', $self->channelsAlertColour);
        $newTask->ivPoke('chatAlertColour', $self->chatAlertColour);
        $newTask->ivPoke('divertAlertColour', $self->divertAlertColour);
        # Preserve intervals before resetting the background colour
        $newTask->ivPoke('channelsAlertInterval', $self->channelsAlertInterval);
        $newTask->ivPoke('chatAlertInterval', $self->chatAlertInterval);
        $newTask->ivPoke('divertAlertInterval', $self->divertAlertInterval);

        return 1;
    }

#   sub setParentFileObj {}     # Inherited from generic task

#   sub updateTaskLists {}      # Inherited from generic task

#   sub ttsReadAttrib {}        # Inherited from generic task

#   sub ttsSwitchFlagAttrib {}  # Inherited from generic task

#   sub ttsSetAlertAttrib {}    # Inherited from generic task

    ##################
    # Task windows

#   sub toggleWin {}            # Inherited from generic task

#   sub openWin {}              # Inherited from generic task

#   sub closeWin {}             # Inherited from generic task

    ##################
    # Methods

#   sub main {}                 # Inherited from generic task

#   sub doShutdown {}           # Inherited from generic task

    sub doReset {

        # Called just before the task completes a reset
        # For process tasks, called by $self->main. For activity tasks, called by $self->reset
        #
        # This function does nothing, so tasks that need to do something special during a reset
        #   should have their own ->doReset function
        #
        # Expected arguments
        #   $newTaskObj     - The replacement task object
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

        my ($self, $newTaskObj, $check) = @_;

        # Check for improper arguments
        if (! defined $newTaskObj || defined $check) {

            return $axmud::CLIENT->writeImproper($self->_objClass . '->doReset', @_);
        }

        # In case the task window is currently a different colour when the task is reset, set it
        #   back to the default colour
        if ($self->defaultTabObj) {

            $self->defaultTabObj->paneObj->applyMonochrome(
                $self->defaultTabObj,
                $self->defaultColour,
            );
        }

        return 1;
    }

#   sub doFirstStage {}         # Inherited from generic task



( run in 1.400 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )