protected override Item CreateItem(string itemTypeString, string itemNameString, Location itemLocation, Item item)
        {
            switch (itemTypeString)
            {
                case "weapon":
                    {
                        item = new Weapon(itemNameString, itemLocation);
                        return item;
                    }
                case "wood":
                    {
                        item = new Wood(itemNameString, itemLocation);
                        return item;
                    }
                case "iron":
                    {
                        item = new Iron(itemNameString, itemLocation);
                        return item;
                    }

                default:
                    {
                        return base.CreateItem(itemTypeString, itemNameString, itemLocation, item);
                    }
            }
        }
 protected override Item CreateItem(string itemTypeString, string itemNameString, Location itemLocation, Item item)
 {
     switch (itemTypeString)
     {
         case "weapon":
             item = new Weapon(itemNameString, itemLocation);
             break;
         case "iron":
             item = new Iron(itemNameString, itemLocation);
             break;
         default:
             return base.CreateItem(itemTypeString, itemNameString, itemLocation,item);
             break;
     }
     return item;
 }
 protected virtual Item CreateItem(string itemTypeString, string itemNameString, Location itemLocation, Item item)
 {
     switch (itemTypeString)
     {
         case "armor":
             item = new Armor(itemNameString, itemLocation);
             break;
         case "weapon":
             item = new Weapon(itemNameString, itemLocation);
             break;
         case "wood":
             item = new Wood(itemNameString, itemLocation);
             break;
         case "iron":
             item = new Iron(itemNameString, itemLocation);
             break;
         default:
             break;
     }
     return item;
 }
        protected override Item CreateItem(string itemTypeString, string itemNameString, Location itemLocation, Item item)
        {
            if (itemTypeString == "armor")
            {
                base.CreateItem(itemTypeString, itemNameString, itemLocation, item);
            }

            switch (itemTypeString)
            {
                case "weapon":
                    item = new Weapon(itemNameString, itemLocation);
                    break;
                case "wood":
                    item = new Wood(itemNameString, itemLocation);
                    break;
                case "iron":
                    item = new Iron(itemNameString, itemLocation);
                    break;
                default:
                    break;
            }

            return item;
        }
 private void HandleGatherInteraction(Person actor, string itemName)
 {
     if (actor.Location.LocationType == LocationType.Forest && actor.ListInventory().Any(x => x.ItemType == ItemType.Weapon))
     {
         var wood = new Wood(itemName);
         AddToPerson(actor, wood);
     }
     else if (actor.Location.LocationType == LocationType.Mine && actor.ListInventory().Any(x => x.ItemType == ItemType.Armor))
     {
         var iron = new Iron(itemName);
         AddToPerson(actor, iron);
     }
 }
        private void HandleGatherInteraction(Person actor, string itemName)
        {
            var actorItems = actor.ListInventory();

            for (int i = 0; i < actorItems.Count; i++)
            {
                if (actorItems[i] is Weapon && actor.Location is Forest)
                {
                    var item = new Wood(itemName);
                    actor.AddToInventory(item);
                    this.ownerByItem.Add(item, actor);
                    return;
                }
                else if (actorItems[i] is Armor && actor.Location is Mine)
                {
                    var item = new Iron(itemName);
                    actor.AddToInventory(item);
                    this.ownerByItem.Add(item, actor);
                    return;
                }
            }
        }
        private void HandleGatherInteraction(string[] commandWords, Person actor)
        {
            var itemsInInventory = actor.ListInventory();
            bool[] hasItemTypes = this.CheckActorInventoryForItem(itemsInInventory);

            if (actor.Location is Forest)
            {
                if (hasItemTypes[2])
                {
                    var gatheredWood = new Wood(commandWords[2], actor.Location);
                    this.AddToPerson(actor, gatheredWood);
                }
            }

            else if (actor.Location is Mine)
            {
                if (hasItemTypes[3])
                {
                    var gatheredIron = new Iron(commandWords[2], actor.Location);
                    this.AddToPerson(actor, gatheredIron);
                }
            }

        }
        private void HandleGatherInteraction(string[] commandWords, Person actor)
        {
            if (actor.Location.LocationType == LocationType.Forest)
            {
                var inventoryItems = actor.ListInventory().Where(x => x.ItemType == ItemType.Weapon);
                if (inventoryItems != null && inventoryItems.Count() > 0)
                {
                    var item = new Wood(commandWords[2], null);
                    actor.AddToInventory(item);
                    ownerByItem.Add(item, actor);
                    item.UpdateWithInteraction("gather");
                }
            }
            else if (actor.Location.LocationType == LocationType.Mine)
            {
                var inventoryItems = actor.ListInventory().Where(x => x.ItemType == ItemType.Armor);
                if (inventoryItems != null && inventoryItems.Count() > 0)
                {
                    var item = new Iron(commandWords[2], null);
                    actor.AddToInventory(item);
                    ownerByItem.Add(item, actor);
                }
            }

        }
