void SetUpLeftoverII(int pickedQuantity)
        {
            IItemIcon leftoverII = CreateLeftoverII(pickedQuantity);

            leftoverII.UpdateTransferableQuantity(pickedQuantity);
            thisItemIcon.HandOverTravel(leftoverII);
        }
Exemplo n.º 2
0
 public void SwapIIInAllMutations(IItemIcon sourceII, IItemIcon targetII)
 {
     foreach (IMutation mut in thisMutationStack)
     {
         mut.FindInProspectiveIIsAndSwap(sourceII, targetII);
     }
 }
Exemplo n.º 3
0
        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);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void ReceiveSpotTransfer(IItemIcon transferringII)
        {
            IUIItem addedItem  = transferringII.GetUIItem();
            int     destSlotID = GetProspectiveSlotID(addedItem);

            AddIIAndMutate(addedItem, destSlotID);
        }
 void CheckPassedItemIconTypeValidity(IItemIcon itemIcon)
 {
     if (!(itemIcon is IEquippableItemIcon))
     {
         throw new System.InvalidCastException("passed itemIcon must be of type IEquippableItemIcon");
     }
 }
    public ItemIconPickUpImplementor CreateIIPUImplementor(int transferableQuantity, int itemQuantity, int pickUpStepQuantity, out IItemIcon ii, out IItemIconTransactionManager iiTAM, out IPickUpSystemUIElementFactory uieFactory)
    {
        IItemIcon thisII = Substitute.For <IItemIcon>();

        thisII.GetUIImage().Returns(Substitute.For <IUIImage>());
        IItemTemplate itemTemp = Substitute.For <IItemTemplate>();

        itemTemp.GetPickUpStepQuantity().Returns(pickUpStepQuantity);
        // thisII.GetItemTemplate().Returns(itemTemp);
        IUIItem item = Substitute.For <IUIItem>();

        item.GetItemTemplate().Returns(itemTemp);
        thisII.GetUIItem().Returns(item);
        thisII.GetTransferableQuantity().Returns(transferableQuantity);
        thisII.GetItemQuantity().Returns(itemQuantity);
        thisII.GetIconGroup().Returns(Substitute.For <IIconGroup>());
        IItemIconTransactionManager   thisIITAM      = Substitute.For <IItemIconTransactionManager>();
        IPickUpSystemUIElementFactory thisUIEFactory = Substitute.For <IPickUpSystemUIElementFactory>();
        ItemIconPickUpImplementor     implementor    = new ItemIconPickUpImplementor(thisIITAM, thisUIEFactory);

        implementor.SetItemIcon(thisII);
        ii         = thisII;
        iiTAM      = thisIITAM;
        uieFactory = thisUIEFactory;
        return(implementor);
    }
 public void SetItemIcon(IItemIcon itemIcon)
 {
     foreach (IIITransactionState state in thisStates)
     {
         state.SetItemIcon(itemIcon);
     }
 }
Exemplo n.º 8
0
    public void SetToPickedState_CallsPickedStateSetPickedII()
    {
        TestIITAMStateEngine engine   = new TestIITAMStateEngine();
        IItemIcon            pickedII = Substitute.For <IItemIcon>();

        engine.SetToPickedState(pickedII);

        engine.GetPickedState().Received(1).SetPickedII(pickedII);
    }
Exemplo n.º 9
0
        protected IEquippableItemIcon GetSameItemEqpII(IEquippableItemIcon sourceEqpII)
        {
            IItemIcon iiWithItem = GetItemIconFromItem(sourceEqpII.GetUIItem());

            if (iiWithItem != null)
            {
                return((IEquippableItemIcon)iiWithItem);
            }
            return(null);
        }
        void IncrementPickUpQuantityBy(int increQuantity)
        {
            IItemIcon pickedII = thisIITAM.GetPickedII();

            pickedII.IncreaseBy(increQuantity, doesIncrement: true);
            thisItemIcon.DecreaseBy(increQuantity, doesIncrement: true, removesEmpty: false);
            int newPickedUpQuantity = pickedII.GetItemQuantity();

            thisItemIcon.UpdateTransferableQuantity(newPickedUpQuantity);
        }
