Games-Axmud

 view release on metacpan or  search on metacpan

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

        #               - The world profile's login account mode (->loginAccountMode)
        #   $pwdHashRef - Reference to a hash copied from the profile object's ->passwordHash
        #   $accHashRef - Reference to a hash copied from the profile object's ->accountHash
        #
        # Return values
        #   'undef' on improper arguments or if $name is invalid
        #   Blessed reference to the newly-created object on success

        my (
            $class, $worldObj, $selectChar, $loginAccountMode, $pwdHashRef, $accHashRef, $check,
        ) = @_;

        # Local variables
        my (
            $name,
            %passwordHash, %accountHash,
        );

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

            return $axmud::CLIENT->writeImproper($class . '->new', @_);
        }

        if (! defined $worldObj) {
            $name = 'unnamed_mini_world';
        } else {
            $name = $worldObj->name;
        }

        if (! defined $loginAccountMode) {

            $loginAccountMode = 'unknown';
        }

        if (defined $pwdHashRef) {

            %passwordHash = %$pwdHashRef;
        }

        if (defined $accHashRef) {

            %accountHash = %$accHashRef;
        }

        # Setup
        my $self = {
            _objName                    => $name,
            _objClass                   => $class,
            _parentFile                 => undef,       # No parent file
            _parentWorld                => undef,       # No parent file
            _privFlag                   => FALSE,       # All IVs are public

            # IVs
            # ---

            # The GA::Profile::World object (or GA::Obj::BasicWorld) and its ->name
            name                        => $name,
            worldObj                    => $worldObj,
            # An IV initially set to the world profile's last connected character (might be set
            #   to 'undef'. When the user selects a character from the table's combobox, this IV is
            #   set to that value (or to 'undef' if the 'no character' item is selected)
            selectChar                  => $selectChar,
            # Login account mode - whether an account name is needed to login to this world, as well
            #   as the usual character name/password. Used only to set the label text in some of
            #   the Connections window's 'dialogue' windows; doesn't affect the automatic login
            #   process
            loginAccountMode            => $loginAccountMode,

            # Hash of IVs, in the form
            #   $propHash{iv_name} = scalar_value
            # If the user makes any changes to a world in the Connections window, those changes are
            #   stored in this hash. When it's time to update the world profile,
            #   $self->storeChangesCallback copies them into the corresponding world profile object
            # 'iv_name' can be any of 'name', 'host', 'port' or 'descrip'
            propHash                    => {},
            # The world profile's ->loginMode IV is not stored here; instead, we store the state of
            #   the 'Auto-login' checkbutton (TRUE or FALSE), and pass the result to
            #   GA::Client->startSession
            noAutoLoginFlag             => undef,
            # A hash of characters and passwords, in the same form as
            #   GA::Profile::World->passwordHash, i.e.
            #       $passwordHash{char_profile_name} = password
            #       $passwordHash{char_profile_name} = 'undef'      (if password not known)
            passwordHash                => \%passwordHash,
            # ->passwordHash is initially copied from the world profile's ->passwordHash. Any
            #   changes are also stored in this hash. (Changes include adding a new character,
            #   regardless of whether the new character's password is set, or not)
            newPasswordHash             => {},
            # A hash of characters and associated account names, in the same form as
            #   GA::Profile::World->accountHash, i.e.
            #       $charHash{char_profile_name} = account
            #       $charHash{char_profile_name} = 'undef'      (if no associated account)
            accountHash                 => \%accountHash,
            # ->accountHash is initially copied from the world profile's ->accountHash. Any changes
            #   are also stored in this hash. (Changes include adding a new character, regardless of
            #   whether the new character's password is set, or not)
            newAccountHash              => {},

            # Flag used in Axmud test mode. When set to TRUE, a world profile's ->numberConnects is
            #   set to at least 1, so that the tester can connect to the world in offline mode,
            #   and the next time the GA::OtherWin::Connect is opened, the world will be visible
            #   near the top of its list
            testModeFlag                => FALSE,
        };

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

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

    sub reset {

        # Called by GA::OtherWin::Connect->applyChangesCallback
        # Resets some of this objects IVs after they have been transferred to a world profile
        #
        # Expected arguments
        #   (none besides $self)



( run in 1.409 second using v1.01-cache-2.11-cpan-8dfa8b56332 )