Add durable recipe discovery and profession crafting
This commit is contained in:
+11
-2
@@ -35,6 +35,8 @@ type ItemRequirements struct {
|
||||
Titles []string `json:"titles" yaml:"titles"`
|
||||
}
|
||||
type ItemDefinition struct {
|
||||
CraftPool []CraftStat `json:"craftPool,omitempty" yaml:"craftPool"`
|
||||
CraftRolls int64 `json:"craftRolls,omitempty" yaml:"craftRolls"`
|
||||
AttackID string `json:"attackId,omitempty" yaml:"attackId"`
|
||||
ID string `json:"id" yaml:"id"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
@@ -46,6 +48,7 @@ type ItemDefinition struct {
|
||||
Modifiers []StatModifier `json:"modifiers" yaml:"modifiers"`
|
||||
}
|
||||
type Catalog struct {
|
||||
Crafting *CraftingContent `json:"crafting,omitempty"`
|
||||
Combat *CombatContent `json:"combat,omitempty"`
|
||||
Gathering *GatheringContent `json:"gathering,omitempty"`
|
||||
Version int64 `json:"version"`
|
||||
@@ -99,7 +102,10 @@ func ValidItemSlot(slot string) bool {
|
||||
return slices.Contains([]string{"helmet", "mask", "chest", "shoulders", "pants", "boots", "gloves", "earrings", "necklace", "ring", "weapon", "offhand", "cape", "bag"}, slot)
|
||||
}
|
||||
func (item ItemDefinition) Validate() error {
|
||||
if slices.Contains([]string{"axe", "flint_and_steel", "fishing_pole", "wood", "ore", "herb", "bandage"}, item.ID) {
|
||||
if err := ValidateCraftPool(item); err != nil {
|
||||
return err
|
||||
}
|
||||
if slices.Contains([]string{"axe", "flint_and_steel", "fishing_pole", "wood", "ore", "herb", "bandage", "escape_stone"}, item.ID) {
|
||||
return fmt.Errorf("equipment ID conflicts with a stackable item")
|
||||
}
|
||||
if math.IsNaN(item.DropChance) || math.IsInf(item.DropChance, 0) || item.DropChance < 0 || item.DropChance > 100 {
|
||||
@@ -126,6 +132,9 @@ func (item ItemDefinition) Validate() error {
|
||||
return ValidateModifiers(item.Modifiers)
|
||||
}
|
||||
func (c Catalog) Validate() error {
|
||||
if err := c.validateCrafting(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.validateCombat(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -201,5 +210,5 @@ func DefaultCatalog() (Catalog, error) {
|
||||
if err != nil {
|
||||
return Catalog{}, err
|
||||
}
|
||||
return Catalog{Combat: b.Combat, Gathering: b.Gathering, Version: 1, Titles: b.Titles, Items: b.Items, Stats: *b.Stats}, nil
|
||||
return Catalog{Crafting: b.Crafting, Combat: b.Combat, Gathering: b.Gathering, Version: 1, Titles: b.Titles, Items: b.Items, Stats: *b.Stats}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user