Games-Axmud

 view release on metacpan or  search on metacpan

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


            # Remove any leading or trailing whitespace
            $victim = $axmud::CLIENT->trimWhitespace($victim);
            # Remove any punctuation from the end of the string
            $victim =~ s/\W+$//;
        }

        # Import the current character and Status task
        $charObj = $session->currentChar;
        $taskObj = $session->statusTask;

        # Check that $modLine isn't an exception to the usual rules
        foreach my $pattern ($session->currentWorld->noTargetKilledPatternList) {

            if ($modLine =~ m/$pattern/) {

                # Ignore this line
                return undef;
            }
        }

        # Fight complete. Update the current character profile's IVs (via the Status task)
        if ($charObj) {

            # ->fightVictimHash is similarly not updated, but we can update the base string hash
            if ($charObj->ivExists('fightVictimStringHash', lc($victim))) {
                $charObj->ivIncHash('fightVictimStringHash', lc($victim));
            } else {
                $charObj->ivAdd('fightVictimStringHash', lc($victim), 1);
            }

            if ($taskObj) {

                # Updates ->fightCount, ->killCount
                $taskObj->inc_fightCount();
            }
        }

        # Write something in the 'main' window, if allowed
        if ($self->announceFlag) {

            $self->writeText(
                '\'' . $self->uniqueName . '\' task : Detected killed target \'' . $victim . '\'',
            );
        }

        # Write something to the 'attack' logfile, if allowed
        $axmud::CLIENT->writeLog(
            $self->session,
            FALSE,      # Not a 'standard' logfile
            $modLine,
            FALSE,      # Don't precede with a newline character
            TRUE,       # Use final newline character
            'attack',   # Write to this logfile
        );

        # Play a sound effect (if allowed)
        $axmud::CLIENT->playSound('kill');

        # Read a text-to-speech (TTS) message, if required
        $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->targetKilledSeen');
        if ($self->ivShow('ttsFlagAttribHash', 'fight')) {

            $self->ttsQuick('Killed ' . $victim);
        }

        # Send the list of victim commands (if any)
        foreach my $cmd ($self->fightCmdList) {

            $session->relayCmd($cmd);
        }

        return 1;
    }

    sub interactionSuccessSeen {

        # Called by GA::Session->checkTriggers
        #
        # This task's ->resetInteractionTriggers function creates some triggers to capture strings
        #   matching the text received, when the character experiences a successful interaction
        # e.g. ('^You cast a spell on (.*)$', 1)
        #
        # The world profile's successful interaction list occurs in groups of 2 elements,
        #   representing
        #   [0] - the pattern to match
        #   [1] - which group substring contains the data we need
        #
        # The trigger interfaces have the following properties in ->propertyHash:
        #   grp_num         - which group substring contains the data we need (same as [1] )
        #
        # This function checks the appropriate group substring and updates IVs for this task and/or
        #   the Status task. If there are any commands in $self->interactCmdList, they are sent to
        #   the world
        #
        # 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, if the interface
        #       object can't be found, if the victim can't be extracted from the matching text or if
        #       the received line of text is an exception to the normal rules
        #   1 otherwise

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

        # Local variables

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

            $victim = $axmud::CLIENT->trimWhitespace($victim);
            # Remove any punctuation from the end of the string
            $victim =~ s/\W+$//;
        }

        # Import the current character and Status task
        $charObj = $session->currentChar;
        $taskObj = $session->statusTask;

        # Check that $modLine isn't an exception to the usual rules
        foreach my $pattern ($session->currentWorld->noInteractionSuccessPatternList) {

            if ($modLine =~ m/$pattern/) {

                # Ignore this line
                return undef;
            }
        }

        # Update the current character profile's IVs (via the Status task)
        if ($charObj) {

            # ->interactionVictimHash can't be updated because we don't have a main noun; but
            #   we can still update the base string hash
            if ($charObj->ivExists('interactionVictimStringHash', lc($victim))) {
                $charObj->ivIncHash('interactionVictimStringHash', lc($victim));
            } else {
                $charObj->ivAdd('interactionVictimStringHash', lc($victim), 1);
            }

            if ($taskObj) {

                # Updates ->interactCount, ->interactSuccessCount
                $taskObj->inc_interactSuccessCount();
            }
        }

        # Write something in the 'main' window, if allowed
        if ($self->announceFlag) {

            $self->writeText(
                '\'' . $self->uniqueName . '\' task : Detected successful interaction with \''
                . $victim . '\'',
            );
        }

        # Write something to the 'attack' logfile, if allowed
        $axmud::CLIENT->writeLog(
            $self->session,
            FALSE,      # Not a 'standard' logfile
            $modLine,
            FALSE,      # Don't precede with a newline character
            TRUE,       # Use final newline character
            'attack',   # Write to this logfile
        );

        # Play a sound effect (if allowed)
        $axmud::CLIENT->playSound('notify');

        # Read a text-to-speech (TTS) message, if required
        $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->interactionSuccessSeen');
        if (
            $self->ivShow('ttsFlagAttribHash', 'interact')
            || $self->ivShow('ttsFlagAttribHash', 'interaction')
        ) {
            $self->ttsQuick('Successful interaction with ' . $victim);
        }

        # Send the list of victim commands (if any)
        foreach my $cmd ($self->interactCmdList) {

            $session->relayCmd($cmd);
        }

        return 1;
    }

    sub interactionFailSeen {

        # Called by GA::Session->checkTriggers
        #
        # This task's ->resetInteractionTriggers function creates some triggers to capture strings
        #   matching the text received, when the character experiences a failed interaction
        # e.g. ('^You fail to cast a spell on (.*)$', 1)
        #
        # The world profile's failed interaction list occurs in groups of 2 elements, representing
        #   [0] - the pattern to match
        #   [1] - which group substring contains the data we need
        #
        # The trigger interfaces have the following properties in ->propertyHash:
        #   grp_num         - which group substring contains the data we need (same as [1] )
        #
        # This function checks the appropriate group substring and updates IVs for this task and/or
        #   the Status task. If there are any commands in $self->interactCmdList, they are sent to
        #   the world
        #
        # 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, if the interface
        #       object can't be found, if the victim can't be extracted from the matching text or if
        #       the received line of text is an exception to the normal rules
        #   1 otherwise

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

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

        # Import the trigger's properties
        $grpNum = $obj->ivShow('propertyHash', 'grp_num');
        # Get the victim
        $victim = $$grpStringListRef[$grpNum];
        if (! defined $victim) {

            return undef;

        } else {

            # Remove any leading or trailing whitespace
            $victim = $axmud::CLIENT->trimWhitespace($victim);
            # Remove any punctuation from the end of the string
            $victim =~ s/\W+$//;
        }

        # Import the current character and Status task
        $charObj = $session->currentChar;
        $taskObj = $session->statusTask;

        # Check that $modLine isn't an exception to the usual rules
        foreach my $pattern ($session->currentWorld->noInteractionFailPatternList) {

            if ($modLine =~ m/$pattern/) {

                # Ignore this line
                return undef;
            }
        }

        # Interaction complete. Update the current character profile's IVs (via the Status task)
        if ($charObj && $taskObj) {

            # Updates ->interactCount, ->interactFailCount
            $taskObj->inc_interactFailCount();
        }

        # Write something in the 'main' window, if allowed
        if ($self->announceFlag) {

            $self->writeText(
                '\'' . $self->uniqueName . '\' task : Detected failed interaction with \''
                . $victim . '\'',
            );
        }

        # Write something to the 'attack' logfile, if allowed
        $axmud::CLIENT->writeLog(
            $self->session,
            FALSE,      # Not a 'standard' logfile
            $modLine,
            FALSE,      # Don't precede with a newline character
            TRUE,       # Use final newline character
            'attack',   # Write to this logfile
        );

        # Play a sound effect (if allowed)
        $axmud::CLIENT->playSound('notify');

        # Read a text-to-speech (TTS) message, if required
        $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->interactionFailSeen');
        if (
            $self->ivShow('ttsFlagAttribHash', 'interact')
            || $self->ivShow('ttsFlagAttribHash', 'interaction')
        ) {
            $self->ttsQuick('Failed interaction with ' . $victim);
        }

        # Send the list of victim commands (if any)
        foreach my $cmd ($self->interactCmdList) {

            $session->relayCmd($cmd);
        }

        return 1;
    }

    sub interactionFightSeen {

        # Called by GA::Session->checkTriggers
        #
        # This task's ->resetInteractionTriggers function creates some triggers to capture strings
        #   matching the text received, when the character experiences an interaction which leads to
        #   a fight
        # e.g. ('^The (.*) dislikes your spell and attacks you!$',  1)
        #
        # The world profile's interaction fight list occurs in groups of 2 elements, representing
        #   [0] - the pattern to match
        #   [1] - which group substring contains the data we need
        #
        # The trigger interfaces have the following properties in ->propertyHash:
        #   grp_num         - which group substring contains the data we need (same as [1] )
        #
        # This function checks the appropriate group substring and updates IVs for this task and/or
        #   the Status task. If there are any commands in $self->interactCmdList, they are sent to
        #   the world
        #
        # 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, if the interface
        #       object can't be found, if the victim can't be extracted from the matching text or if
        #       the received line of text is an exception to the normal rules
        #   1 otherwise

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

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

        # Import the trigger's properties
        $grpNum = $obj->ivShow('propertyHash', 'grp_num');
        # Get the victim
        $victim = $$grpStringListRef[$grpNum];
        if (! defined $victim) {

            return undef;

        } else {

            # Remove any leading or trailing whitespace
            $victim = $axmud::CLIENT->trimWhitespace($victim);
            # Remove any punctuation from the end of the string
            $victim =~ s/\W+$//;
        }

        # Import the current character and Status task
        $charObj = $session->currentChar;
        $taskObj = $session->statusTask;

        # Check that $modLine isn't an exception to the usual rules
        foreach my $pattern ($session->currentWorld->noInteractionFightPatternList) {

            if ($modLine =~ m/$pattern/) {

                # Ignore this line
                return undef;
            }
        }

        # Interaction complete. Update the current character profile's IVs (via the Status task)
        if ($charObj && $taskObj) {

            # Updates ->interactCount, ->interactFightCount
            $taskObj->inc_interactFightCount();
        }

        # Write something in the 'main' window, if allowed
        if ($self->announceFlag) {

            $self->writeText(
                '\'' . $self->uniqueName . '\' task : Detected interaction leading to fight with \''
                . $victim . '\'',
            );
        }

        # Write something to the 'attack' logfile, if allowed
        $axmud::CLIENT->writeLog(
            $self->session,
            FALSE,      # Not a 'standard' logfile
            $modLine,
            FALSE,      # Don't precede with a newline character
            TRUE,       # Use final newline character
            'attack',   # Write to this logfile
        );

        # Play a sound effect (if allowed)
        $axmud::CLIENT->playSound('notify');

        # Read a text-to-speech (TTS) message, if required
        $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->interactionFightSeen');
        if (
            $self->ivShow('ttsFlagAttribHash', 'interact')
            || $self->ivShow('ttsFlagAttribHash', 'interaction')
        ) {
            $self->ttsQuick('Interaction with ' . $victim . ' has become a fight');
        }

        # Send the list of victim commands (if any)
        foreach my $cmd ($self->interactCmdList) {

            $session->relayCmd($cmd);
        }

        return 1;
    }

    sub interactionDisasterSeen {

        # Called by GA::Session->checkTriggers
        #
        # This task's ->resetInteractionTriggers function creates some triggers to capture strings
        #   matching the text received, when the character experiences a disastrous interaction
        # e.g. ('^The (.*) is enraged and chops your arms off!$',  1)
        #
        # The world profile's failed interaction list occurs in groups of 2 elements, representing
        #   [0] - the pattern to match
        #   [1] - which group substring contains the data we need
        #
        # The trigger interfaces have the following properties in ->propertyHash:
        #   grp_num         - which group substring contains the data we need (same as [1] )
        #
        # This function checks the appropriate group substring and updates IVs for this task and/or
        #   the Status task. If there are any commands in $self->interactCmdList, they are sent to
        #   the world
        #
        # 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, if the interface
        #       object can't be found, if the victim can't be extracted from the matching text or if
        #       the received line of text is an exception to the normal rules
        #   1 otherwise

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

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

        # Import the trigger's properties
        $grpNum = $obj->ivShow('propertyHash', 'grp_num');
        # Get the victim
        $victim = $$grpStringListRef[$grpNum];
        if (! defined $victim) {

            return undef;

        } else {

            # Remove any leading or trailing whitespace
            $victim = $axmud::CLIENT->trimWhitespace($victim);
            # Remove any punctuation from the end of the string
            $victim =~ s/\W+$//;
        }

        # Import the current character and Status task
        $charObj = $session->currentChar;
        $taskObj = $session->statusTask;

        # Check that $modLine isn't an exception to the usual rules
        foreach my $pattern ($session->currentWorld->noInteractionDisasterPatternList) {

            if ($modLine =~ m/$pattern/) {

                # Ignore this line
                return undef;
            }
        }

        # Interaction complete. Update the current character profile's IVs (via the Status task)
        if ($charObj && $taskObj) {

            # Updates ->interactCount, ->interactDisasterCount
            $taskObj->inc_interactDisasterCount();
        }

        # Write something in the 'main' window, if allowed
        if ($self->announceFlag) {

            $self->writeText(
                '\'' . $self->uniqueName . '\' task : Detected disastrous interaction with \''
                . $victim . '\'',
            );
        }

        # Write something to the 'attack' logfile, if allowed
        $axmud::CLIENT->writeLog(
            $self->session,
            FALSE,      # Not a 'standard' logfile
            $modLine,
            FALSE,      # Don't precede with a newline character
            TRUE,       # Use final newline character
            'attack',   # Write to this logfile
        );

        # Play a sound effect (if allowed)
        $axmud::CLIENT->playSound('notify');

        # Read a text-to-speech (TTS) message, if required
        $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->interactionDisasterSeen');
        if (
            $self->ivShow('ttsFlagAttribHash', 'interact')
            || $self->ivShow('ttsFlagAttribHash', 'interaction')
        ) {
            $self->ttsQuick('Disastrous interaction with ' . $victim);
        }

        # Send the list of victim commands (if any)
        foreach my $cmd ($self->interactCmdList) {

            $session->relayCmd($cmd);
        }

        return 1;
    }

    ##################
    # Accessors - set

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

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

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

    sub fightCmdList
        { my $self = shift; return @{$self->{fightCmdList}}; }
    sub interactCmdList
        { my $self = shift; return @{$self->{interactCmdList}}; }
    sub announceFlag
        { $_[0]->{announceFlag} }
}

