using System;
using Plus.HabboHotel.GameClients;
using Plus.Communication.Packets.Outgoing.Inventory.Purse;
using Plus.Utilities;
using Plus.HabboHotel.Items;
using Plus.Communication.Packets.Outgoing.Inventory.Furni;
using Plus.Communication.Packets.Outgoing.Rooms.Notifications;
using Plus.Communication.Packets;
using Plus.Communication.Packets.Incoming;
using Plus;

namespace Plus.Communication.Packets.Incoming.Rooms.Nux
{
    class GetNuxPresentEvent : IPacketEvent
    {
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            int Data1 = Packet.PopInt(); 
            int Data2 = Packet.PopInt(); 
            int Data3 = Packet.PopInt(); 
            int Data4 = Packet.PopInt(); 
            var RewardName = "";

            switch (Data4)
            {
                case 0:
                    int RewardDiamonds = RandomNumber.GenerateRandom(5, 10);
                    Session.GetHabbo().Diamonds = Session.GetHabbo().Diamonds + RewardDiamonds;
                    Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, Convert.ToInt32(RewardDiamonds), 5));
                    break;
                case 1:
                    int RewardGotw = RandomNumber.GenerateRandom(25, 50);
                    Session.GetHabbo().GOTWPoints = Session.GetHabbo().GOTWPoints + RewardGotw;
                    Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, RewardGotw));
                    break;
                case 2:
                    int RewardItem = RandomNumber.GenerateRandom(1, 10);
                    var RewardItemId = 0;

                    switch (RewardItem)
                    {
                        case 1:
                            RewardItemId = 212;
                            RewardName = "Sofa VIP";
                            break;
                        case 2:
                            RewardItemId = 9510;
                            RewardName = "Elephant";
                            break;
                        case 3:
                            RewardItemId = 1587;
                            RewardName = "Lampe Calippo";
                            break;
                        case 4:
                            RewardItemId = 212;
                            RewardName = "Sofa VIP";
                            break;
                        case 5:
                            RewardItemId = 385; 
                            RewardName = "Toldo Amarillo";
                            break;
                        case 6:
                            RewardItemId = 212; 
                            RewardName = "Sofa VIP";
                            break;
                        case 7:
                            RewardItemId = 212; 
                            RewardName = "Sofa VIP";
                            break;
                        case 8:
                            RewardItemId = 9506; 
                            RewardName = "Parasol Azul";
                            break;
                        case 9:
                            RewardItemId = 212;
                            RewardName = "Sofa VIP";
                            break;
                        case 10:
                            RewardItemId = 212;
                            RewardName = "Sofa VIP";
                            break;
                    }
                    ItemData Item = null;
                    if (!PlusEnvironment.GetGame().GetItemManager().GetItem(RewardItemId, out Item))
                    { return; }

                    Item GiveItem = ItemFactory.CreateSingleItemNullable(Item, Session.GetHabbo(), "", "");
                    if (GiveItem != null)
                    {
                        Session.GetHabbo().GetInventoryComponent().TryAddItem(GiveItem);

                        Session.SendMessage(new FurniListNotificationComposer(GiveItem.Id, 1));
                        Session.SendMessage(new FurniListUpdateComposer());
                        Session.SendMessage(new BubbleNotificationComposer("Votre cadeau vous attend dans votre inventaire !", "voucher"));
                    }

                    Session.GetHabbo().GetInventoryComponent().UpdateItems(true);
                    break;
            }
            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_AnimationRanking", 1);
        }
    }
}