using System;
using Server;
using Server.Multis;

namespace Server.Custom.InnRooms
{
    public class InnRoomHouse : BaseHouse
    {
        public override Rectangle2D[] Area
        {
            get { return new Rectangle2D[] { new Rectangle2D(-5, -5, 10, 10) }; }
        }

        public override Point3D BaseBanLocation
        {
            get { return new Point3D(this.X, this.Y - 5, this.Z + 20); }
        }

        // --- THE STORAGE FIXES ---
        
        // 1. Negate the 20% Mondain's Legacy bonus so they get exactly 250 items!
        public override double BonusStorageScalar { get { return 1.0; } }

        // 2. Both base values are passed as 250
        public InnRoomHouse(Mobile owner) : base(0xA26, owner, 250, 250) 
        {
            RestrictDecay = true; 
            
            // Force the initial properties to 250
            MaxLockDowns = 250; 
            MaxSecures = 250;
        }

        public InnRoomHouse(Serial serial) : base(serial)
        {
        }

        // The absolute maximum number of floor items
        public override int GetAosMaxLockdowns()
        {
            return 250; 
        }

        // The absolute maximum number of total items (chests + floor items + inside chests)
        public override int GetAosMaxSecures()
        {
            return 250; 
        }
        
        // -------------------------

        public override bool IsInside(Point3D p, int height)
        {
            if (Deleted)
                return false;

            int rx = p.X - this.X;
            int ry = p.Y - this.Y;

            bool inArea = false;
            foreach (Rectangle2D rect in Area)
            {
                if (rect.Contains(new Point2D(rx, ry)))
                {
                    inArea = true;
                    break;
                }
            }

            if (!inArea)
                return false;

            if (p.Z >= this.Z && (p.Z + height) <= this.Z + 40)
                return true;

            return false;
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write((int)0); 
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();
        }
    }
}
