Skip to content

Commit

Permalink
Introduce inventory cross-item limits. (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyro authored Jul 26, 2024
1 parent ffe51c2 commit 9d52412
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions definitions/07-Hiro-Inventory.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@
"prop2": 456
}
}
},
"limits": {
"categories": {
"category1": 10
}
}
}
6 changes: 6 additions & 0 deletions inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

type InventoryConfig struct {
Items map[string]*InventoryConfigItem `json:"items,omitempty"`
Limits *InventoryConfigLimits `json:"limits,omitempty"`
ItemSets map[string]map[string]bool `json:"-"` // Auto-computed when the config is read or personalized.
}

Expand All @@ -40,6 +41,11 @@ type InventoryConfigItem struct {
KeepZero bool `json:"keep_zero,omitempty"`
}

type InventoryConfigLimits struct {
Categories map[string]int64 `json:"categories,omitempty"`
ItemSets map[string]int64 `json:"item_sets,omitempty"`
}

// The InventorySystem provides a gameplay system which can manage a player's inventory.
//
// A player can have items added via economy rewards, or directly.
Expand Down
23 changes: 23 additions & 0 deletions schemas/07-Hiro-Inventory.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,29 @@
}
},
"type": "object"
},
"limits": {
"properties": {
"categories": {
"patternProperties": {
".+": {
"minimum": 0,
"type": "number"
}
},
"type": "object"
},
"item_sets": {
"patternProperties": {
".+": {
"minimum": 0,
"type": "number"
}
},
"type": "object"
}
},
"type": "object"
}
},
"type": "object"
Expand Down

0 comments on commit 9d52412

Please sign in to comment.