using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FiestaBot.Instances.Networking;
using FiestaBot.Manager.ClientPacket;
using FiestaBot.Manager.Networking;
using FiestaBot.Utilities;
using FiestaBot.Zone.ClientPacket;
using FiestaBot.Zone.Networking;

namespace FiestaBot.Zone.Game
{
    internal class Chat
    {
        public static void Party(ManagerClient Socket, string Message, params object[] args)
        {
            Message = string.Format(Message, args);

            Packet p = new Packet(8, 20);
            p.WriteString(Message, true);

            Socket.SendPacket(p);
        }
        public static void Whisper(ManagerClient Socket, string Receiver, string Message, params object[] args)
        {
            Message = string.Format(Message, args);
        }

        public static void Normal(ZoneClient Socket, string Message, params object[] args)
        {
            Message = string.Format(Message, args);

            Packet p = new Packet(8, 1);
            p.WriteString(Message, true);
            Socket.SendPacket(p);
        }

        public static void HandleCommand(ZoneClient Socket, ushort ObjectID, string Command)
        {
            if (Command.ToLower().Contains("party"))
            {
                if(!Socket.Manager.InParty)
                {
                    string ToInvite = Socket.ObjectList.Find(x => x.ObjectID == ObjectID).Name;

                    ManagerPacket.SendPartyInvite(Socket.Manager, ToInvite);
                    Chat.Normal(Socket, "I've invited you, {0}", ToInvite);
                }
                else { Chat.Normal(Socket, "Sorry, I already am in a party!"); }
            }
            else if(Command.ToLower().Contains("follow me"))
            {
                Socket.FollowMode = true;
                Socket.FollowUser = ObjectID;
                Chat.Normal(Socket, "I will now follow you.");
            }
            else if(Command.ToLower().Contains("break zone"))
            {
                Chat.Normal(Socket, "Zone & login will be broken in approx 5 seconds.");
                ZonePacket.SendZoneBreak(Socket);
			}
        }
    }
}