Exemplo n.º 11
0
 public void EvaluateAllIIsHoverability(IItemIcon pickedII)
 {
     foreach (IItemIcon ii in this.thisItemIcons)
     {
         if (ii != pickedII)
         {
             ii.EvaluateHoverability(pickedII);
         }
     }
 }
 public override void SetItemIcon(IItemIcon itemIcon)
 {
     if (itemIcon is IEquippableItemIcon)
     {
         base.SetItemIcon(itemIcon);
     }
     else
     {
         throw new System.InvalidOperationException("itemIcon needs to be of type IEquippableItemIcon");
     }
 }
Exemplo n.º 13
0
        void AddIIAndMutate(IUIItem item, int idAtAdd)
        {
            IItemIcon        newItemIcon = thisPickupSystemUIElementFactory.CreateItemIcon(item);
            List <IItemIcon> newIIs      = CreateNewItemIconsFrom(thisItemIcons);

            newIIs.Insert(idAtAdd, newItemIcon);
            this.UpdateIIs(newIIs);
            IReformation reformation = new Reformation(iconGroup: this, newProspectiveIIs: thisItemIcons, travelTransferII: newItemIcon, iisToInit: null);

            UpdateMutation(reformation, travelTransferData: null);
        }
Exemplo n.º 14
0
 public void RemoveItem(IUIItem item, bool doesIncrement, bool removesEmpty)
 {
     if (item != null)
     {
         IItemIcon thisII = GetItemIconFromItem(item);
         if (thisII != null)
         {
             thisII.DecreaseBy(thisII.GetItemQuantity(), doesIncrement, removesEmpty);
         }
     }
 }
Exemplo n.º 15
0
        public void ReplaceAndUpdateII(int indexToReplace, IItemIcon replacingII)
        {
            List <IItemIcon> newIIs = new List <IItemIcon>();
            int i = 0;

            foreach (IItemIcon ii in thisItemIcons)
            {
                newIIs[i++] = ii;
            }
            newIIs[indexToReplace] = replacingII;
            UpdateIIs(newIIs);
        }
    public void GetItemIconFromItem_MoreThanOneMatch_ReturnsFirstMatch(int[] quantities, int[] sameAt)
    {
        IIconGroupConstArg arg;
        TestIG             testIG     = CreateTestIG(quantities.Length, quantities.Length, out arg);
        IUIItem            sourceItem = Substitute.For <IUIItem>();
        List <IItemIcon>   iis        = CreateStubIIsWithItemsMatchingAt(quantities, sourceItem, sameAt);

        testIG.SetItemIcons(iis);

        IItemIcon actualII = testIG.GetItemIconFromItem(sourceItem);

        Assert.That(actualII, Is.EqualTo(iis[sameAt[0]]));
    }
Exemplo n.º 17
0
        public void EvaluateHoverability(IPickableUIE pickedUIE)
        {
            IItemIcon pickedII = (IItemIcon)pickedUIE;

            if (this.IsEligibleForHover(pickedII))
            {
                BecomeHoverable();
            }
            else
            {
                BecomeUnhoverable();
            }
        }
Exemplo n.º 18
0
    public void HandOverTravel_IrperNotNull_CallsProcessUpdateTravellingII()
    {
        IItemIconConstArg arg;
        TestItemIcon      itemIcon = CreateTestItemIconWithIG(0, out arg);
        ITravelProcess    process  = Substitute.For <ITravelProcess>();

        itemIcon.SetRunningTravelProcess(process);
        IItemIcon other = Substitute.For <IItemIcon>();

        itemIcon.HandOverTravel(other);

        process.Received(1).UpdateTravellingUIEFromTo(itemIcon, other);
    }
        IItemIcon CreateLeftoverII(int pickedQuantity)
        {
            IItemIcon leftoverII      = thisPickUpSystemUIElementFactory.CreateItemIcon(thisItem);
            IUIImage  leftoverIIImage = leftoverII.GetUIImage();

            leftoverII.SetParentUIE(thisItemIcon.GetParentUIE(), true);
            leftoverIIImage.CopyPosition(thisImage);
            thisIG.ReplaceAndUpdateII(thisItemIcon.GetSlotID(), leftoverII);
            leftoverII.DisemptifyInstantly(thisItem);
            leftoverII.DecreaseBy(pickedQuantity, doesIncrement: true, removesEmpty: false);

            return(leftoverII);
        }
