public bool IsSameAs(IUIItem other) { /* Ghost is treated as same, sharing the same item instance with picked */ if (thisItemTemp.IsStackable()) { return(thisItemTemp == other.GetItemTemplate()); } else /* non stackable */ { return(thisItemID == other.GetItemID()); } }
public void IsSameAs_ThisItemTempIsStackable_ThisItemTempNotRefEqualsToOtherItemTemp_ReturnsFalse() { IUIItemConstArg arg; TestItem item = CreateTestItem(1, 0, out arg); IItemTemplate thisItemTemp = arg.itemTemp; thisItemTemp.IsStackable().Returns(true); IUIItem otherItem = Substitute.For <IUIItem>(); otherItem.GetItemTemplate().Returns(Substitute.For <IItemTemplate>()); bool actualBool = item.IsSameAs(otherItem); Assert.That(actualBool, Is.False); }
public void IsSameAs_ThisItemTempIsNotStackable_ThisItemIDEqualsToOtherItemID_ReturnsTrue() { IUIItemConstArg arg; const int itemID = 0; TestItem item = CreateTestItem(1, itemID, out arg); IItemTemplate thisItemTemp = arg.itemTemp; thisItemTemp.IsStackable().Returns(false); IUIItem otherItem = Substitute.For <IUIItem>(); otherItem.GetItemID().Returns(itemID); bool actualBool = item.IsSameAs(otherItem); Assert.That(actualBool, Is.True); }
protected override int GetMaxTransferableQuantity() { IItemTemplate thisItemTemp = thisEqpItem.GetItemTemplate(); int thisQuantity = thisEqpII.GetItemQuantity(); if (thisEqpII.IsBowOrWearItemIcon()) { if (thisQuantity != 0) { return(1); } else { return(0); } } else { if (thisEqpII.IsInEqpIG()) { return(thisQuantity); } else { if (thisItemTemp.IsStackable()) { return(thisQuantity); } else { IEquipToolEquippedCarriedGearsIG relevantEqpCGIG = thisEqpIITAM.GetRelevantEquippedCarriedGearsIG(); int equippedQuantity = relevantEqpCGIG.GetItemQuantity(thisEqpItem); int spaceInEqpIG = thisEqpItem.GetMaxEquippableQuantity() - equippedQuantity; return(Mathf.Min(spaceInEqpIG, thisQuantity)); } } } }