public static void CreateNewCharacter(MySql database, string accountName, int charNum, PlayerData playerData) { // Add the character to the 'characters' table database.AddRow("characters", new IDataColumn[] { database.CreateColumn(false, "AccountName", accountName), database.CreateColumn(false, "Slot", charNum.ToString()), database.CreateColumn(false, "CharID", playerData.CharID) }); SavePlayerCharacteristics(database, playerData); // SavePlayerExpKit(database, playerData); SavePlayerLocation(database, playerData); SavePlayerTeam(database, playerData); SavePlayerItemGenerals(database, playerData); }
public static void SavePlayerInventory(MySql database, PlayerData playerData) { database.ExecuteNonQuery("DELETE FROM inventory WHERE CharID = \'" + playerData.CharID + "\' " + "AND ItemSlot > " + (playerData.MaxInv)); for (int i = 0; i < playerData.Inventory.Count; i++) { Characters.InventoryItem invItem = playerData.Inventory.ValueByIndex(i); database.UpdateOrInsert("inventory", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "ItemSlot", playerData.Inventory.KeyByIndex(i).ToString()), database.CreateColumn(false, "ItemNum", invItem.Num.ToString()), database.CreateColumn(false, "Amount", invItem.Amount.ToString()), database.CreateColumn(false, "Sticky", invItem.Sticky.ToIntString()), database.CreateColumn(false, "Tag", invItem.Tag) }); } }
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; }
public static void SavePlayerBank(MySql database, PlayerData playerData) { database.ExecuteNonQuery("DELETE FROM bank WHERE CharID = \'" + playerData.CharID + "\' " + "AND ItemSlot > " + (playerData.MaxBank)); MultiRowInsert multiRowInsert = new MultiRowInsert(database, "bank", "CharID", "ItemSlot", "ItemNum", "Amount", "Sticky", "Tag"); for (int i = 0; i < playerData.Bank.Count; i++) { Characters.InventoryItem invItem = playerData.Bank.ValueByIndex(i); multiRowInsert.AddRowOpening(); multiRowInsert.AddColumnData(playerData.CharID); multiRowInsert.AddColumnData(playerData.Bank.KeyByIndex(i), invItem.Num, invItem.Amount); multiRowInsert.AddColumnData(invItem.Sticky.ToIntString(), invItem.Tag); multiRowInsert.AddRowClosing(); } database.ExecuteNonQuery(multiRowInsert.GetSqlQuery()); }
public static void LoadPlayerTriggerEvents(MySql database, PlayerData playerData) { string query = "SELECT trigger_events.ID, trigger_events.Type, trigger_events.Action, " + "trigger_events.TriggerCommand, trigger_events.AutoRemove " + "FROM trigger_events " + "WHERE trigger_events.CharID = \'" + playerData.CharID + "\'"; foreach (DataColumnCollection columnCollection in database.RetrieveRowsEnumerable(query)) { PlayerDataTriggerEvent triggerEvent = new PlayerDataTriggerEvent(); triggerEvent.Items.Add("Type", columnCollection["Type"].ValueString); triggerEvent.Items.Add("ID", columnCollection["ID"].ValueString); triggerEvent.Items.Add("Action", columnCollection["Action"].ValueString); triggerEvent.Items.Add("TriggerCommand", columnCollection["TriggerCommand"].ValueString); triggerEvent.Items.Add("AutoRemove", columnCollection["AutoRemove"].ValueString); playerData.TriggerEvents.Add(triggerEvent); } for (int i = 0; i < playerData.TriggerEvents.Count; i++) { if (playerData.TriggerEvents[i].Items.GetValue("Type") == "1") { query = "SELECT map_load_trigger_event.MapID " + "FROM map_load_trigger_event " + "WHERE map_load_trigger_event.CharID = \'" + playerData.CharID + "\' " + "AND map_load_trigger_event.ID = \'" + playerData.TriggerEvents[i].Items.GetValue("ID") + "\'"; foreach (DataColumnCollection columnCollection in database.RetrieveRowsEnumerable(query)) { playerData.TriggerEvents[i].Items.Add("MapID", columnCollection["MapID"].ValueString); } } else if (playerData.TriggerEvents[i].Items.GetValue("Type") == "2") { query = "SELECT stepped_on_tile_trigger_event.MapID, stepped_on_tile_trigger_event.X, " + "stepped_on_tile_trigger_event.Y " + "FROM stepped_on_tile_trigger_event " + "WHERE stepped_on_tile_trigger_event.CharID = \'" + playerData.CharID + "\' " + "AND stepped_on_tile_trigger_event.ID = \'" + playerData.TriggerEvents[i].Items.GetValue("ID") + "\'"; foreach (DataColumnCollection columnCollection in database.RetrieveRowsEnumerable(query)) { playerData.TriggerEvents[i].Items.Add("MapID", columnCollection["MapID"].ValueString); playerData.TriggerEvents[i].Items.Add("X", columnCollection["X"].ValueString); playerData.TriggerEvents[i].Items.Add("Y", columnCollection["Y"].ValueString); } } else if (playerData.TriggerEvents[i].Items.GetValue("Type") == "3") { query = "SELECT step_counter_trigger_event.Steps, step_counter_trigger_event.StepsCounted " + "FROM step_counter_trigger_event " + "WHERE step_counter_trigger_event.CharID = \'" + playerData.CharID + "\' " + "AND step_counter_trigger_event.ID = \'" + playerData.TriggerEvents[i].Items.GetValue("ID") + "\'"; foreach (DataColumnCollection columnCollection in database.RetrieveRowsEnumerable(query)) { playerData.TriggerEvents[i].Items.Add("Steps", columnCollection["Steps"].ValueString); playerData.TriggerEvents[i].Items.Add("StepsCounted", columnCollection["StepsCounted"].ValueString); } } } }
public static void LoadPlayerStoryChapters(MySql database, PlayerData playerData) { string query = "SELECT story_chapters.Chapter, story_chapters.Complete " + "FROM story_chapters " + "WHERE story_chapters.CharID = \'" + playerData.CharID + "\';"; foreach (DataColumnCollection columnCollection in database.RetrieveRowsEnumerable(query)) { int chapter = columnCollection["Chapter"].ValueString.ToInt(); bool complete = columnCollection["Complete"].ValueString.ToBool(); playerData.StoryChapters.Add(chapter, complete); } }
public static void LoadPlayerRecruitList(MySql database, PlayerData playerData) { string query = "SELECT recruit_list.PokemonID, recruit_list.Status " + "FROM recruit_list " + "WHERE recruit_list.CharID = \'" + playerData.CharID + "\'"; foreach (DataColumnCollection columnCollection in database.RetrieveRowsEnumerable(query)) { int pokemonID = columnCollection["PokemonID"].ValueString.ToInt(); if (playerData.RecruitList.ContainsKey(pokemonID) == false) { playerData.RecruitList.Add(pokemonID, columnCollection["Status"].ValueString.ToByte()); } } playerData.RecruitListLoaded = true; }
public static void LoadPlayerMissionBoardMissions(MySql database, PlayerData playerData) { string query = "SELECT mission_board_missions.Slot, " + "mission_board_missions.ClientIndex, mission_board_missions.TargetIndex, mission_board_missions.RewardIndex, mission_board_missions.MissionType, " + "mission_board_missions.Data1, mission_board_missions.Data2, mission_board_missions.DungeonIndex, mission_board_missions.Goal, " + "mission_board_missions.RDungeon, mission_board_missions.StartScript, mission_board_missions.WinScript, mission_board_missions.LoseScript " + "FROM mission_board_missions " + "WHERE mission_board_missions.CharID = \'" + playerData.CharID + "\' " + "ORDER BY mission_board_missions.Slot"; foreach (DataColumnCollection columnCollection in database.RetrieveRowsEnumerable(query)) { int slot = columnCollection["Slot"].ValueString.ToInt(); PlayerDataJobListItem job = new PlayerDataJobListItem(); job.MissionClientIndex = columnCollection["ClientIndex"].ValueString.ToInt(); job.TargetIndex = columnCollection["TargetIndex"].ValueString.ToInt(); job.RewardIndex = columnCollection["RewardIndex"].ValueString.ToInt(); job.MissionType = columnCollection["MissionType"].ValueString.ToInt(); job.Data1 = columnCollection["Data1"].ValueString.ToInt(); job.Data2 = columnCollection["Data2"].ValueString.ToInt(); job.DungeonIndex = columnCollection["DungeonIndex"].ValueString.ToInt(); job.GoalMapIndex = columnCollection["Goal"].ValueString.ToInt(); job.RDungeon = columnCollection["RDungeon"].ValueString.ToBool(); job.StartStoryScript = columnCollection["StartScript"].ValueString.ToInt(); job.WinStoryScript = columnCollection["WinScript"].ValueString.ToInt(); job.LoseStoryScript = columnCollection["LoseScript"].ValueString.ToInt(); playerData.MissionBoardMissions.Add(job); } }
public static void SavePlayerStatistics(MySql database, PlayerData playerData) { database.UpdateOrInsert("character_statistics", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "TotalPlayTime", playerData.TotalPlayTime.ToString()), database.CreateColumn(false, "LastIPAddressUsed", playerData.LastIPAddressUsed), database.CreateColumn(false, "LastMacAddressUsed", playerData.LastMacAddressUsed), database.CreateColumn(false, "LastLogin", playerData.LastLogin.ToString("yyyy:MM:dd HH:mm:ss")), database.CreateColumn(false, "LastLogout", playerData.LastLogout.ToString("yyyy:MM:dd HH:mm:ss")), database.CreateColumn(false, "LastPlayTime", playerData.LastPlayTime.ToString()), database.CreateColumn(false, "LastOS", playerData.LastOS), database.CreateColumn(false, "LastDotNetVersion", playerData.LastDotNetVersion) }); }
public static void SavePlayerRecruitList(MySql database, PlayerData playerData) { for (int i = 0; i < playerData.StoryHelperStateSettings.Count; i++) { database.UpdateOrInsert("recruit_list", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "PokemonID", playerData.RecruitList.KeyByIndex(i).ToString()), database.CreateColumn(false, "Status", playerData.RecruitList.ValueByIndex(i).ToString()) }); } }
public static void SavePlayerMissionGenerals(MySql database, PlayerData playerData) { database.UpdateOrInsert("missions", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "MissionExp", playerData.MissionExp.ToString()), database.CreateColumn(false, "LastGenTime", playerData.LastGenTime.ToString()), database.CreateColumn(false, "Completions", playerData.MissionCompletions.ToString()) }); }
/* public static void SavePlayerMissionBoardGenerals(MySql database, PlayerData playerData) { database.UpdateOrInsert("mission_board", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "LastGenerationDate", playerData.MissionBoardLastGenerationDate.Ticks.ToString()) }); } */ public static void SavePlayerMissionBoardMissions(MySql database, PlayerData playerData) { database.ExecuteNonQuery("DELETE FROM mission_board_missions WHERE CharID = \'" + playerData.CharID + "\'"); for (int i = 0; i < playerData.MissionBoardMissions.Count; i++) { database.UpdateOrInsert("mission_board_missions", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "Slot", i.ToString()), database.CreateColumn(false, "ClientIndex", playerData.MissionBoardMissions[i].MissionClientIndex.ToString()), database.CreateColumn(false, "TargetIndex", playerData.MissionBoardMissions[i].TargetIndex.ToString()), database.CreateColumn(false, "RewardIndex", playerData.MissionBoardMissions[i].RewardIndex.ToString()), database.CreateColumn(false, "MissionType", playerData.MissionBoardMissions[i].MissionType.ToString()), database.CreateColumn(false, "Data1", playerData.MissionBoardMissions[i].Data1.ToString()), database.CreateColumn(false, "Data2", playerData.MissionBoardMissions[i].Data2.ToString()), database.CreateColumn(false, "DungeonIndex", playerData.MissionBoardMissions[i].DungeonIndex.ToString()), database.CreateColumn(false, "Goal", playerData.MissionBoardMissions[i].GoalMapIndex.ToString()), database.CreateColumn(false, "RDungeon", playerData.MissionBoardMissions[i].RDungeon.ToIntString()), database.CreateColumn(false, "StartScript", playerData.MissionBoardMissions[i].StartStoryScript.ToString()), database.CreateColumn(false, "WinScript", playerData.MissionBoardMissions[i].WinStoryScript.ToString()), database.CreateColumn(false, "LoseScript", playerData.MissionBoardMissions[i].LoseStoryScript.ToString()) }); } }
public static void SavePlayerLocation(MySql database, PlayerData playerData) { database.UpdateOrInsert("location", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "Map", playerData.Map), database.CreateColumn(false, "X", playerData.X.ToString()), database.CreateColumn(false, "Y", playerData.Y.ToString()), database.CreateColumn(false, "Direction", playerData.Direction.ToString()) }); }
public static void SavePlayerJobList(MySql database, PlayerData playerData) { database.ExecuteNonQuery("DELETE FROM job_list WHERE CharID = \'" + playerData.CharID + "\'"); for (int i = 0; i < playerData.JobList.Count; i++) { PlayerDataJobListItem jobItem = playerData.JobList[i]; database.UpdateOrInsert("job_list", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "JobListSlot", i.ToString()), database.CreateColumn(false, "Accepted", jobItem.Accepted.ToString()), database.CreateColumn(false, "SendsRemaining", jobItem.SendsRemaining.ToString()), database.CreateColumn(false, "ClientIndex", jobItem.MissionClientIndex.ToString()), database.CreateColumn(false, "TargetIndex", jobItem.TargetIndex.ToString()), database.CreateColumn(false, "RewardIndex", jobItem.RewardIndex.ToString()), database.CreateColumn(false, "MissionType", jobItem.MissionType.ToString()), database.CreateColumn(false, "Data1", jobItem.Data1.ToString()), database.CreateColumn(false, "Data2", jobItem.Data2.ToString()), database.CreateColumn(false, "DungeonIndex", jobItem.DungeonIndex.ToString()), database.CreateColumn(false, "Goal", jobItem.GoalMapIndex.ToString()), database.CreateColumn(false, "RDungeon", jobItem.RDungeon.ToIntString()), database.CreateColumn(false, "StartScript", jobItem.StartStoryScript.ToString()), database.CreateColumn(false, "WinScript", jobItem.WinStoryScript.ToString()), database.CreateColumn(false, "LoseScript", jobItem.LoseStoryScript.ToString()) }); } }
public static void SavePlayerItemGenerals(MySql database, PlayerData playerData) { database.UpdateOrInsert("items", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "MaxInv", playerData.MaxInv.ToString()), database.CreateColumn(false, "MaxBank", playerData.MaxBank.ToString()) }); }
public static void LoadPlayerIgnoreList(MySql database, PlayerData playerData) { //string query = "SELECT friends.FriendName " + // "FROM friends " + // "WHERE friends.CharID = \'" + playerData.CharID + "\';"; //List<DataColumnCollection> rows = database.RetrieveRows(query); //if (rows != null) { // for (int i = 0; i < rows.Count; i++) { // playerData.Friends.QuickAdd(rows[i]["FriendName"].ValueString); // } //} //playerData.Friends.Loaded = true; }
public static void LoadPlayerJobList(MySql database, PlayerData playerData) { string query = "SELECT job_list.Accepted, job_list.SendsRemaining, " + "job_list.ClientIndex, job_list.TargetIndex, job_list.RewardIndex, job_list.MissionType, " + "job_list.Data1, job_list.Data2, job_list.DungeonIndex, job_list.Goal, " + "job_list.RDungeon, job_list.StartScript, job_list.WinScript, job_list.LoseScript " + "FROM job_list " + "WHERE job_list.CharID = \'" + playerData.CharID + "\' " + "ORDER BY job_list.JobListSlot"; foreach (DataColumnCollection columnCollection in database.RetrieveRowsEnumerable(query)) { PlayerDataJobListItem jobItem = new PlayerDataJobListItem(); jobItem.Accepted = columnCollection["Accepted"].ValueString.ToInt(); jobItem.SendsRemaining = columnCollection["SendsRemaining"].ValueString.ToInt(); jobItem.MissionClientIndex = columnCollection["ClientIndex"].ValueString.ToInt(); jobItem.TargetIndex = columnCollection["TargetIndex"].ValueString.ToInt(); jobItem.RewardIndex = columnCollection["RewardIndex"].ValueString.ToInt(); jobItem.MissionType = columnCollection["MissionType"].ValueString.ToInt(); jobItem.Data1 = columnCollection["Data1"].ValueString.ToInt(); jobItem.Data2 = columnCollection["Data2"].ValueString.ToInt(); jobItem.DungeonIndex = columnCollection["DungeonIndex"].ValueString.ToInt(); jobItem.GoalMapIndex = columnCollection["Goal"].ValueString.ToInt(); jobItem.RDungeon = columnCollection["RDungeon"].ValueString.ToBool(); jobItem.StartStoryScript = columnCollection["StartScript"].ValueString.ToInt(); jobItem.WinStoryScript = columnCollection["WinScript"].ValueString.ToInt(); jobItem.LoseStoryScript = columnCollection["LoseScript"].ValueString.ToInt(); playerData.JobList.Add(jobItem); } }
public static void SavePlayerStoryChapters(MySql database, PlayerData playerData) { for (int i = 0; i < playerData.StoryChapters.Count; i++) { database.UpdateOrInsert("story_chapters", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "Chapter", playerData.StoryChapters.KeyByIndex(i).ToString()), database.CreateColumn(false, "Complete", playerData.StoryChapters.ValueByIndex(i).ToIntString()) }); } }
public static void SavePlayerStoryGenerals(MySql database, PlayerData playerData) { database.UpdateOrInsert("story", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "CurrentChapter", playerData.CurrentChapter), database.CreateColumn(false, "CurrentSegment", playerData.CurrentSegment.ToString()) }); }
public static void SavePlayerStoryHelperStateSettings(MySql database, PlayerData playerData) { for (int i = 0; i < playerData.StoryHelperStateSettings.Count; i++) { database.UpdateOrInsert("story_helper_state_settings", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "SettingKey", playerData.StoryHelperStateSettings.KeyByIndex(i)), database.CreateColumn(false, "Value", playerData.StoryHelperStateSettings.ValueByIndex(i)) }); } }
public static void LoadPlayerStatistics(MySql database, PlayerData playerData) { string query = "SELECT character_statistics.TotalPlayTime, character_statistics.LastIPAddressUsed, " + "character_statistics.LastMacAddressUsed, character_statistics.LastLogin, character_statistics.LastLogout, " + "character_statistics.LastPlayTime, character_statistics.LastOS, character_statistics.LastDotNetVersion " + "FROM character_statistics " + "WHERE character_statistics.CharID = \'" + playerData.CharID + "\'"; DataColumnCollection row = database.RetrieveRow(query); if (row != null) { playerData.TotalPlayTime = TimeSpan.Parse(row["TotalPlayTime"].ValueString); playerData.LastIPAddressUsed = row["LastIPAddressUsed"].ValueString; playerData.LastMacAddressUsed = row["LastMacAddressUsed"].ValueString; playerData.LastLogin = DateTime.ParseExact(row["LastLogin"].ValueString, "yyyy:MM:dd HH:mm:ss", null); playerData.LastLogout = DateTime.ParseExact(row["LastLogout"].ValueString, "yyyy:MM:dd HH:mm:ss", null); playerData.LastPlayTime = TimeSpan.Parse(row["LastPlayTime"].ValueString); playerData.LastOS = row["LastOS"].ValueString; playerData.LastDotNetVersion = row["LastDotNetVersion"].ValueString; } }
public static void SavePlayerTeam(MySql database, PlayerData playerData) { for (int i = 0; i < playerData.TeamMembers.Length; i++) { database.UpdateOrInsert("team", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "Slot", i.ToString()), database.CreateColumn(false, "RecruitIndex", playerData.TeamMembers[i].RecruitIndex.ToString()), database.CreateColumn(false, "UsingTempStats", playerData.TeamMembers[i].UsingTempStats.ToIntString()) }); } }
public static void LoadPlayerStoryHelperStateSettings(MySql database, PlayerData playerData) { string query = "SELECT story_helper_state_settings.SettingKey, story_helper_state_settings.Value " + "FROM story_helper_state_settings " + "WHERE story_helper_state_settings.CharID = \'" + playerData.CharID + "\'"; foreach (DataColumnCollection columnCollection in database.RetrieveRowsEnumerable(query)) { playerData.StoryHelperStateSettings.Add( columnCollection["SettingKey"].ValueString, columnCollection["Value"].ValueString); } }
public static void SavePlayerTriggerEvents(MySql database, PlayerData playerData) { for (int i = 0; i < playerData.TriggerEvents.Count; i++) { PlayerDataTriggerEvent triggerEvent = playerData.TriggerEvents[i]; database.UpdateOrInsert("trigger_events", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "ID", triggerEvent.Items.GetValue("ID")), database.CreateColumn(false, "Type", triggerEvent.Items.GetValue("Type")), database.CreateColumn(false, "Action", triggerEvent.Items.GetValue("Action")), database.CreateColumn(false, "TriggerCommand", triggerEvent.Items.GetValue("TriggerCommand")), database.CreateColumn(false, "AutoRemove", triggerEvent.Items.GetValue("AutoRemove")) }); switch (triggerEvent.Items.GetValue("Type")) { case "1": { database.UpdateOrInsert("map_load_trigger_event", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "ID", triggerEvent.Items.GetValue("ID")), database.CreateColumn(false, "MapID", triggerEvent.Items.GetValue("MapID")) }); } break; case "2": { database.UpdateOrInsert("stepped_on_tile_trigger_event", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "ID", triggerEvent.Items.GetValue("ID")), database.CreateColumn(false, "MapID", triggerEvent.Items.GetValue("MapID")), database.CreateColumn(false, "X", triggerEvent.Items.GetValue("X")), database.CreateColumn(false, "Y", triggerEvent.Items.GetValue("Y")) }); } break; case "3": { database.UpdateOrInsert("step_counter_trigger_event", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "ID", triggerEvent.Items.GetValue("ID")), database.CreateColumn(false, "Steps", triggerEvent.Items.GetValue("Steps")), database.CreateColumn(false, "StepsCounted", triggerEvent.Items.GetValue("StepsCounted")), }); } break; } } }
public static void SavePlayerAvailableExpKitModules(MySql database, PlayerData playerData) { database.UpdateOrInsert("expkit", new IDataColumn[] { database.CreateColumn(false, "CharID", playerData.CharID), database.CreateColumn(false, "AvailableModules", playerData.AvailableModules.ToString()) }); }
/* public static bool IsWonderMailCompleted(MySql database, string charID, string wonderMail) { string query = "SELECT completed_mail.Code " + "FROM completed_mail " + "WHERE completed_mail.CharID = \'" + database.VerifyValueString(charID) + "\' " + "AND completed_mail.Code = \'" + database.VerifyValueString(wonderMail) + "\';"; DataColumnCollection row = database.RetrieveRow(query); if (row != null) { if (!string.IsNullOrEmpty(row["Code"].ValueString)) { return true; } else { return false; } } else { return false; } } public static void LoadPlayerCompletedMail(MySql database, PlayerData playerData) { string query = "SELECT completed_mail.Code " + "FROM completed_mail " + "WHERE completed_mail.CharID = \'" + playerData.CharID + "\';"; foreach (DataColumnCollection columnCollection in database.RetrieveRowsEnumerable(query)) { string code = columnCollection["Code"].ValueString; playerData.CompletedMail.Add(code); } } */ public static bool LoadPlayerData(MySql database, PlayerData playerData) { string query = "SELECT accounts.Email, characteristics.Name, characteristics.Access, characteristics.ActiveSlot, characteristics.PK, " + "characteristics.Solid, characteristics.Status, characteristics.Veteran, characteristics.InTempMode, characteristics.Dead, " + "expkit.AvailableModules, " + "location.Map, location.X, location.Y, location.Direction, " + "guild.GuildName, guild.GuildAccess, " + "story.CurrentChapter, story.CurrentSegment, " + "items.MaxInv, items.MaxBank, " + "missions.MissionExp, missions.LastGenTime, missions.Completions " + "FROM characteristics " + "LEFT OUTER JOIN characters ON characters.CharID = characteristics.CharID " + "LEFT OUTER JOIN accounts ON accounts.AccountName = characters.AccountName " + "LEFT OUTER JOIN expkit ON expkit.CharID = characteristics.CharID " + "LEFT OUTER JOIN location ON characteristics.CharID = location.CharID " + "LEFT OUTER JOIN guild ON characteristics.CharID = guild.CharID " + "LEFT OUTER JOIN story ON characteristics.CharID = story.CharID " + "LEFT OUTER JOIN items ON characteristics.CharID = items.CharID " + "LEFT OUTER JOIN missions ON items.CharID = missions.CharID " + "WHERE characteristics.CharID = \'" + database.VerifyValueString(playerData.CharID) + "\';"; DataColumnCollection row = database.RetrieveRow(query); if (row != null) { playerData.Email = row["Email"].ValueString; playerData.Name = row["Name"].ValueString; playerData.Access = row["Access"].ValueString.ToByte(); playerData.ActiveSlot = row["ActiveSlot"].ValueString.ToInt(); playerData.PK = row["PK"].ValueString.ToBool(); playerData.Solid = row["Solid"].ValueString.ToBool(); playerData.Status = row["Status"].ValueString; playerData.Veteran = row["Veteran"].ValueString.ToBool(); playerData.InTempMode = row["InTempMode"].ValueString.ToBool(); playerData.Dead = row["Dead"].ValueString.ToBool(); playerData.AvailableModules = row["AvailableModules"].ValueString; playerData.Map = row["Map"].ValueString; playerData.X = row["X"].ValueString.ToInt(); playerData.Y = row["Y"].ValueString.ToInt(); playerData.Direction = row["Direction"].ValueString.ToByte(); playerData.GuildName = row["GuildName"].ValueString; playerData.GuildAccess = row["GuildAccess"].ValueString.ToByte(); playerData.CurrentChapter = row["CurrentChapter"].ValueString; playerData.CurrentSegment = row["CurrentSegment"].ValueString.ToInt(-1); playerData.MaxInv = row["MaxInv"].ValueString.ToInt(-1); playerData.MaxBank = row["MaxBank"].ValueString.ToInt(-1); playerData.MissionExp = row["MissionExp"].ValueString.ToInt(0); playerData.LastGenTime = row["LastGenTime"].ValueString.ToInt(); playerData.MissionCompletions = row["Completions"].ValueString.ToInt(); } else { return false; } // Load team data query = "SELECT team.Slot, team.RecruitIndex, team.UsingTempStats " + "FROM team " + "WHERE team.CharID = \'" + playerData.CharID + "\' " + "AND team.Slot >= 0 " + "AND team.Slot < 4"; List<DataColumnCollection> rows = database.RetrieveRows(query); if (rows != null) { for (int i = 0; i < rows.Count; i++) { int slot = rows[i]["Slot"].ValueString.ToInt(); playerData.TeamMembers[slot] = new PlayerDataTeamMember(); playerData.TeamMembers[slot].RecruitIndex = rows[i]["RecruitIndex"].ValueString.ToInt(); playerData.TeamMembers[slot].UsingTempStats = rows[i]["UsingTempStats"].ValueString.ToBool(); } } if (playerData.TeamMembers[0].RecruitIndex == -1) { playerData.TeamMembers[0].RecruitIndex = 0; } // Load inventory query = "SELECT inventory.ItemSlot, inventory.ItemNum, inventory.Amount, " + "inventory.Sticky, inventory.Tag " + "FROM inventory " + "WHERE inventory.CharID = \'" + playerData.CharID + "\';"; foreach (DataColumnCollection columnCollection in database.RetrieveRowsEnumerable(query)) { Characters.InventoryItem invItem = new Characters.InventoryItem(); int itemSlot = columnCollection["ItemSlot"].ValueString.ToInt(-1); if (itemSlot > -1) { invItem.Num = columnCollection["ItemNum"].ValueString.ToInt(0); invItem.Amount = columnCollection["Amount"].ValueString.ToInt(0); invItem.Sticky = columnCollection["Sticky"].ValueString.ToBool(); invItem.Tag = columnCollection["Tag"].ValueString; playerData.Inventory.Add(itemSlot, invItem); } } for (int i = 1; i <= playerData.MaxInv; i++) { if (playerData.Inventory.ContainsKey(i) == false) { Characters.InventoryItem invItem = new Characters.InventoryItem(); playerData.Inventory.Add(i, invItem); } } // Load bank query = "SELECT bank.ItemSlot, bank.ItemNum, bank.Amount, " + "bank.Sticky, bank.Tag " + "FROM bank " + "WHERE bank.CharID = \'" + playerData.CharID + "\';"; foreach (DataColumnCollection columnCollection in database.RetrieveRowsEnumerable(query)) { Characters.InventoryItem invItem = new Characters.InventoryItem(); int itemSlot = columnCollection["ItemSlot"].ValueString.ToInt(-1); if (itemSlot > -1) { invItem.Num = columnCollection["ItemNum"].ValueString.ToInt(0); invItem.Amount = columnCollection["Amount"].ValueString.ToInt(0); invItem.Sticky = columnCollection["Sticky"].ValueString.ToBool(); invItem.Tag = columnCollection["Tag"].ValueString; playerData.Bank.Add(itemSlot, invItem); } } for (int i = 1; i <= playerData.MaxBank; i++) { if (playerData.Bank.ContainsKey(i) == false) { Characters.InventoryItem invItem = new Characters.InventoryItem(); playerData.Bank.Add(i, invItem); } } return true; }
public static void CharacterCreated(string accountName, int slot, PlayerData characterData, RecruitData leaderData) { try { leaderData.Level = 5; } catch (Exception ex) { Messenger.AdminMsg("Error: CharacterCreated", Text.Black); } }
public static void LoadPlayerDungeonCompletionCounts(MySql database, PlayerData playerData) { string query = "SELECT dungeons.DungeonID, dungeons.CompletionCount " + "FROM dungeons " + "WHERE dungeons.CharID = \'" + playerData.CharID + "\';"; List<DataColumnCollection> rows = database.RetrieveRows(query); if (rows != null) { for (int i = 0; i < rows.Count; i++) { int dungeonID = rows[i]["DungeonID"].ValueString.ToInt(); int completionCount = rows[i]["CompletionCount"].ValueString.ToInt(); int index = playerData.DungeonCompletionCounts.IndexOfKey(dungeonID); if (index > -1) { playerData.DungeonCompletionCounts.Values[index] = completionCount; } else { playerData.DungeonCompletionCounts.Add(dungeonID, completionCount); } } } playerData.DungeonCompletionCountsLoaded = true; }
public void CreateCharacter(DatabaseConnection dbConnection, string name, Enums.Sex sex, int slot, bool silent) { PlayerData characterData = new PlayerData(PlayerID.GeneratePlayerID()); characterData.Name = name; characterData.Map = MapManager.GenerateMapID(Settings.StartMap); characterData.X = Settings.StartX; characterData.Y = Settings.StartY; characterData.MaxInv = 20; characterData.MaxBank = 100; RecruitData leaderData = new RecruitData(); leaderData.Name = name; leaderData.Sex = (byte)sex; leaderData.Species = 0; leaderData.Form = 1; leaderData.Level = 1; leaderData.HP = -1; Scripting.ScriptManager.InvokeSub("CharacterCreated", accountName, slot, characterData, leaderData); PlayerDataManager.CreateNewCharacter(dbConnection.Database, accountName, slot, characterData); //PlayerDataManager.SavePlayerAvailableExpKitModules(client.Database, playerData); //PlayerDataManager.SavePlayerCharacteristics(client.Database, playerData); //PlayerDataManager.SavePlayerGuild(client.Database, playerData); //PlayerDataManager.SavePlayerItemGenerals(client.Database, playerData); //PlayerDataManager.SavePlayerJobList(client.Database, playerData); //PlayerDataManager.SavePlayerLocation(client.Database, playerData); //PlayerDataManager.SavePlayerMissionBoardGenerals(client.Database, playerData); //PlayerDataManager.SavePlayerMissionBoardMissions(client.Database, playerData); //PlayerDataManager.SavePlayerMissionGenerals(client.Database, playerData); //PlayerDataManager.SavePlayerStoryGenerals(client.Database, playerData); //PlayerDataManager.SavePlayerStoryHelperStateSettings(client.Database, playerData); //// Save inventory //ListPair<int, PlayerDataInventoryItem> updatedInventory = new ListPair<int, PlayerDataInventoryItem>(); //for (int i = 1; i <= Inventory.Count; i++) { // if (Inventory[i].Updated) { // updatedInventory.Add(i, Inventory[i].BaseInventoryItem); // Inventory[i].Updated = false; // } //} //PlayerDataManager.SavePlayerInventoryUpdates(client.Database, CharID, updatedInventory); //// Save bank //ListPair<int, PlayerDataInventoryItem> updatedBank = new ListPair<int, PlayerDataInventoryItem>(); //for (int i = 1; i <= Bank.Count; i++) { // if (Bank[i].Updated) { // updatedBank.Add(i, Bank[i].BaseInventoryItem); // Bank[i].Updated = false; // } //} //PlayerDataManager.SavePlayerBankUpdates(client.Database, CharID, updatedBank); //// Save trigger events //playerData.TriggerEvents.Clear(); //for (int i = 0; i < triggerEvents.Count; i++) { // PlayerDataTriggerEvent triggerEvent = new PlayerDataTriggerEvent(); // triggerEvents[i].Save(triggerEvent); // playerData.TriggerEvents.Add(triggerEvent); //} //PlayerDataManager.SavePlayerTriggerEvents(client.Database, playerData); //// Save team //for (int i = 0; i < team.Length; i++) { // playerData.TeamMembers[i].RecruitIndex = team[i].RecruitIndex; // playerData.TeamMembers[i].UsingTempStats = team[i].InTempMode; // if (team[i].Loaded) { // team[i].Save(); // } //} //PlayerDataManager.SavePlayerTeam(client.Database, playerData); PlayerDataManager.SavePlayerRecruit(dbConnection.Database, characterData.CharID, 0, leaderData); if (silent == false) { Messenger.SendChars(dbConnection, client); Messenger.PlainMsg(client, "Character has been created!", Enums.PlainMsgType.Chars); } }
public static void SavePlayerIgnoreList(MySql database, PlayerData playerData) { //database.ExecuteNonQuery("DELETE FROM friends WHERE CharID = \'" + playerData.CharID + "\' " + // "AND FriendListSlot > " + (playerData.Friends.Count - 1)); //database.DeleteRow("friends", "CharID = \'" + playerData.CharID + "\'"); //for (int i = 0; i < playerData.Friends.Count; i++) { // database.UpdateOrInsert("friends", new IDataColumn[] { // database.CreateColumn(false, "CharID", playerData.CharID), // database.CreateColumn(false, "FriendListSlot", i.ToString()), // database.CreateColumn(false, "FriendName", playerData.Friends[i]) // }); //} }