Exemplo n.º 20
0
    public void EvaluatePickability_ThisIsEmpty_CallsEngineBecomeUnpickable()
    {
        IItemIconConstArg arg;
        IItemIcon         itemIcon = CreateTestItemIcon(out arg);
        IItemIconTransactionStateEngine iiTAStateEngine      = arg.iiTAStateEngine;
        IItemIconEmptinessStateEngine   emptinessStateEngine = arg.emptinessStateEngine;

        emptinessStateEngine.IsEmpty().Returns(true);
        Assert.That(itemIcon.IsEmpty(), Is.True);

        itemIcon.EvaluatePickability();

        iiTAStateEngine.Received(1).BecomeUnpickable();
    }
    public void AssertPickUpSystemUIEFactoryCreateItemIconIsCalled(IItemIcon ii, IPickUpSystemUIElementFactory factory, bool expectedToReceive)
    {
        IItemIcon leftoverII = Substitute.For <IItemIcon>();

        factory.CreateItemIcon(ii.GetUIItem()).Returns(leftoverII);
        if (expectedToReceive)
        {
            factory.Received(1).CreateItemIcon(ii.GetUIItem());
        }
        else
        {
            factory.DidNotReceive().CreateItemIcon(ii.GetUIItem());
        }
    }
        protected override bool IsEligibleForHover(IItemIcon pickedII)
        {
            CheckPassedItemIconTypeValidity(pickedII);
            IEquippableItemIcon pickedEqpII = (IEquippableItemIcon)pickedII;

            if (this.IsInSourceIG(pickedEqpII))
            {
                return(this.IsEligibleForHoverAsSourceIGEqpII(pickedEqpII));
            }
            else
            {
                return(this.IsEligibleForHoverAsDestIGEqpII(pickedEqpII));
            }
        }
Exemplo n.º 23
0
 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");
     }
 }
Exemplo n.º 24
0
 public void RemoveIIAndMutate(IItemIcon itemIconToRemove)
 {
     if (thisItemIcons.Contains(itemIconToRemove))
     {
         List <IItemIcon> newIIs = CreateNewItemIconsFrom(thisItemIcons);
         newIIs.Remove(itemIconToRemove);
         this.UpdateIIs(newIIs);
         IReformation reformation = new Reformation(iconGroup: this, newProspectiveIIs: newIIs, travelTransferII: null, iisToInit: null);
         UpdateMutation(reformation, travelTransferData: null);
     }
     else
     {
         throw new System.InvalidOperationException("itemIconToRemove is not a memeber of thisItemIcons");
     }
 }
    public void CheckAndIncrementPickUpQuantity_ThisIITAMIsNotInPickedUpState_DoesNotCallPickedIIIncreaseBy(int transferableQuantity, int itemQuantity, int pickUpStepQuantity)
    {
        IItemIcon thisII;
        IItemIconTransactionManager   thisIITAM;
        IPickUpSystemUIElementFactory thisUIEFactory;
        ItemIconPickUpImplementor     implementor = CreateIIPUImplementor(transferableQuantity, itemQuantity, pickUpStepQuantity, out thisII, out thisIITAM, out thisUIEFactory);

        thisIITAM.IsInPickedUpState().Returns(false);
        IItemIcon pickedII = Substitute.For <IItemIcon>();

        thisIITAM.GetPickedII().Returns(pickedII);

        implementor.CheckAndIncrementPickUpQuantity();

        pickedII.DidNotReceive().IncreaseBy(Arg.Any <int>(), Arg.Any <bool>());
    }
    public void CheckAndIncrementPickUpQuantity_ThisIITAMIsInPickedUpState_IncrementQGreaterThanZero_CallsPickedIIIncreaseBy(int transferableQuantity, int itemQuantity, int pickUpStepQuantity)
    {
        IItemIcon thisII;
        IItemIconTransactionManager   thisIITAM;
        IPickUpSystemUIElementFactory thisUIEFactory;
        ItemIconPickUpImplementor     implementor = CreateIIPUImplementor(transferableQuantity, itemQuantity, pickUpStepQuantity, out thisII, out thisIITAM, out thisUIEFactory);

        thisIITAM.IsInPickedUpState().Returns(true);
        IItemIcon pickedII = Substitute.For <IItemIcon>();

        thisIITAM.GetPickedII().Returns(pickedII);

        implementor.CheckAndIncrementPickUpQuantity();

        pickedII.Received(1).IncreaseBy(Mathf.Min(transferableQuantity, pickUpStepQuantity), true);
    }
Exemplo n.º 27
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));
    }
Exemplo n.º 28
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));
    }
    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);
    }
Exemplo n.º 30
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);
    }