Add biome revisions readable content and visible projectile outcomes

This commit is contained in:
dingo
2026-09-09 08:27:32 -04:00
parent 4a7979e32f
commit 70d08b0d32
24 changed files with 703 additions and 128 deletions
+3 -3
View File
@@ -8,9 +8,9 @@ combatRules:
hitRadius: 1.2
combat:
attacks:
- { id: bow_shot, name: Bow shot, description: A straight projectile that can miss., delivery: projectile, effect: damage, stat: rangedDamage, multiplier: 1, range: 45, cooldown: 1, stamina: 2, speed: 35, radius: 0, duration: 0, interval: 1 }
- { id: blast_shot, name: Blast shot, description: A projectile with a damage burst., delivery: projectile, effect: damage, stat: rangedDamage, multiplier: 1, range: 35, cooldown: 3, stamina: 8, speed: 25, radius: 6, duration: 0, interval: 1 }
- { id: healing_field, name: Healing field, description: A projectile that creates a stationary healing area., delivery: projectile, effect: heal, stat: magicDamage, multiplier: 1, range: 30, cooldown: 8, stamina: 10, speed: 25, radius: 6, duration: 5, interval: 1 }
- { id: bow_shot, name: Bow shot, description: A straight projectile that can miss., delivery: projectile, effect: damage, stat: rangedDamage, multiplier: 1, range: 45, cooldown: 1, stamina: 2, speed: 35, dexteritySpeed: 0.1, strengthSpeed: 0.05, radius: 0, duration: 0, interval: 1 }
- { id: blast_shot, name: Blast shot, description: A projectile with a damage burst., delivery: projectile, effect: damage, stat: rangedDamage, multiplier: 1, range: 35, cooldown: 3, stamina: 8, speed: 25, dexteritySpeed: 0.1, strengthSpeed: 0.05, radius: 6, duration: 0, interval: 1 }
- { id: healing_field, name: Healing field, description: A projectile that creates a stationary healing area., delivery: projectile, effect: heal, stat: magicDamage, multiplier: 1, range: 30, cooldown: 8, stamina: 10, speed: 25, dexteritySpeed: 0.1, strengthSpeed: 0.05, radius: 6, duration: 5, interval: 1 }
- { id: sentinel_strike, name: Sentinel strike, description: Close range damage., delivery: melee, effect: damage, stat: meleeDamage, multiplier: 1, range: 3, cooldown: 1.8, stamina: 0, speed: 1, radius: 0, duration: 0, interval: 1 }
mobs:
- { id: ash_guard, name: Ash guard, description: A territorial guardian., model: sentinel, behavior: aggressive, level: 1, hp: 54, damage: 6, defence: 0, speed: 4, aggroRange: 24, leashRange: 160, scalePerDay: 0.1, xp: 50, attackId: sentinel_strike, lootId: common_mob_loot }
+19 -14
View File
@@ -6,23 +6,28 @@ import (
)
type CombatAttack struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
Delivery string `json:"delivery" yaml:"delivery"`
Effect string `json:"effect" yaml:"effect"`
Stat string `json:"stat" yaml:"stat"`
Multiplier float64 `json:"multiplier" yaml:"multiplier"`
Range float64 `json:"range" yaml:"range"`
Cooldown float64 `json:"cooldown" yaml:"cooldown"`
Stamina float64 `json:"stamina" yaml:"stamina"`
Speed float64 `json:"speed" yaml:"speed"`
Radius float64 `json:"radius" yaml:"radius"`
Duration float64 `json:"duration" yaml:"duration"`
Interval float64 `json:"interval" yaml:"interval"`
DexteritySpeed float64 `json:"dexteritySpeed,omitempty" yaml:"dexteritySpeed"`
StrengthSpeed float64 `json:"strengthSpeed,omitempty" yaml:"strengthSpeed"`
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
Delivery string `json:"delivery" yaml:"delivery"`
Effect string `json:"effect" yaml:"effect"`
Stat string `json:"stat" yaml:"stat"`
Multiplier float64 `json:"multiplier" yaml:"multiplier"`
Range float64 `json:"range" yaml:"range"`
Cooldown float64 `json:"cooldown" yaml:"cooldown"`
Stamina float64 `json:"stamina" yaml:"stamina"`
Speed float64 `json:"speed" yaml:"speed"`
Radius float64 `json:"radius" yaml:"radius"`
Duration float64 `json:"duration" yaml:"duration"`
Interval float64 `json:"interval" yaml:"interval"`
}
func (a CombatAttack) Validate() error {
if !finiteRange(a.DexteritySpeed, 0, 5) || !finiteRange(a.StrengthSpeed, 0, 5) {
return fmt.Errorf("invalid projectile speed coefficients")
}
if !validSetIdentity(a.ID, a.Name, a.Description) || !slices.Contains([]string{"melee", "projectile"}, a.Delivery) || !slices.Contains([]string{"damage", "heal"}, a.Effect) || !slices.Contains([]string{"meleeDamage", "rangedDamage", "magicDamage"}, a.Stat) || !finiteRange(a.Multiplier, .01, 100) || !finiteRange(a.Range, 1, 128) || !finiteRange(a.Cooldown, .1, 120) || !finiteRange(a.Stamina, 0, 10000) || !finiteRange(a.Speed, 1, 100) || !finiteRange(a.Radius, 0, 24) || !finiteRange(a.Duration, 0, 60) || !finiteRange(a.Interval, .2, 60) {
return fmt.Errorf("invalid attack %q", a.ID)
}
+27 -9
View File
@@ -31,11 +31,13 @@ type ResourceDefinition struct {
Biomes []string `json:"biomes" yaml:"biomes"`
}
type BiomeDefinition struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
Color string `json:"color" yaml:"color"`
Weight int64 `json:"weight" yaml:"weight"`
Revision int64 `json:"revision,omitempty" yaml:"revision"`
Resources []string `json:"resources" yaml:"resources"`
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
Color string `json:"color" yaml:"color"`
Weight int64 `json:"weight" yaml:"weight"`
}
type GatheringConsumable struct {
ID string `json:"id" yaml:"id"`
@@ -45,10 +47,11 @@ type GatheringConsumable struct {
Modifiers []StatModifier `json:"modifiers" yaml:"modifiers"`
}
type GatheringContent struct {
Skills []GatheringSkill `json:"skills" yaml:"skills"`
Resources []ResourceDefinition `json:"resources" yaml:"resources"`
Biomes []BiomeDefinition `json:"biomes" yaml:"biomes"`
Consumables []GatheringConsumable `json:"consumables" yaml:"consumables"`
BiomeHistory []BiomeDefinition `json:"biomeHistory,omitempty" yaml:"biomeHistory"`
Skills []GatheringSkill `json:"skills" yaml:"skills"`
Resources []ResourceDefinition `json:"resources" yaml:"resources"`
Biomes []BiomeDefinition `json:"biomes" yaml:"biomes"`
Consumables []GatheringConsumable `json:"consumables" yaml:"consumables"`
}
type GatheringRules struct {
FailureBase float64 `json:"failureBase" yaml:"failureBase"`
@@ -84,6 +87,9 @@ func (r GatheringRules) Validate() error {
return nil
}
func (g GatheringContent) Validate() error {
if len(g.BiomeHistory) > 1024 {
return fmt.Errorf("biome revision history limit reached")
}
if len(g.Skills) < 1 || len(g.Skills) > 64 || len(g.Resources) > 256 || len(g.Biomes) < 1 || len(g.Biomes) > 32 || len(g.Consumables) > 256 {
return fmt.Errorf("invalid gathering content counts")
}
@@ -125,6 +131,18 @@ func (g GatheringContent) Validate() error {
seen[id] = true
}
}
for _, b := range append(slices.Clone(g.Biomes), g.BiomeHistory...) {
if b.Revision < 0 || len(b.Resources) > 256 {
return fmt.Errorf("invalid biome revision")
}
seen := map[string]bool{}
for _, id := range b.Resources {
if seen[id] || !slices.ContainsFunc(g.Resources, func(r ResourceDefinition) bool { return r.ID == id }) {
return fmt.Errorf("unknown/duplicate biome resource %q", id)
}
seen[id] = true
}
}
for _, c := range g.Consumables {
if !identity(c.ID, c.Name, c.Description) || !finiteRange(c.Seconds, 1, 86400) || len(c.Modifiers) < 1 {
return fmt.Errorf("invalid consumable %q", c.ID)