Ejemplo n.º 1
0
        private void HandleGaterInteraction(string[] commandWords, Person actor)
        {
            var inventory = actor.ListInventory();

            if (actor.Location.LocationType == LocationType.Forest)
            {
                foreach (var item in inventory)
                {
                    if (ownerByItem[item] == actor && item.ItemType == ItemType.Weapon)
                    {
                        var woodenItem = new Wood(commandWords[2]);
                        this.AddToPerson(actor, woodenItem);

                        woodenItem.UpdateWithInteraction("gather");
                    }
                }
            }

            if (actor.Location.LocationType == LocationType.Mine)
            {
                foreach (var item in inventory)
                {
                    if (ownerByItem[item] == actor && item.ItemType == ItemType.Armor)
                    {
                        var ironItem = new Iron(commandWords[2]);
                        this.AddToPerson(actor, ironItem);

                        ironItem.UpdateWithInteraction("gather");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void HandleGatherInteraction(string[] commandWords, Person actor)
        {
            string gatherItemName = commandWords[2];
            Item   newItem        = null;

            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)
                {
                    newItem = new Wood(gatherItemName);
                    this.AddToPerson(actor, newItem);
                    newItem.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)
                {
                    newItem = new Iron(gatherItemName);
                    this.AddToPerson(actor, newItem);
                    newItem.UpdateWithInteraction("gather");
                }
            }
        }
        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);
                }
            }

        }
        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(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");
                }
            }
        }