/// <summary> /// Groups the given items (adds quantities), in the inventory and backpack seperately /// </summary> /// <param name="items">The items to group.</param> /// <returns>The grouped list.</returns> private LinkedList <BlissHiveLogItem> Group(LinkedList <BlissHiveLogItem> items) { for (int i = 0; i < items.Count; i++) { BlissHiveLogItem item = items.ElementAt(i); for (int j = 0; j < items.Count; j++) { if (i == j) { continue; } BlissHiveLogItem otherItem = items.ElementAt(j); if (item.location != otherItem.location) { continue; } if (item.key == otherItem.key) { items.Remove(otherItem); item.quantity += otherItem.quantity; i--; j--; // Continue, re-search the entire backpack for more duplicates // of the same item break; } } } return(items); }
/// <summary> /// Clones this object. /// </summary> /// <returns></returns> public BlissHiveLogItem Clone() { BlissHiveLogItem item = new BlissHiveLogItem(this.key, this.location, this.quantity); item.description = this.description; return(item); }
/// <summary> /// Merges the inventory and backpack to the inventory, and gets the list /// </summary> /// <returns></returns> public LinkedList <BlissHiveLogItem> GetMergedItemList() { LinkedList <BlissHiveLogItem> result = new LinkedList <BlissHiveLogItem>(); foreach (BlissHiveLogItem item in this.items) { // All items are in the inventory now for easing calculation-+ BlissHiveLogItem newItem = item.Clone(); newItem.location = BlissHiveLogItem.Location.Inventory; result.AddLast(newItem); } return(this.Group(result)); }
public BlissHiveLogActivityItem(int quantity, BlissHiveLogItem item, String timestamp) { this.quantity = quantity; this.item = item; this.timestamp = timestamp; }