Games-Axmud

 view release on metacpan or  search on metacpan

lib/Games/Axmud/Obj/Mission.pm  view on Meta::CPAN

        #   $comment    - The comment to show
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

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

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

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

        $session->writeText(
            'MISSION: \'' . $self->name . '\' (step ' . $self->nextString . ')',
        );

        $session->writeText($comment);

        return 1;
    }

    sub taskReady {

        # Called by GA::Task::Locator->processLine while the mission is on a Locator break, whenever
        #   the task notices that there are no more room statements expected (i.e. the character has
        #   arrived at their intended destination)
        #
        # Expected arguments
        #   $session        - The calling function's GA::Session
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

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

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

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

        # Reset the mission's IVs
        $self->ivUndef('breakType');

        # Send the next group of commands, and return the result ('undef', 1 or 2)
        return ($self->continueMission($session));
    }

    sub statusTaskChange {

        # Called by GA::Task::Status->deadSeen, ->passedOutSeen or ->asleepSeen when the character
        #   dies, passes out or falls asleep
        # Terminates the current mission
        #
        # Expected arguments
        #   $session        - The calling function's GA::Session
        #   $status         - The Status task's new ->lifeStatus IV: 'sleep', 'passout' or
        #                       'dead' (if it's 'alive', this function does nothing)
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

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

        # Local variables
        my $comment;

        # Check for improper arguments
        if (
            ! defined $session || ! defined $status
            || (
                $status ne 'alive' && $status ne 'sleep' && $status ne 'passout'
                && $status ne 'dead'
            ) || defined $check
        ) {
            return $axmud::CLIENT->writeImproper($self->_objClass . '->statusTaskChange', @_);
        }

        if ($status eq 'alive') {

            # Do nothing
            return 1;

        } else {

            $comment = 'Mission terminated because character has ';
            if ($status eq 'sleep') {
                $comment .= 'fallen asleep';
            } elsif ($status eq 'passout') {
                $comment .= 'passed out';
            } elsif ($status eq 'dead') {
                $comment .= 'died';
            }

            $self->displayComment($session, $comment);
            $session->reset_currentMission();

            return 1;
        }
    }

    # Response methods

    sub triggerSeen {

        # Called by GA::Session->checkTriggers, while on a trigger break, after the trigger created
        #   by $self->continueMission fires
        #
        # Expected arguments (standard args from GA::Session->checkTriggers)
        #   $session        - The calling function's GA::Session
        #   $interfaceNum   - The number of the active trigger interface that fired
        #   $line           - The line of text received from the world
        #   $stripLine      - $line, with all escape sequences removed
        #   $modLine        - $stripLine, possibly modified by previously-checked triggers
        #   $grpStringListRef
        #                   - Reference to a list of group substrings from the pattern match
        #                       (equivalent of @_)
        #   $matchMinusListRef
        #                   - Reference to a list of matched substring offsets (equivalent of @-)
        #   $matchPlusListRef
        #                   - Reference to a list of matched substring offsets (equivalent of @+)
        #
        # Return values
        #   'undef' on improper arguments, or if $session is the wrong session, or if the interface
        #       object can't be found
        #   Otherwise returns the result of the call to $self->continueMission ('undef', 1 or 2)

        my (
            $self, $session, $interfaceNum, $line, $stripLine, $modLine, $grpStringListRef,
            $matchMinusListRef, $matchPlusListRef, $check,
        ) = @_;

        # Local variables
        my $obj;

        # Check for improper arguments
        if (
            ! defined $session || ! defined $interfaceNum || ! defined $line || ! defined $stripLine
            || ! defined $modLine || ! defined $grpStringListRef || ! defined $matchMinusListRef



( run in 0.732 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )