Esempio n. 1
0
    List <IItemIcon> CreateStubIIsWithNoMatchAndEmptyAt(int size, IEquippableUIItem item, int[] emptyAt)
    {
        List <IItemIcon> result = new List <IItemIcon>();

        for (int i = 0; i < size; i++)
        {
            IEquippableItemIcon tarII = Substitute.For <IEquippableItemIcon>();
            bool contained            = false;
            foreach (int j in emptyAt)
            {
                if (j == i)
                {
                    contained = true;
                }
            }
            if (contained)
            {
                tarII.GetUIItem().Returns((IUIItem)null);
                tarII.IsEmpty().Returns(true);
            }
            else
            {
                IUIItem tarItem = Substitute.For <IUIItem>();
                tarII.GetUIItem().Returns(tarItem);
                tarII.IsEmpty().Returns(false);
            }
            result.Add(tarII);
        }
        return(result);
    }
Esempio n. 2
0
    List <IItemIcon> CreateStubEqpIIsWithSameItemAt(int size, IUIItem sourceItem, int[] sameAt)
    {
        List <IItemIcon> result = new List <IItemIcon>();

        for (int i = 0; i < size; i++)
        {
            IEquippableItemIcon tarII   = Substitute.For <IEquippableItemIcon>();
            IUIItem             tarItem = Substitute.For <IUIItem>();
            tarII.GetUIItem().Returns(tarItem);

            bool contained = false;
            foreach (int j in sameAt)
            {
                if (j == i)
                {
                    contained = true;
                }
            }
            if (contained)
            {
                tarItem.IsSameAs(sourceItem).Returns(true);
            }
            else
            {
                tarItem.IsSameAs(sourceItem).Returns(false);
            }

            result.Add(tarII);
        }
        return(result);
    }
Esempio n. 3
0
        protected IEquippableItemIcon GetSameItemEqpII(IEquippableItemIcon sourceEqpII)
        {
            IItemIcon iiWithItem = GetItemIconFromItem(sourceEqpII.GetUIItem());

            if (iiWithItem != null)
            {
                return((IEquippableItemIcon)iiWithItem);
            }
            return(null);
        }
 protected override bool IsEligibleForHover(IItemIcon pickedII)
 {
     if (pickedII is IEquippableItemIcon)
     {
         IEquippableItemIcon pickedEqpII    = pickedII as IEquippableItemIcon;
         IUIItem             pickedItem     = pickedEqpII.GetUIItem();
         IItemTemplate       pickedItemTemp = pickedItem.GetItemTemplate();
         if (pickedEqpII.IsBowOrWearItemIcon())               // always swapped
         {
             return(true);
         }
         else
         {
             if (pickedEqpII.IsInEqpIG())
             {
                 return(true);                 //always revertable
             }
             else                              // pickd from pool
             {
                 if (pickedEqpII.IsEquipped()) //always has the same partially picked item
                 {
                     return(true);
                 }
                 else
                 {
                     IEquipToolIG relevantEqpIG = thisEqpIITAM.GetRelevantEquipIG(pickedEqpII);
                     if (relevantEqpIG.GetSize() == 1)                            //swap target is deduced
                     {
                         return(true);
                     }
                     else
                     {
                         if (relevantEqpIG.HasSlotSpace())                               //add target is deduced
                         {
                             return(true);
                         }
                         else
                         {
                             return(false);
                         }
                     }
                 }
             }
         }
     }
     else
     {
         throw new System.ArgumentException("pickedII must be of type IEquippableItemIcon");
     }
 }
Esempio n. 5
0
    public void EqpToolEqpCarriedGearIG_GetDefaultTATargetEqpII_HasNoSameItem_HasEmpty_ReturnsFirstEmpty(int[] emptyAt)
    {
        IIconGroupConstArg  arg;
        TestEqpToolEqpCGIG  ig            = CreateEqpToolEqpCarriedGearIG(0, 4, out arg);
        IEquippableItemIcon pickedEqpII   = Substitute.For <IEquippableItemIcon>();
        IEquippableUIItem   pickedEqpItem = Substitute.For <IEquippableUIItem>();

        pickedEqpII.GetUIItem().Returns(pickedEqpItem);
        List <IItemIcon> iis = CreateStubIIsWithNoMatchAndEmptyAt(4, pickedEqpItem, emptyAt);

        ig.SetItemIcons(iis);

        IEquippableItemIcon actualEqpII   = ig.GetDefaultTATargetEqpII(pickedEqpII);
        IItemIcon           expectedEqpII = iis[emptyAt[0]];

        Assert.That(actualEqpII, Is.SameAs(expectedEqpII));
    }
Esempio n. 6
0
    public void EqpToolEqpCarriedGearIG_GetDefaultTATargetEqpII_HasSameItem_ReturnsIt(int[] sameAt)
    {
        IIconGroupConstArg  arg;
        TestEqpToolEqpCGIG  ig            = CreateEqpToolEqpCarriedGearIG(0, 4, out arg);
        IEquippableItemIcon pickedEqpII   = Substitute.For <IEquippableItemIcon>();
        IEquippableUIItem   pickedEqpItem = Substitute.For <IEquippableUIItem>();

        pickedEqpII.GetUIItem().Returns(pickedEqpItem);
        List <IItemIcon> iisContainingSameItem = CreateStubEqpIIsWithSameItemAt(4, pickedEqpItem, sameAt);

        ig.SetItemIcons(iisContainingSameItem);

        IEquippableItemIcon actualEqpII = ig.GetDefaultTATargetEqpII(pickedEqpII);
        IItemIcon           expectedII  = iisContainingSameItem[sameAt[0]];

        Assert.That(actualEqpII, Is.SameAs(expectedII));
    }