Games-Axmud

 view release on metacpan or  search on metacpan

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

        #       'char_account' will be undef

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

        # Local variables
        my (
            $host, $port, $pass, $account,
            @emptyList,
        );

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

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

        # Prefer IPV6, if specified. Otherwise, prefer 'deathmud.com' over '101.111.121.131'
        if ($self->ipv6) {
            $host = $self->ipv6;
        } elsif ($self->dns) {
            $host = $self->dns;
        } elsif ($self->ipv4) {
            $host = $self->ipv4;
        } else {
            $host = '127.0.0.1';        # Emergency default value
        }

        if ($self->port) {
            $port = $self->port;
        } else {
            $port = 23;                 # Emergency default value
        }

        if ($char) {

            if ($self->ivExists('passwordHash', $char)) {

                $pass = $self->ivShow('passwordHash', $char);

            } elsif ($self->ivExists('newPasswordHash', $char)) {

                # Character profile not created yet, but we know the password
                $pass = $self->ivShow('newPasswordHash', $char);
            }

            if ($self->ivExists('accountHash', $char)) {

                $account = $self->ivShow('accountHash', $char);

            } elsif ($self->ivExists('newAccountHash', $char)) {

                # Character profile not created yet, but we know the password
                $account = $self->ivShow('newAccountHash', $char);
            }
        }

        return ($host, $port, $char, $pass, $account);
    }

    sub updateQuestStats {

        # Called by anything, any time a quest stored by this profile changes
        # Re-calculates this profile's running totals
        #
        # Expected arguements
        #   $session    - The calling function's GA::Session
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

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

        # Local variables
        my ($questCount, $pointCount, $xpCount, $cashCount);

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

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

        # Go through each quest registered in $self->questHash, updating the
        #   running totals wherever possible
        $questCount = 0;
        $pointCount = 0;
        $xpCount = 0;
        $cashCount = 0;
        foreach my $questObj ($self->ivValues('questHash')) {

            $questCount++;

            if (defined $questObj->questPoints) {

                $pointCount += $questObj->questPoints;
            }

            if (defined $questObj->questXP) {

                $xpCount += $questObj->questXP;
            }

            if (defined $questObj->questCash) {

                $cashCount += $questObj->questCash;
            }
        }

        # Save the totals
        $self->ivPoke('questCount', $questCount);
        $self->ivPoke('questPointCount', $pointCount);
        $self->ivPoke('questXPCount', $xpCount);
        $self->ivPoke('questCashCount', $cashCount);

        # Now go through each character profile, and update its quest stats, too
        foreach my $profObj ($session->ivValues('profHash')) {

            if ($profObj->category eq 'char') {

                $profObj->updateQuestStats($session);

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


            skillHistoryList            => [$self->skillHistoryList],

            lifeCount                   => $self->lifeCount,
            deathCount                  => $self->deathCount,
            lifeMax                     => $self->lifeMax,
            lifeStatus                  => $self->lifeStatus,

            remoteWimpy                 => $self->remoteWimpy,
            remoteWimpyMax              => $self->remoteWimpyMax,
            localWimpy                  => $self->localWimpy,
            constLocalWimpyMax          => $self->constLocalWimpyMax,

            age                         => $self->age,

            bankBalance                 => $self->bankBalance,
            purseContents               => $self->purseContents,

            fightCount                  => $self->fightCount,
            killCount                   => $self->killCount,
            wimpyCount                  => $self->wimpyCount,
            fightDefeatCount            => $self->fightDefeatCount,

            interactCount               => $self->interactCount,
            interactSuccessCount        => $self->interactSuccessCount,
            interactFailCount           => $self->interactFailCount,
            interactFightCount          => $self->interactFightCount,
            interactDisasterCount       => $self->interactDisasterCount,

            fleeCount                   => $self->fleeCount,
            escapeCount                 => $self->escapeCount,

            fightVictimHash             => {$self->fightVictimHash},
            fightVictimStringHash       => {$self->fightVictimStringHash},
            interactionVictimHash       => {$self->interactionVictimHash},
            interactionVictimStringHash
                                        => {$self->interactionVictimStringHash},

            statHash                    => {$self->statHash},

            statusCmdHash               => {$self->statusCmdHash},
            statusCmdFlag               => $self->statusCmdFlag,
            inventoryCmdHash            => {$self->inventoryCmdHash},

            protectObjList              => [$self->protectObjList],
            monitorObjList              => [$self->monitorObjList],
        };

        # Bless the cloned object into existence
        bless $clone, $self->_objClass;

        # Also need to clone everything in the initial tasklist
        $clone->cloneInitTaskList($self);

        return $clone;
    }

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

    sub updateQuestStats {

        # Called by anything, any time a quest stored by this profile changes
        # Re-calculates this profile's running totals
        #
        # Expected arguements
        #   $session    - The calling function's GA::Session
        #
        # Return values
        #   'undef' on improper arguments
        #   1 otherwise

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

        # Local variables
        my ($questCount, $pointCount, $xpCount, $cashCount);

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

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

        # Go through each quest registered in $self->questHash, updating the
        #   running totals wherever possible
        $questCount = 0;
        $pointCount = 0;
        $xpCount = 0;
        $cashCount = 0;
        foreach my $questName ($self->ivKeys('questHash')) {

            my $questObj = $session->currentWorld->ivShow('questHash', $questName);
            if ($questObj) {

                $questCount++;

                if (defined $questObj->questPoints) {

                    $pointCount += $questObj->questPoints;
                }

                if (defined $questObj->questXP) {

                    $xpCount += $questObj->questXP;
                }

                if (defined $questObj->questCash) {

                    $cashCount += $questObj->questCash;
                }
            }
        }

        # Save the totals
        $self->ivPoke('questCount', $questCount);
        $self->ivPoke('questPointCount', $pointCount);
        $self->ivPoke('questXPCount', $xpCount);
        $self->ivPoke('questCashCount', $cashCount);

        return 1;
    }



( run in 3.008 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )