示例#1
0
        /// <summary>
        /// Implementation of the IInventoryManager interface
        /// </summary>
        /// <param name="inventory">Input inventory list</param>
        /// <returns>Processed inventory list</returns>
        public IList <Item> ProcessInventory(IList <Item> inventory)
        {
            var processedInventory = new List <Item>();

            foreach (var item in inventory)
            {
                MerchandiseType type = MerchandiseType.Normal;

                // Lookup in map to see if item has a specified category.
                if (!MerchandiseTypeMap.TryGetValue(item.Name, out type))
                {
                    // Unless specified in the map, apply the following assumptions
                    if (item.Name.StartsWith("Conjured"))
                    {
                        type = MerchandiseType.Conjured;
                    }
                    else if (item.Name.StartsWith("Backstage passes"))
                    {
                        type = MerchandiseType.EventPass;
                    }
                    else
                    {
                        type = MerchandiseType.Normal;
                    }
                }
                Merchandise merchandise = null;
                switch (type)
                {
                case MerchandiseType.AgedWell:
                    merchandise = new AgedWellItem(item);
                    break;

                case MerchandiseType.Conjured:
                    merchandise = new ConjuredItem(item);
                    break;

                case MerchandiseType.EventPass:
                    merchandise = new EventPassItem(item);
                    break;

                case MerchandiseType.Legendary:
                    merchandise = new LegendaryItem(item);
                    break;

                default:
                case MerchandiseType.Normal:
                    merchandise = new NormalItem(item);
                    break;
                }
                merchandise.UpdateQuality();
                processedInventory.Add(merchandise);
            }
            return(processedInventory);
        }
        public int TestLegendaryItem(int sellInDays, int daysElapsed)
        {
            LegendaryItem item = new LegendaryItem("Sulfuras", sellInDays);

            for (int i = 0; i < daysElapsed; i++)
            {
                item.UpdateAfterDayElapsed();
            }

            return item.Quality;
        }
 public int LegendaryItemSellInIsConstant(int sellIn)
 {
     LegendaryItem item = new LegendaryItem("Dirt", sellIn, 20);
     item.UpdateSellIn();
     return item.SellIn;
 }
 public int LegendaryItemQualityIsConstant(int sellIn)
 {
     LegendaryItem item = new LegendaryItem("Dirt", sellIn, 20);
     item.UpdateQuality();
     return item.Quality;
 }