Esempio n. 9
0
 private void HandleGatherInteraction(string[] commandWords, Person actor)
 {
     List<Item> itemsInInventory = actor.ListInventory();
     foreach (var items in itemsInInventory)
     {
         if (items.ItemType == ItemType.Weapon)
         {
             hasWeapon = true;
         }
         else if (items.ItemType == ItemType.Armor)
         {
             hasArmor = true;
         }
     }
     if (actor.Location.LocationType == LocationType.Forest && hasWeapon == true)
     {
         Wood newWood = new Wood(commandWords[2], null);
         this.AddToPerson(actor, newWood);
     }
     else if (actor.Location.LocationType == LocationType.Mine && hasArmor == true)
     {
         Iron newIron = new Iron(commandWords[2], null);
         this.AddToPerson(actor, newIron);
     }
 }
 private void HandleGatherCommand(string[] commandWords, Person actor)
 {
     if (actor.Location.LocationType == LocationType.Forest)
     {
         foreach (var item in actor.ListInventory())
         {
             if ((item as Weapon)!= null )
             {
                 Wood wood = new Wood(commandWords[2]);
                 this.AddToPerson(actor, wood);
                 break;
             }
         }
     }
     else if (actor.Location.LocationType == LocationType.Mine)
     {
         foreach (var item in actor.ListInventory())
         {
             if ((item as Armor) != null)
             {
                 Iron iron = new Iron(commandWords[2]);
                 this.AddToPerson(actor, iron);
                 break;
             }
         }
     }
 }
        private void HandleGatherInteraction(string[] commandWords, Person actor)
        {
            string newItemName = commandWords[2];
            var actorInventory = actor.ListInventory();
            Item newItem = null;

            if (actor.Location.LocationType == LocationType.Forest)
            {
                bool hasWeapon = PossessTheRequiredItem(actorInventory, ItemType.Weapon);

                if (hasWeapon)
                {
                    newItem = new Wood(newItemName);
                    this.AddToPerson(actor, newItem);
                    newItem.UpdateWithInteraction("gather");
                }
            }
            else if (actor.Location.LocationType == LocationType.Mine)
            {
                bool hasArmor = PossessTheRequiredItem(actorInventory, ItemType.Armor);

                if (hasArmor)
                {
                    newItem = new Iron(newItemName);
                    this.AddToPerson(actor, newItem);
                    newItem.UpdateWithInteraction("gather");
                }
            }
        }
        private void HandleGatherInteraction(Person actor, string[] commandWords)
        {
            if (actor.Location.LocationType == LocationType.Forest)
            {
                bool hasWeapon = false;
                var inventory = actor.ListInventory();

                foreach (var item in inventory)
                {
                    if (item is Weapon)
                    {
                        hasWeapon = true;
                        break;
                    }
                }

                if (hasWeapon)
                {
                    Wood wood = new Wood(commandWords[2], "wood", actor.Location);
                    this.AddToPerson(actor, wood);
                }
            }
            else if (actor.Location.LocationType == LocationType.Mine)
            {
                bool hasArmor = false;
                var inventory = actor.ListInventory();

                foreach (var item in inventory)
                {
                    if (item is Armor)
                    {
                        hasArmor = true;
                        break;
                    }
                }

                if (hasArmor)
                {
                    Iron iron = new Iron(commandWords[2], "iron", actor.Location);
                    this.AddToPerson(actor, iron);
                }
            }
        }
        private void HandleGatherInteraction(string newItemName, Person actor)
        {
            if (actor.Location.LocationType == LocationType.Forest)
            {
                Item weaponItem = actor.ListInventory().FirstOrDefault(i => i.ItemType == ItemType.Weapon);

                if (weaponItem != null)
                {
                    Item gatheredItem = new Wood(newItemName);
                    this.AddToPerson(actor, gatheredItem);
                }
            }
            else if (actor.Location.LocationType == LocationType.Mine)
            {
                Item armorItem = actor.ListInventory().FirstOrDefault(i => i.ItemType == ItemType.Armor);

                if (armorItem != null)
                {
                    Item gatheredItem = new Iron(newItemName);
                    this.AddToPerson(actor, gatheredItem);
                }
            }
        }
        private void HandleGatherInteraction(Person actor, string itemName)
        {
            //Gathering means a Person takes an item from a special location
            //A Person should be able to gather from mines and from forests
            //A Person can gather from a forest only if he has a Weapon in his inventory
            //Gathering from a forests results in adding a Wood item in the Person’s inventory
            //A Person can gather from a mine only if he has an Armor in his inventory
            //Gathering from a mine results in adding an Iron item in the Person’s inventory
            //Syntax: Joro gather newItemName – gathers an item, naming it newItemName if the Person Joro is at a mine or forest, and respectively has an Armor or Weapon

            if (actor.Location.LocationType == LocationType.Forest && actor.ListInventory().Any(a => a.GetType() == typeof(Weapon)))
            {
                Wood a = new Wood(itemName);
                base.AddToPerson(actor, a);
                actor.AddToInventory(new Wood(itemName));
            }

            if (actor.Location.LocationType == LocationType.Mine && actor.ListInventory().Any(a => a.GetType() == typeof(Armor)))
            {
                Iron a = new Iron(itemName);
                base.AddToPerson(actor, a);
                actor.AddToInventory(new Iron(itemName));
            }
        }
