public void AddItem(IUIItem item, bool doesIncrement)
        {
            int idAtAdd = GetProspectiveSlotID(item);

            if (thisItemIcons.Count == idAtAdd)
            {
                AddIIAndMutate(item, idAtAdd);
            }
            else
            {
                IItemIcon iiAtID = thisItemIcons[idAtAdd];
                if (iiAtID.IsEmpty())
                {
                    iiAtID.Disemptify(item);
                    iiAtID.SetQuantityInstantly(0);
                    iiAtID.UpdateQuantity(item.GetQuantity(), doesIncrement);
                }
                else
                {
                    if (iiAtID.HasSameItem(item))
                    {
                        iiAtID.IncreaseBy(item.GetQuantity(), doesIncrement);
                    }
                    else
                    {
                        this.AddIIAndMutate(item, idAtAdd);
                    }
                }
            }
        }
    public List <IItemIcon> CreateStubItemIconsWithItemTempsMatchingAt(int[] quantities, int[] sameAt, IItemTemplate sourceItemTemp)
    {
        List <IItemIcon> result = new List <IItemIcon>();
        int index = -1;

        foreach (int i in quantities)
        {
            index++;
            IItemIcon ii      = Substitute.For <IItemIcon>();
            IUIItem   tarItem = Substitute.For <IUIItem>();
            if (i == -1)
            {
                ii.IsEmpty().Returns(true);
                ii.GetUIItem().Returns((IUIItem)null);
                ii.GetItemTemplate().Returns((IItemTemplate)null);
            }
            else
            {
                ii.IsEmpty().Returns(false);
                tarItem.GetQuantity().Returns(i);
                IItemTemplate tarItemTemp = Substitute.For <IItemTemplate>();
                tarItem.GetItemTemplate().Returns(tarItemTemp);
                bool contained = false;
                foreach (int j in sameAt)
                {
                    if (j == index)
                    {
                        contained = true;
                    }
                }
                if (contained)
                {
                    tarItemTemp.IsSameAs(sourceItemTemp).Returns(true);
                }
                else
                {
                    tarItemTemp.IsSameAs(sourceItemTemp).Returns(false);
                }
                ii.GetUIItem().Returns(tarItem);
                ii.GetItemTemplate().Returns(tarItemTemp);
            }
            result.Add(ii);
        }
        return(result);
    }
Beispiel #3
0
    List <IItemIcon> CreateStubIIsWithItemQuantity(int size, int quantInIG, IUIItem item)
    {
        List <IItemIcon> result = new List <IItemIcon>();

        for (int i = 0; i < size; i++)
        {
            result.Add(Substitute.For <IItemIcon>());
        }
        if (quantInIG != 0)
        {
            IItemIcon firstOne = result[0];
            IUIItem   sameItem = Substitute.For <IUIItem>();
            sameItem.IsSameAs(item).Returns(true);
            sameItem.GetQuantity().Returns(quantInIG);
            firstOne.GetUIItem().Returns(sameItem);
        }
        return(result);
    }
        public int GetItemQuantity(IUIItem item)
        {
            int result = 0;

            foreach (IItemIcon ii in thisItemIcons)
            {
                if (ii.IsEmpty())
                {
                    continue;
                }
                else
                {
                    IUIItem thisItem = ii.GetUIItem();
                    if (thisItem.IsSameAs(item))
                    {
                        result += thisItem.GetQuantity();
                    }
                }
            }
            return(result);
        }