/// <summary> /// Attempts to get an arena qualifier. /// </summary> /// <param name="playerId">The player id.</param> /// <param name="arenaInfo">The qualifier.</param> /// <returns>True if the arena qualifier was retrieved.</returns> public static bool TryGetArenaInfo(int playerId, out Models.Arena.ArenaInfo arenaInfo) { return(_qualifiers.TryGetValue(playerId, out arenaInfo)); }
public static bool GetCustomPlayerData(Models.Entities.Player player, Models.Packets.Client.DataExchangePacket packet) { #region Basic stats // To update it client side ... player.BoundCPs = player.BoundCPs; player.ValidateLoginMap(); player.UpdateStats(); player.Stamina = Data.Constants.GameMode.StartStamina; #endregion #region Status Flags if (!string.IsNullOrWhiteSpace(player.DbPlayer.StatusFlag)) { player.StaticStatusFlag = player.DbPlayer.StatusFlag.ToEnum <Enums.StatusFlag>(); } // Idk why, but for some reason you can't update the client any other way with the pk points and status flag ... var pkp = player.PKPoints; player.PKPoints = 0; player.PKPoints = pkp; #endregion #region Messages if (Collections.BroadcastQueue.LastMessage != null) { player.ClientSocket.Send(Collections.BroadcastQueue.LastMessage); } foreach (var dbWhisper in Database.Dal.WhisperCache.GetAllByRecipent(player.Name, Drivers.Settings.WorldSettings.Server)) { player.ClientSocket.Send( Controllers.Packets.Message.MessageController.CreateWhisper(string.Concat("[Sent offline]", dbWhisper.Message), dbWhisper.From, dbWhisper.To, dbWhisper.Mesh, player.Mesh) ); dbWhisper.Delete(); } #endregion #region Houses var houses = Database.Dal.PlayerHouses.GetAll(player.DbPlayer.Id); if (houses.Count > 0) { bool anyRent = false; foreach (var dbPlayerHouse in houses) { if (!anyRent && dbPlayerHouse.IsLeasing && dbPlayerHouse.NextRentDate.HasValue && DateTime.UtcNow >= dbPlayerHouse.NextRentDate.Value) { anyRent = true; } var playerHouse = new Models.Maps.PlayerHouse(player, dbPlayerHouse); player.Houses.Add(playerHouse); if (dbPlayerHouse.Warehouse) { player.Warehouses.CreateWarehouse((uint)(dbPlayerHouse.MapId + 100000)); playerHouse.CreateWarehouse(); } } if (anyRent) { player.SendSystemMessage("RENT_DUE"); } } #endregion #region Warehouse foreach (var dbOwnerItem in Database.Dal.Warehouses.GetWarehouseItems(player.DbPlayer.Id)) { var item = Collections.ItemCollection.CreateItemById((uint)dbOwnerItem.ItemId); item.DbOwnerItem = dbOwnerItem; if (!string.IsNullOrWhiteSpace(dbOwnerItem.Color)) { item.Color = dbOwnerItem.Color.ToEnum <Enums.ItemColor>(); } item.Gem1 = dbOwnerItem.Gem1.ToEnum <Enums.Gem>(); item.Gem2 = dbOwnerItem.Gem2.ToEnum <Enums.Gem>(); Collections.Warehouse warehouse; if (player.Warehouses.TryGetWarehouse(dbOwnerItem.LocationId.Value, out warehouse)) { if (!warehouse.Add(item, true)) { player.ClientSocket.Disconnect(Drivers.Messages.Errors.FAILED_TO_LOAD_WAREHOUSE); return(false); } } } #endregion #region Nobility Models.Nobility.NobilityDonation nobility; if (Collections.NobilityBoard.TryGetNobility(player.DbPlayer.Id, out nobility)) { nobility.Player = player; player.Nobility = nobility; } player.UpdateClientNobility(); #endregion #region VIP byte vipLevel = 0; if (player.DbPlayer.DonationPoints >= 6) { vipLevel = 6; } else if (player.DbPlayer.DonationPoints > 0) { vipLevel = (byte)player.DbPlayer.DonationPoints; } player.VIPLevel = vipLevel; #endregion #region Arena Models.Arena.ArenaInfo arenaInfo; if (!Collections.ArenaQualifierCollection.TryGetArenaInfo(player.DbPlayer.Id, out arenaInfo)) { arenaInfo = new Models.Arena.ArenaInfo(null) { Player = player }; if (!Collections.ArenaQualifierCollection.TryAddArenaInfo(player.DbPlayer.Id, arenaInfo)) { player.ClientSocket.Disconnect(Drivers.Messages.Errors.FAILED_TO_INITIALIZE_ARENA_INFO); } } else { arenaInfo.Player = player; } player.ArenaInfo = arenaInfo; #endregion // TODO: Load subclass // TODO: Load heaven blessing #region Merchant player.UpdateClient(Enums.UpdateClientType.Merchant, 255UL); #endregion Server.FinishLogin.Handle(player); return(true); }
/// <summary> /// Attempts to add a new arena qualifier. /// </summary> /// <param name="playerId">The player id.</param> /// <param name="arenaInfo">The arena qualifier.</param> /// <returns>True if the qualifier was added.</returns> public static bool TryAddArenaInfo(int playerId, Models.Arena.ArenaInfo arenaInfo) { return(_qualifiers.TryAdd(playerId, arenaInfo)); }