Games-Axmud

 view release on metacpan or  search on metacpan

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


    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('listalias', TRUE, TRUE);
        if (! $self) {return undef}

        $self->{defaultUserCmdList} = ['lal', 'listal', 'listalias'];
        $self->{userCmdList} = \@{$self->{defaultUserCmdList}};
        $self->{descrip} = 'Lists aliases';

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

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

    sub do {

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

        # (No imprope arguments to check)

        # List aliases
        return $self->listInterface(
            $session, $inputString, $standardCmd,
            'alias',
            'aliases',
            @args,
        );
    }
}

{ package Games::Axmud::Cmd::AddMacro;

    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('addmacro', TRUE, FALSE);
        if (! $self) {return undef}

        $self->{defaultUserCmdList} = ['ama', 'addma', 'addmacro'];
        $self->{userCmdList} = \@{$self->{defaultUserCmdList}};
        $self->{descrip} = 'Adds a macro';

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

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

    sub do {

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

        # Check for improper arguments
        if (! @args) {

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

        # Add the macro
        return $self->addInterface(
            $session, $inputString, $standardCmd,
            'macro',
            'macros',
            $axmud::CLIENT->ivShow('interfaceModelHash', 'macro'),
            @args,
        );
    }
}

{ package Games::Axmud::Cmd::QuickMacro;

    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('quickmacro', TRUE, TRUE);
        if (! $self) {return undef}

        $self->{defaultUserCmdList} = ['qm', 'qmacro', 'quickmacro'];
        $self->{userCmdList} = \@{$self->{defaultUserCmdList}};
        $self->{descrip} = 'Creates a macro using the previous command';

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

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

    sub do {

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

        # Local variables
        my $prevBufferObj;

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

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

        if (defined $session->instructBufferLast) {

            $prevBufferObj = $session->ivShow('instructBufferHash', $session->instructBufferLast);
            if (! $prevBufferObj) {

                return $self->error(
                    $session, $inputString,
                    'Can\'t create a macro because the instruction buffer is empty',
                );
            }
        }

        # Add the macro, pretending to be a call from GA::Cmd::AddMacro->do
        return $self->addInterface(
            $session, 'addmacro -s' . $arg . ' -p ' . $prevBufferObj->instruct, $standardCmd,
            'macro',
            'macros',
            $axmud::CLIENT->ivShow('interfaceModelHash', 'macro'),
            '-s',
            $arg,
            '-p',
            $prevBufferObj->instruct,
        );
    }
}

{ package Games::Axmud::Cmd::ModifyMacro;

    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('modifymacro', TRUE, FALSE);
        if (! $self) {return undef}

        $self->{defaultUserCmdList} = ['mma', 'modma', 'modmacro', 'modifyma', 'modifymacro'];
        $self->{userCmdList} = \@{$self->{defaultUserCmdList}};
        $self->{descrip} = 'Modifies a macro';

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

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

    sub do {

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

        # Check for improper arguments
        if (! @args) {

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

        # Modify the macro
        return $self->modifyInterface(
            $session, $inputString, $standardCmd,
            'macro',
            'macros',
            $axmud::CLIENT->ivShow('interfaceModelHash', 'macro'),
            @args,
        );
    }
}

{ package Games::Axmud::Cmd::ExportMacro;

    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('exportmacro', TRUE, FALSE);
        if (! $self) {return undef}

        $self->{defaultUserCmdList} = ['xma', 'expma', 'expmacro', 'exportmac', 'exportmacro'];
        $self->{userCmdList} = \@{$self->{defaultUserCmdList}};
        $self->{descrip} = 'Exports a macro to the interface clipboard';

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

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

    sub do {

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

        # Check for improper arguments
        if (! @args) {

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

        # Export the macro
        return $self->exportInterface(
            $session, $inputString, $standardCmd,
            'macro',
            'macros',
            $axmud::CLIENT->ivShow('interfaceModelHash', 'macro'),
            @args,
        );
    }
}

{ package Games::Axmud::Cmd::ImportMacro;

    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('importmacro', TRUE, FALSE);
        if (! $self) {return undef}

        $self->{defaultUserCmdList} = ['ima', 'impma', 'impmacro', 'importma', 'importmacro'];
        $self->{userCmdList} = \@{$self->{defaultUserCmdList}};
        $self->{descrip} = 'Imports macro(s) from the interface clipboard';

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

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

    sub do {

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

        # (No improper arguments to check)

        # Import the macro(s)
        return $self->importInterface(
            $session, $inputString, $standardCmd,
            'macro',
            'macros',
            $axmud::CLIENT->ivShow('interfaceModelHash', 'macro'),
            @args,
        );
    }
}

{ package Games::Axmud::Cmd::DeleteMacro;

    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('deletemacro', TRUE, FALSE);
        if (! $self) {return undef}

        $self->{defaultUserCmdList} = ['dma', 'delma', 'delmacro', 'deletema', 'deletemacro'];
        $self->{userCmdList} = \@{$self->{defaultUserCmdList}};
        $self->{descrip} = 'Deletes a macro';

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

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

    sub do {

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

        # Check for improper arguments
        if (! @args) {

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

        # Delete the macro
        return $self->deleteInterface(
            $session, $inputString, $standardCmd,
            'macro',
            'macros',
            @args,
        );
    }
}

{ package Games::Axmud::Cmd::ListMacro;

    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('listmacro', TRUE, TRUE);
        if (! $self) {return undef}

        $self->{defaultUserCmdList} = ['lma', 'listma', 'listmacro'];
        $self->{userCmdList} = \@{$self->{defaultUserCmdList}};
        $self->{descrip} = 'Lists macros';

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

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

    sub do {

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

        # (No imprope arguments to check)

        # List macros
        return $self->listInterface(
            $session, $inputString, $standardCmd,
            'macro',
            'macros',
            @args,
        );
    }
}



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