Esempio n. 15
0
        private void HandleGatherInteraction(Person actor, string name)
        {
            var locationForest = actor.Location as Forest;
            if (locationForest is Forest)
            {
                if (actor.ListInventory().Exists(x => x is Weapon))
                {
                    var item = new Wood(name, actor.Location);
                    actor.AddToInventory(item);
                    this.AddToPerson(actor, item);
                }
            }

            var locationMine = actor.Location as Mine;
            if (locationMine is Mine)
            {
                if (actor.ListInventory().Exists(x => x is Armor))
                {
                    var item = new Iron(name, actor.Location);
                    actor.AddToInventory(item);
                    this.AddToPerson(actor, item);
                }
            }
        }
Esempio n. 16
0
        private void HandleGatherInteraction(string[] commandWords, Person actor)
        {
            Item gatherItem = null;
            string itemName = commandWords[2];
            switch (actor.Location.LocationType)
            {
                case LocationType.Mine:
                    foreach (var item in actor.ListInventory())
                    {
                        if (item.ItemType == ItemType.Armor)
                        {
                            gatherItem = new Iron(itemName);
                            this.AddToPerson(actor, gatherItem);
                            return;
                        }
                    }

                    break;
                case LocationType.Forest:
                    foreach (var item in actor.ListInventory())
                    {
                        if (item.ItemType == ItemType.Weapon)
                        {
                            gatherItem = new Wood(itemName);
                            this.AddToPerson(actor, gatherItem);
                            return;
                        }
                    }

                    break;
                default:
                    break;
            }
        }
        private void HandleGatherInteraction(string[] commandWords, Person actor)
        {
            string gatherItemName = commandWords[2];

            if (actor.Location.LocationType == LocationType.Forest)
            {
                bool hasWeapon = false;

                foreach (var item in actor.ListInventory())
                {
                    if (item.ItemType == ItemType.Weapon)
                    {
                        hasWeapon = true;
                        break;
                    }
                }

                if (hasWeapon)
                {
                    var addedItem = new Wood(gatherItemName);
                    this.AddToPerson(actor, addedItem);
                    addedItem.UpdateWithInteraction("gather");
                }
            }
            else if (actor.Location.LocationType == LocationType.Mine)
            {
                bool hasArmor = false;

                foreach (var item in actor.ListInventory())
                {
                    if (item.ItemType == ItemType.Armor)
                    {
                        hasArmor = true;
                        break;
                    }
                }

                if (hasArmor)
                {
                    var addedItem = new Iron(gatherItemName);
                    this.AddToPerson(actor, addedItem);
                    addedItem.UpdateWithInteraction("gather");
                }
            }
        }