Example #1
0
        public bool RemoveFromDefinition(CWDefinition definition, int quantity)
        {
            InventoryEntry existingInventoryEntry = FindInventoryEntryFromDefinition(definition);

            while (quantity > 0 && existingInventoryEntry != null)
            {
                if (existingInventoryEntry.quantity >= quantity)
                {
                    int temp = existingInventoryEntry.quantity;
                    existingInventoryEntry.quantity -= quantity;
                    quantity -= temp;
                }
                else
                {
                    int temp = existingInventoryEntry.quantity;
                    existingInventoryEntry.quantity = 0;
                    quantity -= temp;
                }

                if (existingInventoryEntry.quantity == 0)
                    entries.Remove(existingInventoryEntry);

                existingInventoryEntry = FindInventoryEntryFromDefinition(definition);
            }

            return quantity <= 0;
        }
Example #2
0
        public InventoryEntry FindInventoryEntryFromDefinition(CWDefinition definition)
        {
            foreach (InventoryEntry entry in entries)
                if (entry.cwobject.definition == definition)
                    return entry;

            return null;
        }
Example #3
0
 public bool HasMoreOfDefinition(CWDefinition definition)
 {
     return FindInventoryEntryFromDefinition(definition) != null;
 }