Пример #1
0
        public bool LoadCharacter(DatabaseConnection dbConnection, int characterSlot)
        {
            dataLock.EnterReadLock();
            bool   result      = false;
            string characterID = PlayerDataManager.RetrieveAccountCharacterID(dbConnection.Database, accountName, characterSlot);

            if (!string.IsNullOrEmpty(characterID))
            {
                playerData = new PlayerData(characterID);
                PlayerDataManager.LoadPlayerData(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerStatistics(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerMissionBoardMissions(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerStoryHelperStateSettings(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerJobList(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerTriggerEvents(dbConnection.Database, playerData);

                inventory = new Inventory(playerData.Inventory);
                bank      = new Inventory(playerData.Bank);

                // Load available ExpKit modules
                if (string.IsNullOrEmpty(playerData.AvailableModules))
                {
                    AddEnabledExpKitModules();
                }
                else
                {
                    string[] modules = playerData.AvailableModules.Split(';');
                    availableExpKitModules = new AvailableExpKitModuleCollection(modules.Length);
                    AddEnabledExpKitModules();
                    for (int i = 0; i < modules.Length; i++)
                    {
                        if (modules[i].IsNumeric())
                        {
                            if (availableExpKitModules.Contains((Enums.ExpKitModules)modules[i].ToInt()) == false)
                            {
                                availableExpKitModules.Add(new AvailableExpKitModule((Enums.ExpKitModules)modules[i].ToInt(), false));
                            }
                        }
                    }
                }

                // Load statistics - Statistics data is inherited from PlayerData
                statistics = new Statistics.PlayerStatistics(this);

                // Load mission board data
                missionBoard = new WonderMails.MissionBoard(this);
                missionBoard.LoadMissionBoardData();
                missionBoard.UpdateMissionBoard();

                // Load joblist
                jobList = new WonderMailTasks(this);
                jobList.LoadJobList(playerData.JobList);

                //load mission goals [HIGH]
                goalPoints = new List <GoalPoint>();

                // Load story helper
                storyHelper = new StoryHelper(this);

                // Load trigger events [HIGH]
                triggerEvents = new List <Events.Player.TriggerEvents.ITriggerEvent>();

                // Load player team
                team = new Recruit[playerData.TeamMembers.Length];
                for (int i = 0; i < playerData.TeamMembers.Length; i++)
                {
                    team[i] = new Recruit(client);
                }
                for (int i = 0; i < playerData.TeamMembers.Length; i++)
                {
                    if (playerData.TeamMembers[i].RecruitIndex != -1)
                    {
                        RecruitData recruitData = PlayerDataManager.LoadPlayerRecruit(dbConnection.Database, CharID, playerData.TeamMembers[i].RecruitIndex, playerData.TeamMembers[i].UsingTempStats);
                        if (recruitData != null)
                        {
                            team[i].LoadFromRecruitData(recruitData, playerData.TeamMembers[i].RecruitIndex);
                        }
                        else
                        {
                            playerData.TeamMembers[i].RecruitIndex = -1;
                        }
                    }
                }

                for (int i = 0; i < playerData.TeamMembers.Length; i++)
                {
                    if (team[i].RecruitIndex != -1)
                    {
                        team[i].LoadActiveItemList();
                    }
                }

                // Set the explorer rank
                while (ExplorerRank != Enums.ExplorerRank.Guildmaster && MissionExp >= MissionManager.DetermineMissionExpRequirement(ExplorerRank + 1))
                {
                    ExplorerRank++;
                }

                if (MapID.IsNumeric())
                {
                    int mapNum = MapID.ToInt();
                    if (mapNum == -2)
                    {
                        MapID = MapManager.GenerateMapID(Settings.Crossroads);
                    }
                    else
                    {
                        MapID = "s" + MapID;
                    }
                }
                //            if (string.IsNullOrEmpty(this.id)) {
                //                id = PlayerID.GeneratePlayerID();
                //            }
                //PlayerID.AddPlayerToIndexList(CharID, client.TcpID);

                loaded = true;
            }

            dataLock.ExitReadLock();
            return(result);
        }
Пример #2
0
        public bool LoadCharacter(DatabaseConnection dbConnection, int characterSlot)
        {
            dataLock.EnterReadLock();
            bool result = false;
            string characterID = PlayerDataManager.RetrieveAccountCharacterID(dbConnection.Database, accountName, characterSlot);
            if (!string.IsNullOrEmpty(characterID)) {
                playerData = new PlayerData(characterID);
                PlayerDataManager.LoadPlayerData(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerStatistics(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerMissionBoardMissions(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerStoryHelperStateSettings(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerJobList(dbConnection.Database, playerData);
                PlayerDataManager.LoadPlayerTriggerEvents(dbConnection.Database, playerData);

                inventory = new Inventory(playerData.Inventory);
                bank = new Inventory(playerData.Bank);

                // Load available ExpKit modules
                if (string.IsNullOrEmpty(playerData.AvailableModules)) {
                    AddEnabledExpKitModules();
                } else {
                    string[] modules = playerData.AvailableModules.Split(';');
                    availableExpKitModules = new AvailableExpKitModuleCollection(modules.Length);
                    AddEnabledExpKitModules();
                    for (int i = 0; i < modules.Length; i++) {
                        if (modules[i].IsNumeric()) {
                            if (availableExpKitModules.Contains((Enums.ExpKitModules)modules[i].ToInt()) == false) {
                                availableExpKitModules.Add(new AvailableExpKitModule((Enums.ExpKitModules)modules[i].ToInt(), false));
                            }
                        }
                    }
                }

                // Load statistics - Statistics data is inherited from PlayerData
                statistics = new Statistics.PlayerStatistics(this);

                // Load mission board data
                missionBoard = new WonderMails.MissionBoard(this);
                missionBoard.LoadMissionBoardData();
                missionBoard.UpdateMissionBoard();

                // Load joblist
                jobList = new WonderMailTasks(this);
                jobList.LoadJobList(playerData.JobList);

                //load mission goals [HIGH]
                goalPoints = new List<GoalPoint>();

                // Load story helper
                storyHelper = new StoryHelper(this);

                // Load trigger events [HIGH]
                triggerEvents = new List<Events.Player.TriggerEvents.ITriggerEvent>();

                // Load player team
                team = new Recruit[playerData.TeamMembers.Length];
                for (int i = 0; i < playerData.TeamMembers.Length; i++) {
                    team[i] = new Recruit(client);
                }
                for (int i = 0; i < playerData.TeamMembers.Length; i++) {
                    if (playerData.TeamMembers[i].RecruitIndex != -1) {
                        RecruitData recruitData = PlayerDataManager.LoadPlayerRecruit(dbConnection.Database, CharID, playerData.TeamMembers[i].RecruitIndex, playerData.TeamMembers[i].UsingTempStats);
                        if (recruitData != null) {
                            team[i].LoadFromRecruitData(recruitData, playerData.TeamMembers[i].RecruitIndex);
                        } else {
                            playerData.TeamMembers[i].RecruitIndex = -1;
                        }
                    }
                }

                for (int i = 0; i < playerData.TeamMembers.Length; i++) {
                    if (team[i].RecruitIndex != -1) {
                        team[i].LoadActiveItemList();
                    }
                }

                // Set the explorer rank
                while (ExplorerRank != Enums.ExplorerRank.Guildmaster && MissionExp >= MissionManager.DetermineMissionExpRequirement(ExplorerRank + 1)) {
                    ExplorerRank++;
                }

                if (MapID.IsNumeric()) {
                    int mapNum = MapID.ToInt();
                    if (mapNum == -2) {
                        MapID = MapManager.GenerateMapID(Settings.Crossroads);
                    } else {
                        MapID = "s" + MapID;
                    }
                }
                //            if (string.IsNullOrEmpty(this.id)) {
                //                id = PlayerID.GeneratePlayerID();
                //            }
                //PlayerID.AddPlayerToIndexList(CharID, client.TcpID);

                loaded = true;
            }

            dataLock.ExitReadLock();
            return result;
        }