public bool GetPlayerArenaData(SQLPlayerData _PlayerData, out PlayerData.ArenaData _ResultArenaData) { SQLArenaInfo arenaInfo; if (GetPlayerArenaInfo(_PlayerData, out arenaInfo) == true) { return(GetPlayerArenaData(arenaInfo, out _ResultArenaData)); } _ResultArenaData = null; return(false); }
public bool GetPlayerGearGems(SQLPlayerData _PlayerData, out SQLPlayerGearGems _ResultGearGems) { var conn = OpenConnection(); try { const int ITEMSLOT_COLUMN = 0; const int GEMID1_COLUMN = 1; const int GEMID2_COLUMN = 2; const int GEMID3_COLUMN = 3; const int GEMID4_COLUMN = 4; using (var cmd = new NpgsqlCommand("SELECT itemslot, gemid1, gemid2, gemid3, gemid4 FROM PlayerGearGemsTable WHERE gearid=:ID", conn)) { { var idParam = new NpgsqlParameter("ID", NpgsqlDbType.Integer); idParam.Value = (int)_PlayerData.PlayerGearID; cmd.Parameters.Add(idParam); } using (var reader = cmd.ExecuteReader()) { if (reader.HasRows == true) { _ResultGearGems = SQLPlayerGearGems.CreateEmpty(); while (reader.Read() == true) { SQLGemInfo gemInfo = new SQLGemInfo(); ItemSlot itemSlot = (ItemSlot)reader.GetInt16(ITEMSLOT_COLUMN); gemInfo.GemID1 = reader.GetInt32(GEMID1_COLUMN); gemInfo.GemID2 = reader.GetInt32(GEMID2_COLUMN); gemInfo.GemID3 = reader.GetInt32(GEMID3_COLUMN); gemInfo.GemID4 = reader.GetInt32(GEMID4_COLUMN); _ResultGearGems.Gems.Add(itemSlot, gemInfo); } return(true); } } } } finally { CloseConnection(); } _ResultGearGems = SQLPlayerGearGems.CreateEmpty(); return(false); }
public bool GetPlayerArenaInfo(SQLPlayerData _PlayerData, out SQLArenaInfo _ResultArenaInfo) { _ResultArenaInfo = new SQLArenaInfo(0, 0, 0); if (_PlayerData.PlayerArenaID == 0) { return(false); } var conn = OpenConnection(); try { const int TEAM2V2_COLUMN = 0; const int TEAM3V3_COLUMN = 1; const int TEAM5V5_COLUMN = 2; using (var cmd = new NpgsqlCommand("SELECT team_2v2, team_3v3, team_5v5 FROM PlayerArenaInfoTable WHERE id=:ID", conn)) { { var idParam = new NpgsqlParameter("ID", NpgsqlDbType.Integer); idParam.Value = (int)_PlayerData.PlayerArenaID; cmd.Parameters.Add(idParam); } using (var reader = cmd.ExecuteReader()) { if (reader.Read() == true) { _ResultArenaInfo.Team2v2 = reader.GetInt32(TEAM2V2_COLUMN); _ResultArenaInfo.Team3v3 = reader.GetInt32(TEAM3V3_COLUMN); _ResultArenaInfo.Team5v5 = reader.GetInt32(TEAM5V5_COLUMN); return(true); } } } } finally { CloseConnection(); } return(false); }
public SQLPlayerID UpdateLatestPlayerDataEntry(SQLPlayerID _PlayerID, SQLUploadID _UploadID, PlayerData.Player _PlayerData) { WowVersionEnum wowVersion = VF_RealmPlayersDatabase.StaticValues.GetWowVersion(_PlayerData.Realm); SQLPlayerData playerData = new SQLPlayerData(); playerData.PlayerID = _PlayerID; playerData.UploadID = _UploadID; playerData.UpdateTime = _PlayerData.LastSeen; playerData.PlayerCharacter = _PlayerData.Character; playerData.PlayerGuildID = GenerateNewPlayerGuildDataEntry(_PlayerData.Guild); playerData.PlayerHonorID = GenerateNewPlayerHonorDataEntry(_PlayerData.Honor, wowVersion); playerData.PlayerGearID = GenerateNewPlayerGearDataEntry(_PlayerData.Gear, wowVersion); if (wowVersion != WowVersionEnum.Vanilla) { playerData.PlayerArenaID = GenerateNewPlayerArenaInfoEntry(_PlayerData.Arena); playerData.PlayerTalentsID = GenerateNewPlayerTalentsDataEntry(_PlayerData.TalentPointsData); } else { playerData.PlayerArenaID = 0; playerData.PlayerTalentsID = 0; } if (GenerateNewPlayerDataEntry(playerData) == true) { if (UpdatePlayerEntry(playerData.PlayerID, playerData.UploadID) == false) { VF_RealmPlayersDatabase.Logger.ConsoleWriteLine("Error in UpdateLatestPlayerDataEntry, could not UpdatePlayerEntry!!!"); return(SQLPlayerID.Invalid()); } } else { VF_RealmPlayersDatabase.Logger.ConsoleWriteLine("Error in UpdateLatestPlayerDataEntry, could not GenerateNewPlayerDataEntry!!!"); return(SQLPlayerID.Invalid()); } return(_PlayerID); }
public bool GenerateNewPlayerDataEntry(SQLPlayerData _PlayerData) { if (_PlayerData.PlayerID.ID == 0 || _PlayerData.UploadID.ID == 0 || _PlayerData.PlayerCharacter == null) { return(false); } var conn = OpenConnection(); try { using (var cmdPlayerData = conn.BeginBinaryImport("COPY PlayerDataTable (playerid, uploadid, updatetime, race, class, sex, level, guildinfo, honorinfo, gearinfo, arenainfo, talentsinfo) FROM STDIN BINARY")) { cmdPlayerData.StartRow(); cmdPlayerData.Write((int)_PlayerData.PlayerID, NpgsqlDbType.Integer); cmdPlayerData.Write((int)_PlayerData.UploadID, NpgsqlDbType.Integer); cmdPlayerData.Write(_PlayerData.UpdateTime, NpgsqlDbType.Timestamp); cmdPlayerData.Write((int)_PlayerData.PlayerCharacter.Race, NpgsqlDbType.Smallint); cmdPlayerData.Write((int)_PlayerData.PlayerCharacter.Class, NpgsqlDbType.Smallint); cmdPlayerData.Write((int)_PlayerData.PlayerCharacter.Sex, NpgsqlDbType.Smallint); cmdPlayerData.Write((int)_PlayerData.PlayerCharacter.Level, NpgsqlDbType.Smallint); cmdPlayerData.Write((int)_PlayerData.PlayerGuildID, NpgsqlDbType.Integer); cmdPlayerData.Write((int)_PlayerData.PlayerHonorID, NpgsqlDbType.Integer); cmdPlayerData.Write((int)_PlayerData.PlayerGearID, NpgsqlDbType.Integer); cmdPlayerData.Write((int)_PlayerData.PlayerArenaID, NpgsqlDbType.Integer); cmdPlayerData.Write((int)_PlayerData.PlayerTalentsID, NpgsqlDbType.Integer); cmdPlayerData.Close(); } } finally { CloseConnection(); } return(true); }
public bool GetPlayerGearItems(SQLPlayerData _PlayerData, out SQLPlayerGearItems _ResultGearItems) { var conn = OpenConnection(); try { const int HEAD_COLUMN = 0; const int NECK_COLUMN = 1; const int SHOULDER_COLUMN = 2; const int SHIRT_COLUMN = 3; const int CHEST_COLUMN = 4; const int BELT_COLUMN = 5; const int LEGS_COLUMN = 6; const int FEET_COLUMN = 7; const int WRIST_COLUMN = 8; const int GLOVES_COLUMN = 9; const int FINGER1_COLUMN = 10; const int FINGER2_COLUMN = 11; const int TRINKET1_COLUMN = 12; const int TRINKET2_COLUMN = 13; const int BACK_COLUMN = 14; const int MAINHAND_COLUMN = 15; const int OFFHAND_COLUMN = 16; const int RANGED_COLUMN = 17; const int TABARD_COLUMN = 18; using (var cmd = new NpgsqlCommand("SELECT head, neck, shoulder, shirt, chest, belt, legs, feet, wrist, gloves, finger_1, finger_2, trinket_1, trinket_2, back, main_hand, off_hand, ranged, tabard FROM PlayerGearTable WHERE id=:ID", conn)) { { var idParam = new NpgsqlParameter("ID", NpgsqlDbType.Integer); idParam.Value = (int)_PlayerData.PlayerGearID; cmd.Parameters.Add(idParam); } using (var reader = cmd.ExecuteReader()) { if (reader.Read() == true) { _ResultGearItems = SQLPlayerGearItems.CreateEmpty(); _ResultGearItems.Items.Add(ItemSlot.Head, new SQLIngameItemID(reader.GetInt32(HEAD_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Neck, new SQLIngameItemID(reader.GetInt32(NECK_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Shoulder, new SQLIngameItemID(reader.GetInt32(SHOULDER_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Shirt, new SQLIngameItemID(reader.GetInt32(SHIRT_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Chest, new SQLIngameItemID(reader.GetInt32(CHEST_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Belt, new SQLIngameItemID(reader.GetInt32(BELT_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Legs, new SQLIngameItemID(reader.GetInt32(LEGS_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Feet, new SQLIngameItemID(reader.GetInt32(FEET_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Wrist, new SQLIngameItemID(reader.GetInt32(WRIST_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Gloves, new SQLIngameItemID(reader.GetInt32(GLOVES_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Finger_1, new SQLIngameItemID(reader.GetInt32(FINGER1_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Finger_2, new SQLIngameItemID(reader.GetInt32(FINGER2_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Trinket_1, new SQLIngameItemID(reader.GetInt32(TRINKET1_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Trinket_2, new SQLIngameItemID(reader.GetInt32(TRINKET2_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Back, new SQLIngameItemID(reader.GetInt32(BACK_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Main_Hand, new SQLIngameItemID(reader.GetInt32(MAINHAND_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Off_Hand, new SQLIngameItemID(reader.GetInt32(OFFHAND_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Ranged, new SQLIngameItemID(reader.GetInt32(RANGED_COLUMN))); _ResultGearItems.Items.Add(ItemSlot.Tabard, new SQLIngameItemID(reader.GetInt32(TABARD_COLUMN))); _ResultGearItems.Items.RemoveAll((_V) => _V.Value.ID == 0); return(true); } } } } finally { CloseConnection(); } _ResultGearItems = SQLPlayerGearItems.CreateEmpty(); return(false); }