diff options
Diffstat (limited to 'internal/action/recipe.go')
| -rw-r--r-- | internal/action/recipe.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/action/recipe.go b/internal/action/recipe.go index 7627047..18c08c5 100644 --- a/internal/action/recipe.go +++ b/internal/action/recipe.go @@ -196,6 +196,26 @@ func (r *RecipeDef) ConsumeAll(hasItem func(string) bool, removeItem func(string return true } +func (r *RecipeDef) HasAllItemsQty(countItem func(string) int) bool { + for _, e := range r.Consume { + found := false + for _, id := range e.Items { + qty := e.Qty + if qty <= 0 { + qty = 1 + } + if countItem(id) >= qty { + found = true + break + } + } + if !found { + return false + } + } + return true +} + func (r *RecipeDef) HasAllItems(hasItem func(string) bool) bool { for _, e := range r.Consume { found := false |