{ package Games::Axmud::Task::Channels;

    use strict;
    use warnings;
#   use diagnostics;

    use Glib qw(TRUE FALSE);

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

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

    sub new {

        # Creates a new instances of the Channels task
        #
        # Expected arguments
        #   $session    - The parent GA::Session (not stored as an IV)
        #
        # Optional arguments
        #   $taskType   - Which tasklist this task is being created into - 'current' for the current
        #                   tasklist (tasks which are actually running now), 'initial' (tasks which
        #                   should be run when the user connects to the world), 'custom' (tasks with
        #                   customised initial parameters, which are run when the user demands). If

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

        };
        $self->{ttsAlertAttribHash}     = {};
        $self->{status}                 = 'wait_init';
#       $self->{activeFlag}             = TRUE;             # Task can't be activated/disactivated

        # Task parameters
        #
        # The normal background colour for the window (set when the window is enabled) - set to one
        #   of Axmud's standard colour tags or 'undef' to use the default colour
        $self->{defaultColour}          = undef;
        # When some text is diverted to the task window, the window's background colour changes.
        #   The colour depends on the channel. The channels 'tell', 'social', 'custom' and 'warning'
        #   have a colour assigned to them; all other channels share the same colour
        # The IVs are set to an Axmud colour tag. Any non-underlay tag can be used, but the task's
        #   edit window only shows standard colour tags like 'blue' and 'RED'
        # The colour to use for the 'tell' channel
        $self->{tellAlertColour}        = 'YELLOW';
        # The colour to use for the 'social' channel
        $self->{socialAlertColour}      = 'BLUE';
        # The colour to use for the 'custom' channel
        $self->{customAlertColour}      = 'cyan';
        # The colour to use for the 'warning' channel
        $self->{warningAlertColour}     = 'RED',
        # The colour to use for all other channels
        $self->{otherAlertColour}       = 'magenta',

        # When diverted text is received, how many seconds to use the alert colour
        $self->{tellAlertInterval}      = 10;
        $self->{socialAlertInterval}    = 3;
        $self->{customAlertInterval}    = 3;
        $self->{warningAlertInterval}   = 10;
        $self->{otherAlertInterval}     = 10;

        # Which sound effects are played when diverted text is received. The value should be
        #   one of the keys in GA::Client->customSoundHash; if the value is 'undef', no sound effect
        #   is played
        $self->{tellAlertSound}         = 'greeting';
        $self->{socialAlertSound}       = 'notify';
        $self->{customAlertSound}       = 'notify';
        $self->{warningAlertSound}      = 'alarm';
        $self->{otherAlertSound}        = 'notify';

        # Limits to the amount of text displayed in the task window. If set to 0, the whole matching
        #   line is displayed. Otherwise, the first n characters are displayed
        $self->{tellCharLimit}          = 0;
        $self->{socialCharLimit}        = 0;
        $self->{customCharLimit}        = 0;
        $self->{warningCharLimit}       = 0;
        $self->{otherCharLimit}         = 0;

        # Flags which, if set to TRUE, cause the automapper object's current room to be displayed
        #   when a tell, social or custom alert occurs. (If the automapper's current room isn't set,
        #   nothing extra is displayed)
        $self->{tellRoomFlag}           = FALSE;
        $self->{socialRoomFlag}         = FALSE;
        $self->{customRoomFlag}         = FALSE;
        $self->{warningRoomFlag}        = FALSE;
        $self->{otherRoomFlag}          = FALSE;

        # Flags which, if set to TRUE, cause the task window's urgency hint to be set when text is
        #   diverted (might not work in all desktop environments)
        $self->{tellUrgencyFlag}        = FALSE;
        $self->{socialUrgencyFlag}      = FALSE;
        $self->{customUrgencyFlag}      = FALSE;
        $self->{warningUrgencyFlag}     = FALSE;
        $self->{otherUrgencyFlag}       = FALSE;

        # When diverted text is received, the time (matching GA::Session->sessionTime) at which the
        #   alert background colour should be replaced by the default background colour . Usually
        #   set to 'undef', which means the default background colour is visible
        $self->{resetTime}              = undef;
        # Flag set to TRUE the first time diverted text is received (set to FALSE if no diverted
        #   text has been received)
        $self->{firstTextFlag}          = FALSE;
        # Multiple triggers can match a single line, but this task only displays a single line in
        #   its task window once. The display buffer line number of the last line that matched a
        #   tell, social or custom pattern
        $self->{lastLine}               = 0;
        # A short string written to the task window, in front of any text typed by the user (to make
        #   clear what was typed by whom)
        $self->{responseString}         = '=> ';
        # A list of all lines displayed in the window so that, if the window is closed when text is
        #   visible in it, when the window is opened they'll be ready for the user to see
        $self->{lineList}               = [];

        # 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 {

        # Create a clone of an existing task
        # Usually used upon connection to a world, when every task in the initial tasklists must
        #   be cloned into a new object, representing a task in the current tasklist
        # (Also used when cloning a profile object, since all the tasks in its initial tasklist must
        #   also be cloned)
        #
        # Expected arguments

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


        # Convert the specified colour tags into RGB colour tags (or use default colours, if the
        #   specified tags are invalid)
        if (defined $fullCol) {

            ($fullType) = $axmud::CLIENT->checkColourTags($fullCol);
        }

        if (! $fullType) {
            $fullCol = $self->gaugeStripObj->gaugeFullColour;
        } else {
            $fullCol = $axmud::CLIENT->returnRGBColour($fullCol);
        }

        if (defined $emptyCol) {

            ($emptyType) = $axmud::CLIENT->checkColourTags($emptyCol);
        }

        if (! $emptyType) {
            $emptyCol = $self->gaugeStripObj->gaugeEmptyColour;
        } else {
            $emptyCol = $axmud::CLIENT->returnRGBColour($emptyCol);
        }

        if (defined $labelCol) {

            ($labelType) = $axmud::CLIENT->checkColourTags($labelCol);
            if (! $labelType) {
                $labelCol = $self->gaugeStripObj->gaugeLabelColour;
            } else {
                $labelCol = $axmud::CLIENT->returnRGBColour($labelCol);
            }
        }

        # Assign a label, if none was specified
        if ($label eq '') {

            $label = 'Gauge ' . $number;
        }

        # Add the gauge
        $gaugeObj = $self->gaugeStripObj->addGauge(
            $self->session,
            $self->gaugeLevel,
            undef,
            undef,
            $addFlag,
            $label,
            $fullCol,
            $emptyCol,
            $labelCol,
            TRUE,
        );

        if ($gaugeObj) {

            $self->ivAdd('gaugeHash', $number, $gaugeObj);
        }

        $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->addMainWinGauge');

        return 1;
    }

    sub deleteMainWinGauge {

        # Called by LA::Statement::delgauge->implement
        # Deletes a 'main' window gauge, removing the gauge level if there are no gauges/status bars
        #   left for this task
        #
        # Expected arguments
        #   $number     - A local gauge number for this task, matching a key in $self->gaugeHash
        #                   (not related to GA::Obj::Gauge->number)
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

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

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

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

        # Delete the gauge with this local $number, if it exists
        if ($self->ivExists('gaugeHash', $number)) {

          $self->gaugeStripObj->removeGauges(
                $self->session,
                FALSE,
                $self->ivShow('gaugeHash', $number),
            );

            $self->ivDelete('gaugeHash', $number);

            # If there are no more gauges/status bars left for this task, remove the gauge level
            #   assigned to it
            if (! $self->gaugeHash && ! $self->statusBarHash) {

                $self->gaugeStripObj->removeGaugeLevel($self->session, $self->gaugeLevel);
            }
        }

        return 1;
    }

    sub setMainWinGauge {

        # Called by LA::Statement::setgauge->implement
        # Sets the values displayed by the gauge, and tells the gauge box to re-draw its gauges
        #
        # Expected arguments
        #   $number     - A local gauge number for this task, matching a key in $self->gaugeHash
        #                   (not related to GA::Obj::Gauge->number)
        #
        # Optional arguments
        #   $val        - The value to use for the full portion of the gauge. Can be set to 'undef'
        #                   if the value supplied by the Axbasic script wasn't a valid decimal

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

                'firstStripHash',
                'Games::Axmud::Strip::GaugeBox',
            );

            if (! $stripObj) {

                return undef;

            } else {

                $self->ivPoke('gaugeStripObj', $stripObj);
            }
        }

        # Add a gauge level for this task, if one doesn't already exist
        if (! defined $self->gaugeLevel) {

            # The TRUE flag means 'don't draw it yet'
            $level = $self->gaugeStripObj->addGaugeLevel($self->session, TRUE);
            if (! defined $level) {

                return undef;

            } else {

                $self->ivPoke('gaugeLevel', $level);
            }
        }

        # If this task has already created a status bar with the local number $number, remove it
        if ($self->ivExists('statusBarHash', $number)) {

            $self->gaugeStripObj->removeGauges(
                $self->session,
                FALSE,
                $self->ivShow('statusBarHash', $number),
            );
        }

        # Assign a label, if none was specified
        if ($label eq '') {

            $label = 'Bar ' . $number;
        }

        # Add the status bar
        $gaugeObj = $self->gaugeStripObj->addTextGauge(
            $self->session,
            $self->gaugeLevel,
            undef,
            undef,
            $addFlag,
            $label,
        );

        if ($gaugeObj) {

            $self->ivAdd('statusBarHash', $number, $gaugeObj);
        }

        $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->addMainWinStatusBar');

        return 1;
    }

    sub deleteMainWinStatusBar {

        # Called by LA::Statement::delstatus->implement
        # Deletes a 'main' window status bar, removing the gauge level if there are no gauges/status
        #   bars left for this task
        #
        # Expected arguments
        #   $number     - A local status bar number for this task, matching a key in
        #                   $self->statusBarHash (not related to GA::Obj::Gauge->number)
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

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

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

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

        # Delete the status bar with this local $number, if it exists
        if ($self->ivExists('statusBarHash', $number)) {

          $self->gaugeStripObj->removeGauges(
                $self->session,
                FALSE,
                $self->ivShow('statusBarHash', $number),
            );

            $self->ivDelete('statusBarHash', $number);

            # If there are no more gauges/status bars left for this task, remove the gauge level
            #   assigned to it
            if (! $self->gaugeHash && ! $self->statusBarHash) {

                $self->gaugeStripObj->removeGaugeLevel($self->session, $self->gaugeLevel);
            }
        }

        return 1;
    }

    sub setMainWinStatusBar {

        # Called by LA::Statement::setstatus->implement
        # Sets the values displayed by the status bar, and tells the 'main' window to re-draw its
        #   gauges/status bars
        #
        # Expected arguments
        #   $number     - A local status bar number for this task, matching a key in
        #                   $self->statusBarHash (not related to GA::Obj::Gauge->number)
        #
        # Optional arguments
        #   $val        - The value to use that's the equivalent of the full portion of a

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


        # Convert the specified colour tags into RGB colour tags (or use default colours, if the
        #   specified tags are invalid)
        if (defined $fullCol) {

            ($fullType) = $axmud::CLIENT->checkColourTags($fullCol);
        }

        if (! $fullType) {
            $fullCol = $self->taskWinGaugeStripObj->gaugeFullColour;
        } else {
            $fullCol = $axmud::CLIENT->returnRGBColour($fullCol);
        }

        if (defined $emptyCol) {

            ($emptyType) = $axmud::CLIENT->checkColourTags($emptyCol);
        }

        if (! $emptyType) {
            $emptyCol = $self->taskWinGaugeStripObj->gaugeEmptyColour;
        } else {
            $emptyCol = $axmud::CLIENT->returnRGBColour($emptyCol);
        }

        if (defined $labelCol) {

            ($labelType) = $axmud::CLIENT->checkColourTags($labelCol);
            if (! $labelType) {
                $labelCol = $self->taskWinGaugeStripObj->gaugeLabelColour;
            } else {
                $labelCol = $axmud::CLIENT->returnRGBColour($labelCol);
            }
        }

        # Assign a label, if none was specified
        if ($label eq '') {

            $label = 'Gauge ' . $number;
        }

        # Add the gauge
        $gaugeObj = $self->taskWinGaugeStripObj->addGauge(
            $self->session,
            $self->taskWinGaugeLevel,
            undef,
            undef,
            $addFlag,
            $label,
            $fullCol,
            $emptyCol,
            $labelCol,
            TRUE,
        );

        if ($gaugeObj) {

            $self->ivAdd('taskWinGaugeHash', $number, $gaugeObj);
        }

        $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->addTaskWinGauge');

        return 1;
    }

    sub deleteTaskWinGauge {

        # Called by LA::Statement::windelgauge->implement
        # Deletes a task window gauge, removing the gauge level if there are no gauges/status bars
        #   left for this task
        #
        # Expected arguments
        #   $number     - A local gauge number for this task, matching a key in
        #                   $self->taskWinGaugeHash (not related to GA::Obj::Gauge->number)
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

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

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

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

        # Delete the gauge with this local $number, if it exists
        if ($self->ivExists('taskWinGaugeHash', $number)) {

          $self->taskWinGaugeStripObj->removeGauges(
                $self->session,
                FALSE,
                $self->ivShow('taskWinGaugeHash', $number),
            );

            $self->ivDelete('taskWinGaugeHash', $number);

            # If there are no more gauges/status bars left for this task, remove the gauge level
            #   assigned to it
            if (! $self->taskWinGaugeHash && ! $self->taskWinStatusBarHash) {

                $self->taskWinGaugeStripObj->removeGaugeLevel(
                    $self->session, $self->taskWinGaugeLevel,
                );
            }
        }

        return 1;
    }

    sub setTaskWinGauge {

        # Called by LA::Statement::winsetgauge->implement
        # Sets the values displayed by the gauge, and tells the gauge box to re-draw its gauges
        #
        # Expected arguments
        #   $number     - A local gauge number for this task, matching a key in
        #                   $self->taskWinGaugeHash (not related to GA::Obj::Gauge->number)
        #
        # Optional arguments

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

        # The standard winmaps used by tasks don't provide gauges, so insert one ourselves
        if (! $self->taskWinGaugeStripObj) {

            $stripObj = $self->winObj->addStripObj('Games::Axmud::Strip::GaugeBox');
            if (! $stripObj) {

                return undef;

            } else {

                $self->ivPoke('taskWinGaugeStripObj', $stripObj);
            }
        }

        # Add a gauge level for this task, if one doesn't already exist
        if (! defined $self->taskWinGaugeLevel) {

            # The TRUE flag means 'don't draw it yet'
            $level = $self->taskWinGaugeStripObj->addGaugeLevel($self->session, TRUE);
            if (! defined $level) {

                return undef;

            } else {

                $self->ivPoke('taskWinGaugeLevel', $level);
            }
        }

        # If this task has already created a status bar with the local number $number, remove it
        if ($self->ivExists('taskWinStatusBarHash', $number)) {

            $self->taskWinGaugeStripObj->removeGauges(
                $self->session,
                FALSE,
                $self->ivShow('taskWinStatusBarHash', $number),
            );
        }

        # Assign a label, if none was specified
        if ($label eq '') {

            $label = 'Bar ' . $number;
        }

        # Add the status bar
        $gaugeObj = $self->taskWinGaugeStripObj->addTextGauge(
            $self->session,
            $self->taskWinGaugeLevel,
            undef,
            undef,
            $addFlag,
            $label,
        );

        if ($gaugeObj) {

            $self->ivAdd('taskWinStatusBarHash', $number, $gaugeObj);
        }

        $axmud::CLIENT->desktopObj->updateWidgets($self->_objClass . '->addTaskWinStatusBar');

        return 1;
    }

    sub deleteTaskWinStatusBar {

        # Called by LA::Statement::windelstatus->implement
        # Deletes a task window status bar, removing the gauge level if there are no gauges/status
        #   bars left for this task
        #
        # Expected arguments
        #   $number     - A local status bar number for this task, matching a key in
        #                   $self->taskWinStatusBarHash (not related to GA::Obj::Gauge->number)
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

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

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

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

        # Delete the status bar with this local $number, if it exists
        if ($self->ivExists('taskWinStatusBarHash', $number)) {

          $self->taskWinGaugeStripObj->removeGauges(
                $self->session,
                FALSE,
                $self->ivShow('taskWinStatusBarHash', $number),
            );

            $self->ivDelete('taskWinStatusBarHash', $number);

            # If there are no more gauges/status bars left for this task, remove the gauge level
            #   assigned to it
            if (! $self->taskWinGaugeHash && ! $self->taskWinStatusBarHash) {

                $self->taskWinGaugeStripObj->removeGaugeLevel(
                    $self->session, $self->taskWinGaugeLevel,
                );
            }
        }

        return 1;
    }

    sub setTaskWinStatusBar {

        # Called by LA::Statement::winsetstatus->implement
        # Sets the values displayed by the status bar, and tells the 'main' window to re-draw its
        #   gauges/status bars
        #
        # Expected arguments
        #   $number     - A local status bar number for this task, matching a key in
        #                   $self->taskWinStatusBarHash (not related to GA::Obj::Gauge->number)
        #



( run in 0.948 second using v1.01-cache-2.11-cpan-f56aa216473 )