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

namespace PSO2SERVER.Protocol.Packets
{
    public class CharacterRenamePacket : Packet
    {
        public enum RenameRequestStatus : uint
        {
            /// <summary>
            /// Renaming allowed.
            /// </summary>
            Allowed = 0,

            /// <summary>
            /// Renaming permit needed.
            /// </summary>
            PermitNeeded = 1,

            /// <summary>
            /// Renaming privileges suspended.
            /// </summary>
            PrivilegesSuspended = 2,

            /// <summary>
            /// System error has occurred.
            /// </summary>
            SystemError = 3,

            /// <summary>
            /// Renaming cooldown hasn't yet expired.
            /// </summary>
            TooEarly = 4
        }

        /// <summary>
        /// Renaming availability status.
        /// </summary>
        public RenameRequestStatus Status { get; set; }

        /// <summary>
        /// AC price for a rename pass.
        /// </summary>
        public uint AcPrice { get; set; }

        /// <summary>
        /// Rename cooldown expiry timestamp.
        /// </summary>
        public uint CooldownExpires { get; set; }

        /// <summary>
        /// Seconds until the rename cooldown expires.
        /// </summary>
        public uint CooldownSecs { get; set; }

        public CharacterRenamePacket()
        {
            Status = RenameRequestStatus.Allowed;
            AcPrice = 0;
            CooldownExpires = 0;
            CooldownSecs = 0;
        }

        #region implemented abstract members of Packet

        public override byte[] Build()
        {
            var pkt = new PacketWriter();
            pkt.Write((uint)Status);
            pkt.Write(AcPrice);
            pkt.Write(CooldownExpires);
            pkt.Write(CooldownSecs);
            return pkt.ToArray();
        }

        public override PacketHeader GetHeader()
        {
            return new PacketHeader(0x11, 0x98, PacketFlags.None);
        }

        #endregion
    }
}