예제 #1
0
    public int AmountDesiredOfInventoryType(string type)
    {
        RequestedItem requestedItem;

        if (RequestedItems.TryGetValue(type, out requestedItem) == false)
        {
            return(0);
        }

        Inventory inventory;

        if (DeliveredItems.TryGetValue(type, out inventory) == false)
        {
            inventory = null;
        }

        return(requestedItem.AmountDesired(inventory));
    }
예제 #2
0
    public RequestedItem GetFirstDesiredItem()
    {
        foreach (RequestedItem item in RequestedItems.Values)
        {
            Inventory inventory;
            if (DeliveredItems.TryGetValue(item.Type, out inventory) == false)
            {
                inventory = null;
            }

            if (item.DesiresMore(inventory))
            {
                return(item);
            }
        }

        return(null);
    }
예제 #3
0
    public bool HasAllMaterial()
    {
        if (RequestedItems == null)
        {
            return(true);
        }

        foreach (RequestedItem item in RequestedItems.Values)
        {
            Inventory inventory;
            if (DeliveredItems.TryGetValue(item.Type, out inventory) == false || item.AmountNeeded(inventory) > 0)
            {
                return(false);
            }
        }

        return(true);
    }