Example #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);
        }
Example #2
0
        public void Handle(MerchandiseTypeAddCommand command)
        {
            using (var uow = new UnitOfWork <EF>())
            {
                try
                {
                    //add
                    var merchandiseTypeEntity = new MerchandiseType()
                    {
                        MerchandiseId    = Guid.NewGuid().ToString(),
                        Type             = command.MerchandiseType.Type,
                        Name             = command.MerchandiseType.Name,
                        CalculationUnit  = command.MerchandiseType.CalculationUnit,
                        Description      = command.MerchandiseType.Description,
                        CreatedDate      = System.DateTime.Now,
                        LastModifiedDate = System.DateTime.Now
                    };
                    uow.Repository <MerchandiseType>().Add(merchandiseTypeEntity);
                    uow.SubmitChanges();

                    //Insert new Activity
                    var activity = new Activity();
                    activity.Source        = "Loại Hàng";
                    activity.Source_Id     = merchandiseTypeEntity.MerchandiseId;
                    activity.Action        = "Tạo";
                    activity.Current_value = merchandiseTypeEntity.Name;
                    activity.CreatedDate   = System.DateTime.Now;
                    activity.CreatedBy     = command.MerchandiseType.UserId;
                    iActivityServices.AddActivity(new ActivityAddCommand {
                        Activity = activity
                    });
                }
                catch (DbEntityValidationException dbEx)
                {
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            Trace.TraceInformation("Property: {0} Error: {1}",
                                                   validationError.PropertyName,
                                                   validationError.ErrorMessage);
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Example #3
0
    public bool HaveItem(MerchandiseType type, string Name)
    {
        List <string> targetList;

        if (type == MerchandiseType.Animal)
        {
            targetList = animalList;
        }
        else if (type == MerchandiseType.Cup)
        {
            targetList = cupList;
        }
        else
        {
            targetList = liquidList;
        }
        return(targetList.Exists(x => x == Name));
    }
Example #4
0
 public void Init(MerchandiseInfo info, MerchandiseType type)
 {
     if (info == null || !info.Item)
     {
         return;
     }
     merchandiseInfo = info;
     merchandiseType = type;
     if (type == MerchandiseType.SellToPlayer)
     {
         itemAgentSon.Init(ItemAgentType.Selling);
     }
     else
     {
         itemAgentSon.Init(ItemAgentType.Purchasing);
     }
     itemAgentSon.SetItem(new ItemInfo(info.Item));
     UpdateInfo();
 }
        public void SetType(MerchandiseType merchType)
        {
            string typeLabel = string.Empty;

            switch (merchType)
            {
                case MerchandiseType.Fixed:
                    typeLabel = "Fixed price";
                    break;
                case MerchandiseType.Variable:
                    typeLabel = "Variable amount";
                    break;
                case MerchandiseType.Header:
                    typeLabel = "Section header";
                    break;
            }

            UIUtil.DefaultProvider.SelectWithText("ctl00_cphDialog_feeAmountTypeId", typeLabel, LocateBy.Id);
        }
        public void SetMerchItemPrice(MerchandiseType type, double? fee, double? minFee, double? maxFee)
        {
            switch (type)
            {
                case MerchandiseType.Fixed:
                    this.SetFixedPrice(fee);
                    break;

                case MerchandiseType.Variable:
                    this.SetVariableMinMax(minFee, maxFee);
                    break;

                default:
                    break;
            }
        }
Example #7
0
 void AddProduct(Merchandise product, MerchandiseType type, int index)
 {
     if (type == MerchandiseType.Animal)
     {
         RectTransform rect = Instantiate(AnimalProductPrefab, animalShop).GetComponent <RectTransform>();
         float         x    = index * itemWidth;
         rect.anchoredPosition = new Vector2(x, rect.anchoredPosition.y);
         ProductInShop prod = rect.GetComponent <ProductInShop>();
         prod.icon.sprite   = product.SelectViewSprite;
         prod.nameText.text = product.chineseName;
         prod.costText.text = "x" + product.cost;
         prod.SetCostType(product.costType);
         if (EntireGameManager.getInstance().getPlayerData().HaveItem(type, product.indexName))
         {
             prod.HaveProduct(true);
         }
         else
         {
             prod.HaveProduct(false);
         }
         prod.Cover.gameObject.GetComponent <Button>().onClick.AddListener(() => OnBuyClicked(product, prod));
     }
     else if (type == MerchandiseType.Cup)
     {
         RectTransform rect = Instantiate(CupProductPrefab, cupShop).GetComponent <RectTransform>();
         float         x    = index * itemWidth;
         rect.anchoredPosition = new Vector2(x, rect.anchoredPosition.y);
         ProductInShop prod = rect.GetComponent <ProductInShop>();
         prod.icon.sprite   = product.SelectViewSprite;
         prod.nameText.text = product.chineseName;
         prod.costText.text = "x" + product.cost;
         prod.SetCostType(product.costType);
         if (EntireGameManager.getInstance().getPlayerData().HaveItem(type, product.indexName))
         {
             prod.HaveProduct(true);
         }
         else
         {
             prod.HaveProduct(false);
         }
         prod.Cover.gameObject.GetComponent <Button>().onClick.AddListener(() => OnBuyClicked(product, prod));
     }
     else if (type == MerchandiseType.Liquid)
     {
         RectTransform rect = Instantiate(LiquidProductPrefab, liquidShop).GetComponent <RectTransform>();
         float         x    = index * itemWidth;
         rect.anchoredPosition = new Vector2(x, rect.anchoredPosition.y);
         ProductInShop prod = rect.GetComponent <ProductInShop>();
         prod.nameText.text = product.chineseName;
         prod.costText.text = "x" + product.cost;
         prod.SetCostType(product.costType);
         if (EntireGameManager.getInstance().getPlayerData().HaveItem(type, product.indexName))
         {
             prod.HaveProduct(true);
         }
         else
         {
             prod.HaveProduct(false);
         }
         prod.Cover.gameObject.GetComponent <Button>().onClick.AddListener(() => OnBuyClicked(product, prod));
     }
 }