public void ItemEnchantReq(GameSession session, ItemEnchantReqMessage message) { // Todo !! Enchant For Costumes - Only need to fill the xml containing effects and levels Player player = session.Player; if (player == null) { return; } if (player.PEN < 200) { session.SendAsync(new EnchantItemAckMessage(EnchantResult.NotEnoughMoney)); return; } PlayerItem item = player.Inventory[(ulong)message.ItemId]; // Checks if item not equal null and enchant lvl is less than 16 and is a weapon if (item == null || item.ItemNumber.Category != ItemCategory.Weapon || item.EnchantLvl >= 16) { session.SendAsync(new EnchantItemAckMessage(EnchantResult.ErrorItemEnchant)); } else { try { EnchantSys enchantSystems = GameServer.Instance.ResourceCache.GetEnchantSystem()[item.EnchantLvl]; uint num = (new uint[25] { 200, 200, 300, 300, 500, 500, 600, 600, 800, 800, 1100, 1100, 1300, 1500, 1800, 2300, 2900, 3500, 4200, 5200, 5200, 5200, 5200, 5200, 5200 })[item.EnchantLvl]; EnchantGroup[] array = enchantSystems.EnchantGroup.Where(delegate(EnchantGroup i) { return((i.Category == item.ItemNumber.Category) & (i.SubCategory == item.ItemNumber.SubCategory)); }).ToArray(); // Checks if player's pen is less than cost if (player.PEN < num) { session.SendAsync(new EnchantItemAckMessage(EnchantResult.NotEnoughMoney)); return; } EnchantSystem enchantSystem = array[0].Eff(); EnchantResult result = EnchantResult.Success; uint num2 = enchantSystem.Effect; List <EffectNumber> list = item.Effects.ToList(); if (list.Contains(num2 - 1)) { list.Remove(num2 - 1); list.Add(num2); } else if (list.Contains(num2 - 2)) { list.Remove(num2 - 2); list.Add(num2); } else if (list.Contains(num2 - 3)) { list.Remove(num2 - 3); list.Add(num2); } else if (list.Contains(num2 - 4)) { list.Remove(num2 - 4); list.Add(num2); } else if (!list.Contains(num2) && !list.Contains(num2 + 1) && !list.Contains(num2 + 2) && !list.Contains(num2 + 3) && !list.Contains(num2 + 4)) { list.Add(num2); } else { list = new List <EffectNumber>(); if (item.ItemNumber.Category == ItemCategory.Weapon) { if (item.Effects[0].Equals(1299600007)) { list.Add(1299600007); list.Add(1299602002); list.Add(1208300005); list.Add(1208301005); } else if (item.Effects[0].Equals(1203300005)) { list.Add(1203300005); list.Add(1203301005); list.Add(1299600007); } else if (item.Effects[0].Equals(1299600006)) { list.Add(1299600006); } else { list.Add(1299600001); } } } item.EnchantLvl++; item.Effects = list.ToArray(); item.EnchantMP = 0; player.PEN -= num; session.SendAsync(new EnchantItemAckMessage { Result = result, ItemId = (ulong)message.ItemId, Effect = num2 }); session.SendAsync(new ItemUpdateInventoryAckMessage(InventoryAction.Update, item.Map <PlayerItem, ItemDto>())); session.SendAsync(new MoneyRefreshCashInfoAckMessage(player.PEN, player.AP)); Logger.ForAccount(session).Information(string.Format("Enchanted {0} With {1} PEN", item.ItemNumber, num)); } catch (Exception ex) { session.SendAsync(new EnchantItemAckMessage(EnchantResult.ErrorItemEnchant)); //Logger.Information(ex.StackTrace); } } return; }
public void MPRefill(GameSession session, ItemMPRefillReqMessage message) { // Todo Some improvements Player player = session.Player; PlayerItem playerItem = player.Inventory[message.ItemId2]; PlayerItem playerItem2 = player.Inventory[message.ItemId]; uint[] array = new uint[25] { 168, 168, 336, 336, 504, 504, 672, 672, 840, 840, 1176, 1176, 1512, 1680, 2016, 2688, 3360, 4032, 4872, 6048, 6048, 6048, 6048, 6048, 6048 }; if (playerItem.EnchantMP >= array[playerItem.EnchantLvl]) { session.SendAsync(new ItemMPRefillAckMessage { Result = 1 }); return; } if (playerItem == null || playerItem2 == null || player == null || playerItem.PeriodType == ItemPeriodType.Units || (int)playerItem.ItemNumber.Category > 2) { session.SendAsync(new ItemMPRefillAckMessage { Result = 1 }); return; } playerItem2.Count--; if (playerItem2.Count == 0) { player.Inventory.Remove(playerItem2.Id); } else { session.SendAsync(new ItemUpdateInventoryAckMessage(InventoryAction.Update, playerItem2.Map <PlayerItem, ItemDto>())); } playerItem.EnchantMP += 6048; if (playerItem.EnchantMP > array[playerItem.EnchantLvl]) { playerItem.EnchantMP = array[playerItem.EnchantLvl]; } session.SendAsync(new ItemMPRefillAckMessage { Result = 0 }); session.SendAsync(new ItemUpdateInventoryAckMessage(InventoryAction.Update, playerItem.Map <PlayerItem, ItemDto>())); return; }