Exemplo n.º 1
0
        bool CheckConsumeAction(ItemObject item)
        {
            if (item == null)
            {
                SendFailReport(new ConsumeActionReport(this, null), "not in inventory");
                return false;
            }

            if (item.RefreshmentValue == 0 && item.NutritionalValue == 0)
            {
                SendFailReport(new ConsumeActionReport(this, item), "non-digestible");
                return false;
            }

            return true;
        }
Exemplo n.º 2
0
        bool CheckGetItemAction(ItemObject item)
        {
            if (item == null)
            {
                SendFailReport(new GetItemActionReport(this, item), "item not found");
                return false;
            }

            if (item.Environment != this.Environment || item.Location != this.Location)
            {
                SendFailReport(new GetItemActionReport(this, item), "item not there");
                return false;
            }

            return true;
        }
Exemplo n.º 3
0
        bool CheckDropItemAction(ItemObject item)
        {
            if (item == null)
            {
                SendFailReport(new DropItemActionReport(this, item), "item not found");
                return(false);
            }

            if (item.Container != this)
            {
                SendFailReport(new DropItemActionReport(this, item), "not in inventory");
                return(false);
            }

            if (item.IsEquipped)
            {
                SendFailReport(new DropItemActionReport(this, item), "item equipped");
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        bool CheckDropItemAction(ItemObject item)
        {
            if (item == null)
            {
                SendFailReport(new DropItemActionReport(this, item), "item not found");
                return false;
            }

            if (item.Parent != this)
            {
                SendFailReport(new DropItemActionReport(this, item), "not in inventory");
                return false;
            }

            if (item.IsEquipped)
            {
                SendFailReport(new DropItemActionReport(this, item), "item equipped");
                return false;
            }

            return true;
        }
Exemplo n.º 5
0
        bool CheckEquipItem(ItemObject item)
        {
            if (item == null)
            {
                var report = new EquipItemActionReport(this, null);
                report.SetFail("object doesn't exist");
                SendReport(report);
                return(false);
            }

            if (item.Container != this)
            {
                var report = new EquipItemActionReport(this, item);
                report.SetFail("doesn't have the object");
                SendReport(report);
                return(false);
            }

            if (!item.IsArmor && !item.IsWeapon)
            {
                var report = new EquipItemActionReport(this, item);
                report.SetFail("not equippable");
                SendReport(report);
                return(false);
            }

            if (item.IsEquipped)
            {
                var report = new EquipItemActionReport(this, item);
                report.SetFail("already equipped");
                SendReport(report);
                return(false);
            }

            return(true);
        }
Exemplo n.º 6
0
        bool CheckUnequipItem(ItemObject item)
        {
            if (item == null)
            {
                var report = new UnequipItemActionReport(this, null);
                report.SetFail("object doesn't exist");
                SendReport(report);
                return false;
            }

            if (item.Container != this)
            {
                var report = new UnequipItemActionReport(this, item);
                report.SetFail("doesn't have the object");
                SendReport(report);
                return false;
            }

            if (!item.IsArmor && !item.IsWeapon)
            {
                var report = new UnequipItemActionReport(this, item);
                report.SetFail("not equippable");
                SendReport(report);
                return false;
            }

            if (item.IsEquipped == false)
            {
                var report = new UnequipItemActionReport(this, item);
                report.SetFail("not equipped");
                SendReport(report);
                return false;
            }

            return true;
        }
Exemplo n.º 7
0
        bool CheckEquipItem(ItemObject item)
        {
            if (item == null)
            {
                var report = new EquipItemActionReport(this, null);
                report.SetFail("object doesn't exist");
                SendReport(report);
                return false;
            }

            if (item.Parent != this)
            {
                var report = new EquipItemActionReport(this, item);
                report.SetFail("doesn't have the object");
                SendReport(report);
                return false;
            }

            if (!item.IsArmor || !item.IsWeapon)
            {
                var report = new EquipItemActionReport(this, item);
                report.SetFail("not equippable");
                SendReport(report);
                return false;
            }

            if (item.IsEquipped)
            {
                var report = new EquipItemActionReport(this, item);
                report.SetFail("already equipped");
                SendReport(report);
                return false;
            }

            return true;
        }
Exemplo n.º 8
0
 internal static ItemObject Create(World world, ItemObjectBuilder builder)
 {
     var ob = new ItemObject(builder);
     ob.Initialize(world);
     return ob;
 }
Exemplo n.º 9
0
 internal void OnItemIsEquippedChanged(ItemObject item, bool isEquipped)
 {
     if (item.IsArmor)
         RecalcArmorClass();
 }
Exemplo n.º 10
0
        public void UnequipItem(ItemObject item)
        {
            Debug.Assert(item.Parent == this);
            Debug.Assert(item.IsEquipped);
            Debug.Assert((item.IsArmor && item.ArmorInfo != null) || (item.IsWeapon && item.WeaponInfo != null));

            item.IsEquipped = false;
        }
Exemplo n.º 11
0
        public void EquipItem(ItemObject item)
        {
            Debug.Assert(item.Parent == this);
            Debug.Assert(item.IsEquipped == false);
            Debug.Assert((item.IsArmor && item.ArmorInfo != null) || (item.IsWeapon && item.WeaponInfo != null));

            if (item.IsArmor)
            {
                if (this.Inventory.OfType<ItemObject>().Where(i => i.IsArmor && i.IsEquipped)
                    .Any(i => i.ArmorInfo.Slot == item.ArmorInfo.Slot))
                    throw new Exception();
            }
            else if (item.IsWeapon)
            {
                if (this.Weapon != null)
                    throw new Exception();
            }
            else
            {
                throw new Exception();
            }

            item.IsEquipped = true;
        }
Exemplo n.º 12
0
 public ItemObject Create(World world)
 {
     return(ItemObject.Create(world, this));
 }