aboutsummaryrefslogtreecommitdiff
path: root/internal/action/recipe.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/action/recipe.go')
-rw-r--r--internal/action/recipe.go20
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