using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

using Plus.HabboHotel.GameClients;
using Plus.Communication.Packets.Outgoing.Inventory.Purse;
using Plus.Communication.Packets.Outgoing.Rooms.Notifications;
using Plus.Database.Interfaces;

namespace Plus.HabboHotel.Rooms.Chat.Commands.Moderator
{
    class GiveCommand : IChatCommand
    {
        public string PermissionRequired
        {
            get { return "command_give"; }
        }

        public string Parameters
        {
            get { return "%username% %type% %montant%"; }
        }

        public string Description
        {
            get { return ""; }
        }

        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Veuillez saisir un type de devise! (coins, duckets, diamants, gotw).");
                return;
            }

            GameClient Target = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);
            if (Target == null)
            {
                Session.SendWhisper("Oups, nous n'avons pas pu trouver cet utilisateur!");
                return;
            }

            string UpdateVal = Params[2];
            switch (UpdateVal.ToLower())
            {
                case "coins":
                case "credits":
                    {
                            int Amount;
                            if (int.TryParse(Params[3], out Amount))
                            {
                                Target.GetHabbo().Credits = Target.GetHabbo().Credits += Amount;
                                Target.SendMessage(new CreditBalanceComposer(Target.GetHabbo().Credits));

                                if (Target.GetHabbo().Id != Session.GetHabbo().Id)
                                Target.SendMessage(new BubbleNotificationComposer(Session.GetHabbo().Username + " vous à donner " + Amount.ToString() + " Crédit(s)!", "notif"));
                                Session.SendWhisper("Envoyer avec succès " + Amount + " Crédit(s) à " + Target.GetHabbo().Username + "!");
                                break;
                            }
                            else
                            {
                                Session.SendWhisper("Montant invalide");
                                break;
                            }
                        
                    }

                case "pixels":
                case "duckets":
                    {
                            int Amount;
                            if (int.TryParse(Params[3], out Amount))
                            {
                                Target.GetHabbo().Duckets += Amount;
                                Target.SendMessage(new HabboActivityPointNotificationComposer(Target.GetHabbo().Duckets, Amount));

                                if (Target.GetHabbo().Id != Session.GetHabbo().Id)
                                Target.SendMessage(new BubbleNotificationComposer(Session.GetHabbo().Username + " vous à donner " + Amount.ToString() + " Ducket(s)!", "notif"));
                                Session.SendWhisper("Envoyer avec succès " + Amount + " Ducket(s) à " + Target.GetHabbo().Username + "!");
                                break;
                            }
                            else
                            {
                                Session.SendWhisper("Montant invalide");
                                break;
                            }
                        }
                    

                case "diamonds":
                case "diamants":
                    {
                            int Amount;
                            if (int.TryParse(Params[3], out Amount))
                            {
                                Target.GetHabbo().Diamonds += Amount;
                                Target.SendMessage(new HabboActivityPointNotificationComposer(Target.GetHabbo().Diamonds, Amount, 5));

                                if (Target.GetHabbo().Id != Session.GetHabbo().Id)
                                Target.SendMessage(new BubbleNotificationComposer(Session.GetHabbo().Username + " vous à donner " + Amount.ToString() + " Diamants(s)!", "notif"));
                                Session.SendWhisper("Envoyer avec succès" + Amount + " Diamant(s) à " + Target.GetHabbo().Username + "!");
                                break;
                            }
                            else
                            {
                                Session.SendWhisper("Montant Invalide");
                                break;
                            }
                        
                    }

                case "gotw":
                case "gotwpoints":
                    {
                        int Amount;
                        if (int.TryParse(Params[3], out Amount))
                        {
                            Target.GetHabbo().GOTWPoints = Target.GetHabbo().GOTWPoints + Amount;
                            Target.SendMessage(new HabboActivityPointNotificationComposer(Target.GetHabbo().GOTWPoints, Amount, 103));

                            if (Target.GetHabbo().Id != Session.GetHabbo().Id)
                                Target.SendMessage(new BubbleNotificationComposer(Session.GetHabbo().Username + " vous à donner " + Amount.ToString() + " GOTW Point(s)!", "notif"));
                            Session.SendWhisper("Envoyer avec succès " + Amount + " GOTW point(s) à " + Target.GetHabbo().Username + "!");
                            break;
                        }
                        else
                        {
                            Session.SendWhisper("Montant invalide!");
                            break;
                        }

                    }
                default:
                    Session.SendWhisper("'" + UpdateVal + "' n'est pas une monnaie!");
                    break;
            }
        }
    }
}