public virtual Result <bool> CanUnEquip(int index, int amount) { if (collection.GetAmount(index) < amount) { return(new Result <bool>(false, Errors.CollectionDoesNotContainItem)); } var canRestore = restoreItemsToGroup.CanAdd(collection[index], amount); if (canRestore.error != null) { return(canRestore); } return(true); }
public void CollectionsReadOnlyGroupTest() { // Arrange int addedItemCount = 0; int removedItemCount = 0; int slotsChangedCount = 0; _col0.isReadOnly = true; _col1.isReadOnly = true; _col0.OnAddedItem += (sender, result) => addedItemCount++; _col0.OnRemovedItem += (sender, result) => removedItemCount++; _col0.OnSlotsChanged += (sender, result) => slotsChangedCount++; _col1.OnAddedItem += (sender, result) => addedItemCount++; _col1.OnRemovedItem += (sender, result) => removedItemCount++; _col1.OnSlotsChanged += (sender, result) => slotsChangedCount++; // Act var canAddAmount = _group.GetCanAddAmount(_item); var canAdd = _group.CanAdd(_item); var addResult = _group.Add(_item); var canRemoveResult = _group.CanRemove(_item); var removeResult = _group.Remove(_item); // Assert Assert.AreEqual(0, addedItemCount); Assert.AreEqual(0, removedItemCount); Assert.AreEqual(0, slotsChangedCount); Assert.AreEqual(Errors.CollectionFull, canAdd.error); Assert.AreEqual(Errors.CollectionFull, addResult.error); Assert.AreEqual(Errors.CollectionDoesNotContainItem, canRemoveResult.error); Assert.AreEqual(Errors.CollectionDoesNotContainItem, removeResult.error); Assert.AreEqual(0, canAddAmount); }
public Result <bool> CanAddItem(T item, int amount = 1) { return(inventories.CanAdd(item, amount)); }