Add housing storage, guest permissions, and timed key destruction
This commit is contained in:
@@ -214,6 +214,8 @@ items:
|
||||
modifiers: [{ stat: meleeDamage, flat: 14, percent: 0 }]
|
||||
|
||||
# Milestone 6 provisional crafting tuning. Percentages use 0-100.
|
||||
- {"id": "storage_chest", "name": "Storage chest", "description": "Furniture for a house.", "slot": "bag", "weight": 5, "dropChance": 0, "requirements": {"level": 1, "stats": {}, "titles": []}, "modifiers": [], "furniture": {"width": 2, "depth": 1, "container": true}}
|
||||
- {"id": "house_table", "name": "House table", "description": "Furniture for a house.", "slot": "bag", "weight": 5, "dropChance": 0, "requirements": {"level": 1, "stats": {}, "titles": []}, "modifiers": [], "furniture": {"width": 2, "depth": 2, "container": false}}
|
||||
crafting:
|
||||
rules: { baseFailure: 25, minFailure: 1, maxFailure: 99.9, overLevelDecay: 0.12, underLevelGrowth: 0.25, baseLoss: 80, minLoss: 10, lossDecay: 0.025, qualityPerLevel: 0.03, maxQualityBias: 8, cooldown: 1 }
|
||||
professions:
|
||||
@@ -258,3 +260,5 @@ building:
|
||||
- {"id": "timber_wall", "name": "Timber wall", "description": "A persistent, destructible timber wall.", "model": "wall", "width": 4, "depth": 1, "height": 2, "hp": 250, "profession": "builder", "level": 1}
|
||||
- {"id": "camp_platform", "name": "Camp platform", "description": "A persistent, destructible camp platform.", "model": "camp", "width": 4, "depth": 4, "height": 0.75, "hp": 300, "profession": "builder", "level": 1}
|
||||
- {"id": "fort_block", "name": "Fort block", "description": "A persistent, destructible fort block.", "model": "fort", "width": 6, "depth": 3, "height": 3, "hp": 800, "profession": "builder", "level": 5}
|
||||
|
||||
housing: { roomSize: 12, maxFurniture: 64, maxItems: 256, maxGuests: 64, keySeconds: 3 }
|
||||
|
||||
@@ -19,6 +19,7 @@ type Recipe struct {
|
||||
}
|
||||
|
||||
type Balance struct {
|
||||
Housing *HousingRules `yaml:"housing"`
|
||||
Building *BuildingContent `yaml:"building"`
|
||||
Powers *PowerContent `yaml:"powers"`
|
||||
Crafting *CraftingContent `yaml:"crafting"`
|
||||
@@ -83,6 +84,11 @@ func Parse(data []byte) (Balance, error) {
|
||||
return b, b.Validate()
|
||||
}
|
||||
func (b Balance) Validate() error {
|
||||
if b.Housing != nil {
|
||||
if e := b.Housing.Validate(); e != nil {
|
||||
return e
|
||||
}
|
||||
}
|
||||
if e := (Catalog{Building: b.Building, Crafting: b.Crafting, Items: b.Items}).validateBuilding(); e != nil {
|
||||
return e
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package content
|
||||
|
||||
import "fmt"
|
||||
|
||||
type FurnitureProfile struct {
|
||||
Width float64 `json:"width" yaml:"width"`
|
||||
Depth float64 `json:"depth" yaml:"depth"`
|
||||
Container bool `json:"container" yaml:"container"`
|
||||
}
|
||||
|
||||
func (f FurnitureProfile) Validate() error {
|
||||
if !finiteRange(f.Width, .5, 4) || !finiteRange(f.Depth, .5, 4) {
|
||||
return fmt.Errorf("invalid furniture footprint")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type HousingRules struct {
|
||||
RoomSize float64 `yaml:"roomSize"`
|
||||
MaxFurniture int `yaml:"maxFurniture"`
|
||||
MaxItems int `yaml:"maxItems"`
|
||||
MaxGuests int `yaml:"maxGuests"`
|
||||
KeySeconds float64 `yaml:"keySeconds"`
|
||||
}
|
||||
|
||||
func (r HousingRules) Validate() error {
|
||||
if !finiteRange(r.RoomSize, 8, 32) || r.MaxFurniture < 1 || r.MaxFurniture > 128 || r.MaxItems < 1 || r.MaxItems > 512 || r.MaxGuests < 1 || r.MaxGuests > 128 || r.KeySeconds != 3 {
|
||||
return fmt.Errorf("invalid housing rules")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (c *Catalog) RestoreFurniture(b Balance) {
|
||||
if c.HousingVersion != 0 {
|
||||
return
|
||||
}
|
||||
c.Items = append([]ItemDefinition{}, c.Items...)
|
||||
for _, v := range b.Items {
|
||||
if v.Furniture == nil {
|
||||
continue
|
||||
}
|
||||
found := false
|
||||
for _, i := range c.Items {
|
||||
if i.ID == v.ID {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
c.Items = append(c.Items, v)
|
||||
}
|
||||
}
|
||||
c.HousingVersion = 1
|
||||
}
|
||||
+23
-13
@@ -35,20 +35,22 @@ type ItemRequirements struct {
|
||||
Titles []string `json:"titles" yaml:"titles"`
|
||||
}
|
||||
type ItemDefinition struct {
|
||||
WeaponType string `json:"weaponType,omitempty" yaml:"weaponType"`
|
||||
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"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
Slot string `json:"slot" yaml:"slot"`
|
||||
Weight float64 `json:"weight" yaml:"weight"`
|
||||
DropChance float64 `json:"dropChance" yaml:"dropChance"`
|
||||
Requirements ItemRequirements `json:"requirements" yaml:"requirements"`
|
||||
Modifiers []StatModifier `json:"modifiers" yaml:"modifiers"`
|
||||
Furniture *FurnitureProfile `json:"furniture,omitempty" yaml:"furniture"`
|
||||
WeaponType string `json:"weaponType,omitempty" yaml:"weaponType"`
|
||||
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"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
Slot string `json:"slot" yaml:"slot"`
|
||||
Weight float64 `json:"weight" yaml:"weight"`
|
||||
DropChance float64 `json:"dropChance" yaml:"dropChance"`
|
||||
Requirements ItemRequirements `json:"requirements" yaml:"requirements"`
|
||||
Modifiers []StatModifier `json:"modifiers" yaml:"modifiers"`
|
||||
}
|
||||
type Catalog struct {
|
||||
HousingVersion int `json:"housingVersion,omitempty"`
|
||||
Building *BuildingContent `json:"building,omitempty"`
|
||||
Powers *PowerContent `json:"powers,omitempty"`
|
||||
Crafting *CraftingContent `json:"crafting,omitempty"`
|
||||
@@ -105,6 +107,14 @@ 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 item.Furniture != nil {
|
||||
if item.Slot != "bag" {
|
||||
return fmt.Errorf("furniture must use bag slot")
|
||||
}
|
||||
if e := item.Furniture.Validate(); e != nil {
|
||||
return e
|
||||
}
|
||||
}
|
||||
if err := ValidateCraftPool(item); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -219,5 +229,5 @@ func DefaultCatalog() (Catalog, error) {
|
||||
if err != nil {
|
||||
return Catalog{}, err
|
||||
}
|
||||
return Catalog{Building: b.Building, Powers: b.Powers, Crafting: b.Crafting, Combat: b.Combat, Gathering: b.Gathering, Version: 1, Titles: b.Titles, Items: b.Items, Stats: *b.Stats}, nil
|
||||
return Catalog{HousingVersion: 1, Building: b.Building, Powers: b.Powers, 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