# HG changeset patch # User IBBoard # Date 1256936568 0 # Node ID ec1cfe3ef94e49379c5f63d57276f1d33e4936ed # Parent 4bbf5624ced6df9aab033274be4c387a722f9c21 * Add extra method for getting the number of items in a slot without including the given item (required when editing equipment in slots) no-open-ticket diff -r 4bbf5624ced6 -r ec1cfe3ef94e IBBoard.WarFoundry.API.csproj --- a/IBBoard.WarFoundry.API.csproj Fri Oct 30 20:58:19 2009 +0000 +++ b/IBBoard.WarFoundry.API.csproj Fri Oct 30 21:02:48 2009 +0000 @@ -1,4 +1,4 @@ - + Debug @@ -45,6 +45,8 @@ PreserveNewest + + PreserveNewest diff -r 4bbf5624ced6 -r ec1cfe3ef94e api/Objects/Unit.cs --- a/api/Objects/Unit.cs Fri Oct 30 20:58:19 2009 +0000 +++ b/api/Objects/Unit.cs Fri Oct 30 21:02:48 2009 +0000 @@ -520,6 +520,36 @@ return amount; } + /// + /// Gets the total amount of items taken for the item's slot, excluding the provided item + /// + /// the item to exclude from the count + /// the total number of items + public int GetEquipmentAmountInSlotWithoutItem(UnitEquipmentItem item) + { + int amount = 0; + + List selections = DictionaryUtils.GetValue(equipmentSlots, item.SlotName); + + if (selections != null) + { + RemoveSelectionFromList(item, selections); + amount = GetSelectionTotal(selections); + } + + return amount; + } + + private void RemoveSelectionFromList(UnitEquipmentItem item, List selections) + { + AbstractUnitEquipmentItemSelection selection = GetEquipmentSelection(item); + + if (selection != null) + { + selections.Remove(selection); + } + } + private int GetSelectionTotal (List selections) { int amount = 0;