using Plus.HabboHotel.GameClients;
using Plus.HabboHotel.Items.Wired;
using Plus.HabboHotel.Rooms;
using System;
using System.Threading;


namespace Plus.HabboHotel.Items.Interactor
{
    public class InteractorGateVP : IFurniInteractor
    {
        public void OnPlace(GameClient Session, Item Item)
        {
        }

        public void OnRemove(GameClient Session, Item Item)
        {
        }

        public void OnTrigger(GameClient Session, Item Item, int Request, bool HasRights)
        {
            int Modes = Item.GetBaseItem().Modes - 1;
                if (Session.GetHabbo().VIPRank != 1)
                {
                    Session.SendWhisper("Tu n'es pas VIP ! :(");
                    return;
                }
                else
                {
                    if (!HasRights)
                    {
                        return;
                    }
                    else if (Modes <= 0)
                    {
                        Item.UpdateState(false, true);
                    }

                    int CurrentMode = 0;
                    int NewMode = 0;

                    if (!int.TryParse(Item.ExtraData, out CurrentMode))
                    {
                    }

                    if (CurrentMode <= 0)
                    {
                        NewMode = 1;
                    }
                    else if (CurrentMode >= Modes)
                    {
                        NewMode = 0;
                    }
                    else
                    {
                        NewMode = CurrentMode + 1;
                    }

                    if (NewMode == 0)
                    {
                        if (!Item.GetRoom().GetGameMap().itemCanBePlacedHere(Item.GetX, Item.GetY))
                        {
                            return;
                        }
                    }
                    Item.ExtraData = NewMode.ToString();
                    Item.UpdateState();

                    Item.GetRoom().GetGameMap().updateMapForItem(Item);
                    Item.GetRoom().GetWired().TriggerEvent(WiredBoxType.TriggerStateChanges, Session.GetHabbo(), Item);
                }
            }


        public void OnWiredTrigger(Item Item)
        {
            
        }
    }
    }
            
    