Games-Axmud

 view release on metacpan or  search on metacpan

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

    our @ISA = qw(Games::Axmud::Generic::Cmd Games::Axmud);

    ##################
    # Constructors

    sub new {

        # Create a new instance of this command object (there should only be one)
        #
        # Expected arguments
        #   (none besides $class)
        #
        # Return values
        #   'undef' if GA::Generic::Cmd->new reports an error
        #   Blessed reference to the new object on success

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

        # Setup
        my $self = Games::Axmud::Generic::Cmd->new('setlife', TRUE, FALSE);
        if (! $self) {return undef}

        $self->{defaultUserCmdList} = ['slf', 'setlife'];
        $self->{userCmdList} = \@{$self->{defaultUserCmdList}};
        $self->{descrip} = 'Sets the Status task\'s current life status';

        # Bless the object into existence
        bless $self, $class;
        return $self;
    }

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

    sub do {

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

        # Local variables
        my $result;

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

            return $self->improper($session, $inputString);
        }

        if (! $session->statusTask || ! $session->currentChar) {

            return $self->error(
                $session, $inputString,
                'This command can only be used when the Status task is running and when there\'s'
                . ' a current character profile',
            );
        }

        if ($status eq '-a' || $status eq 'alive') {
            $session->currentChar->ivPoke('lifeStatus', 'alive');
        } elsif ($status eq '-s' || $status eq 'sleep') {
            $session->currentChar->ivPoke('lifeStatus', 'sleep');
        } elsif ($status eq '-p' || $status eq 'passout') {
            $session->currentChar->ivPoke('lifeStatus', 'passout');
        } elsif ($status eq '-d' || $status eq 'dead') {
            $session->currentChar->ivPoke('lifeStatus', 'dead');
        } else {

            return $self->error(
                $session, $inputString,
                'Invalid life status (try -a -s -p -d / alive sleep passout dead)',
            );
        }

        # Tell the Status task that its task window must be updated with a new background colour
        $session->statusTask->set_lifeStatusChangeFlag();

        # Operation complete
        return $self->complete(
            $session, $standardCmd,
            'Current character\'s life status set to \'' . $session->currentChar->lifeStatus
            . '\'',
        );
    }
}

{ package Games::Axmud::Cmd::SetStatusEvent;

    use strict;
    use warnings;
#   use diagnostics;

    use Glib qw(TRUE FALSE);

    our @ISA = qw(Games::Axmud::Generic::Cmd Games::Axmud);

    ##################
    # Constructors

    sub new {

        # Create a new instance of this command object (there should only be one)
        #
        # Expected arguments
        #   (none besides $class)
        #
        # Return values
        #   'undef' if GA::Generic::Cmd->new reports an error
        #   Blessed reference to the new object on success

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

        # Setup
        my $self = Games::Axmud::Generic::Cmd->new('setstatusevent', TRUE, FALSE);
        if (! $self) {return undef}

        $self->{defaultUserCmdList} = ['sev', 'setevent', 'setstatusevent'];
        $self->{userCmdList} = \@{$self->{defaultUserCmdList}};
        $self->{descrip} = 'Handles settings for Status task events';

        # Bless the object into existence
        bless $self, $class;
        return $self;
    }

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

    sub do {

        my (



( run in 0.567 second using v1.01-cache-2.11-cpan-d8267643d1d )