Add rounded fantasy character and admin visual creators
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package content
|
||||
|
||||
import (
|
||||
p "aeternalis/server/internal/protocol"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"slices"
|
||||
)
|
||||
|
||||
// Appearance is a bounded, versioned presentation recipe. It never changes combat
|
||||
// radius, collision, movement speed, or any character/creature stats.
|
||||
type Appearance = p.Appearance
|
||||
|
||||
type VisualPreset struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Appearance Appearance `json:"appearance"`
|
||||
}
|
||||
|
||||
var appearanceColor = regexp.MustCompile(`^#[0-9a-fA-F]{6}$`)
|
||||
|
||||
func ValidateAppearance(a *Appearance, families ...string) error {
|
||||
if a == nil {
|
||||
return nil
|
||||
} // Existing worlds retain their original models.
|
||||
if !slices.Contains(families, a.Family) || a.Version != 1 || a.Variant < 0 || a.Variant > 3 || a.Seed < 1 || a.Seed > 65535 || !finiteRange(a.Height, .75, 1.25) || !finiteRange(a.Width, .75, 1.25) || !finiteRange(a.Detail, 0, 1) || !appearanceColor.MatchString(a.Primary) || !appearanceColor.MatchString(a.Secondary) || !appearanceColor.MatchString(a.Accent) {
|
||||
return fmt.Errorf("invalid appearance: choose a supported form, bounded proportions, and six-digit colors")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c Catalog) validateVisuals() error {
|
||||
if len(c.Visuals) > 1024 {
|
||||
return fmt.Errorf("visual library is full")
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
for _, v := range c.Visuals {
|
||||
if !titleID.MatchString(v.ID) || len(v.Name) < 1 || len(v.Name) > 80 || len(v.Description) > 500 || seen[v.ID] {
|
||||
return fmt.Errorf("invalid visual identity")
|
||||
}
|
||||
if err := ValidateAppearance(&v.Appearance, "human", "creature", "tree", "rock", "plant"); err != nil {
|
||||
return err
|
||||
}
|
||||
seen[v.ID] = true
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package content
|
||||
|
||||
import (
|
||||
"math"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAppearanceValidation(t *testing.T) {
|
||||
base := Appearance{Version: 1, Family: "human", Variant: 0, Seed: 42, Height: 1, Width: 1, Detail: .5, Primary: "#d8a582", Secondary: "#493947", Accent: "#578f8b"}
|
||||
if err := ValidateAppearance(&base, "human"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, mutate := range []func(*Appearance){
|
||||
func(a *Appearance) { a.Family = "tree" }, func(a *Appearance) { a.Version = 2 },
|
||||
func(a *Appearance) { a.Height = 100 }, func(a *Appearance) { a.Width = math.NaN() },
|
||||
func(a *Appearance) { a.Detail = math.Inf(1) }, func(a *Appearance) { a.Variant = 4 },
|
||||
func(a *Appearance) { a.Seed = 0 }, func(a *Appearance) { a.Primary = "url(bad)" },
|
||||
} {
|
||||
v := base
|
||||
mutate(&v)
|
||||
if ValidateAppearance(&v, "human") == nil {
|
||||
t.Fatal("invalid appearance accepted", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
-16
@@ -51,22 +51,23 @@ type LootTable struct {
|
||||
Entries []LootEntry `json:"entries" yaml:"entries"`
|
||||
}
|
||||
type MobDefinition struct {
|
||||
ID string `json:"id" yaml:"id"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
Model string `json:"model" yaml:"model"`
|
||||
Behavior string `json:"behavior" yaml:"behavior"`
|
||||
Level int64 `json:"level" yaml:"level"`
|
||||
HP float64 `json:"hp" yaml:"hp"`
|
||||
Damage float64 `json:"damage" yaml:"damage"`
|
||||
Defence float64 `json:"defence" yaml:"defence"`
|
||||
Speed float64 `json:"speed" yaml:"speed"`
|
||||
AggroRange float64 `json:"aggroRange" yaml:"aggroRange"`
|
||||
LeashRange float64 `json:"leashRange" yaml:"leashRange"`
|
||||
ScalePerDay float64 `json:"scalePerDay" yaml:"scalePerDay"`
|
||||
XP int64 `json:"xp" yaml:"xp"`
|
||||
AttackID string `json:"attackId" yaml:"attackId"`
|
||||
LootID string `json:"lootId" yaml:"lootId"`
|
||||
Appearance *Appearance `json:"appearance,omitempty" yaml:"appearance,omitempty"`
|
||||
ID string `json:"id" yaml:"id"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
Model string `json:"model" yaml:"model"`
|
||||
Behavior string `json:"behavior" yaml:"behavior"`
|
||||
Level int64 `json:"level" yaml:"level"`
|
||||
HP float64 `json:"hp" yaml:"hp"`
|
||||
Damage float64 `json:"damage" yaml:"damage"`
|
||||
Defence float64 `json:"defence" yaml:"defence"`
|
||||
Speed float64 `json:"speed" yaml:"speed"`
|
||||
AggroRange float64 `json:"aggroRange" yaml:"aggroRange"`
|
||||
LeashRange float64 `json:"leashRange" yaml:"leashRange"`
|
||||
ScalePerDay float64 `json:"scalePerDay" yaml:"scalePerDay"`
|
||||
XP int64 `json:"xp" yaml:"xp"`
|
||||
AttackID string `json:"attackId" yaml:"attackId"`
|
||||
LootID string `json:"lootId" yaml:"lootId"`
|
||||
}
|
||||
type MobSpawn struct {
|
||||
ID string `json:"id" yaml:"id"`
|
||||
@@ -168,6 +169,9 @@ func (c Catalog) validateCombat() error {
|
||||
}
|
||||
}
|
||||
for _, m := range v.Mobs {
|
||||
if err := ValidateAppearance(m.Appearance, "creature", "human"); err != nil {
|
||||
return err
|
||||
}
|
||||
if !identity(m.ID, m.Name, m.Description) || !slices.Contains([]string{"sentinel", "boss"}, m.Model) || !slices.Contains([]string{"aggressive", "guard", "passive"}, m.Behavior) || m.Level < 1 || m.Level > 10000 || !finiteRange(m.HP, 1, 1000000) || !finiteRange(m.Damage, 0, 100000) || !finiteRange(m.Defence, 0, 100000) || !finiteRange(m.Speed, .1, 30) || !finiteRange(m.AggroRange, 1, 128) || !finiteRange(m.LeashRange, m.AggroRange, 512) || !finiteRange(m.ScalePerDay, 0, 10) || m.XP < 0 || m.XP > 1000000000 || !attacks[m.AttackID] || (m.LootID != "" && !loot[m.LootID]) {
|
||||
return fmt.Errorf("invalid mob %q or missing attack/loot reference", m.ID)
|
||||
}
|
||||
|
||||
+17
-13
@@ -16,19 +16,20 @@ type GatheringSkill struct {
|
||||
MaxLevel int64 `json:"maxLevel" yaml:"maxLevel"`
|
||||
}
|
||||
type ResourceDefinition struct {
|
||||
ID string `json:"id" yaml:"id"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
SkillID string `json:"skillId" yaml:"skillId"`
|
||||
Model string `json:"model" yaml:"model"`
|
||||
Output string `json:"output" yaml:"output"`
|
||||
RequiredLevel int64 `json:"requiredLevel" yaml:"requiredLevel"`
|
||||
Amount int64 `json:"amount" yaml:"amount"`
|
||||
XP int64 `json:"xp" yaml:"xp"`
|
||||
Seconds float64 `json:"seconds" yaml:"seconds"`
|
||||
RespawnSeconds float64 `json:"respawnSeconds" yaml:"respawnSeconds"`
|
||||
Density int64 `json:"density" yaml:"density"`
|
||||
Biomes []string `json:"biomes" yaml:"biomes"`
|
||||
Appearance *Appearance `json:"appearance,omitempty" yaml:"appearance,omitempty"`
|
||||
ID string `json:"id" yaml:"id"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
Description string `json:"description" yaml:"description"`
|
||||
SkillID string `json:"skillId" yaml:"skillId"`
|
||||
Model string `json:"model" yaml:"model"`
|
||||
Output string `json:"output" yaml:"output"`
|
||||
RequiredLevel int64 `json:"requiredLevel" yaml:"requiredLevel"`
|
||||
Amount int64 `json:"amount" yaml:"amount"`
|
||||
XP int64 `json:"xp" yaml:"xp"`
|
||||
Seconds float64 `json:"seconds" yaml:"seconds"`
|
||||
RespawnSeconds float64 `json:"respawnSeconds" yaml:"respawnSeconds"`
|
||||
Density int64 `json:"density" yaml:"density"`
|
||||
Biomes []string `json:"biomes" yaml:"biomes"`
|
||||
}
|
||||
type BiomeDefinition struct {
|
||||
Revision int64 `json:"revision,omitempty" yaml:"revision"`
|
||||
@@ -121,6 +122,9 @@ func (g GatheringContent) Validate() error {
|
||||
biomes[b.ID] = true
|
||||
}
|
||||
for _, r := range g.Resources {
|
||||
if err := ValidateAppearance(r.Appearance, map[string]string{"tree": "tree", "ore": "rock", "herb": "plant"}[r.Model]); err != nil {
|
||||
return err
|
||||
}
|
||||
if !identity(r.ID, r.Name, r.Description) || !skills[r.SkillID] || !slices.Contains([]string{"tree", "ore", "herb"}, r.Model) || !slices.Contains([]string{"wood", "ore", "herb", "self"}, r.Output) || r.RequiredLevel < 1 || r.RequiredLevel > 10000 || r.Amount < 1 || r.Amount > 1000 || r.XP < 0 || r.XP > 1000000 || !finiteRange(r.Seconds, 0.1, 3600) || !finiteRange(r.RespawnSeconds, 1, 604800) || r.Density < 0 || r.Density > 32 || len(r.Biomes) < 1 || len(r.Biomes) > 32 {
|
||||
return fmt.Errorf("invalid resource %q", r.ID)
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ type ItemDefinition struct {
|
||||
Modifiers []StatModifier `json:"modifiers" yaml:"modifiers"`
|
||||
}
|
||||
type Catalog struct {
|
||||
Visuals []VisualPreset `json:"visuals,omitempty"`
|
||||
HousingVersion int `json:"housingVersion,omitempty"`
|
||||
Building *BuildingContent `json:"building,omitempty"`
|
||||
Powers *PowerContent `json:"powers,omitempty"`
|
||||
@@ -145,6 +146,9 @@ func (item ItemDefinition) Validate() error {
|
||||
return ValidateModifiers(item.Modifiers)
|
||||
}
|
||||
func (c Catalog) Validate() error {
|
||||
if err := c.validateVisuals(); err != nil {
|
||||
return err
|
||||
}
|
||||
if e := c.validateBuilding(); e != nil {
|
||||
return e
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
p "aeternalis/server/internal/protocol"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAppearanceRestartAndReplacement(t *testing.T) {
|
||||
w, c := fixture(t)
|
||||
a := p.Appearance{Version: 1, Family: "human", Variant: 1, Seed: 42, Height: 1, Width: 1, Detail: .5, Primary: "#d8a582", Secondary: "#493947", Accent: "#578f8b"}
|
||||
c.View.Entity.Appearance = &a
|
||||
raw, err := json.Marshal(w)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var restored World
|
||||
if err = json.Unmarshal(raw, &restored); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = restored.Restore(w.now); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
life := restored.Characters[c.View.Entity.ID]
|
||||
if life.View.Entity.Appearance == nil || *life.View.Entity.Appearance != a {
|
||||
t.Fatal("appearance lost on restart")
|
||||
}
|
||||
restored.kill(life, "test replacement")
|
||||
replacement, err := restored.Join(c.Account, "Replacement")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if replacement.View.Entity.ID == life.View.Entity.ID || replacement.View.Entity.Appearance != nil {
|
||||
t.Fatal("replacement inherited prior life's appearance")
|
||||
}
|
||||
}
|
||||
@@ -77,14 +77,14 @@ func (t *Terrain) Chunk(x, z int) p.Chunk {
|
||||
if math.Hypot(px, pz) > t.B.WorldRadius || math.Hypot(px, pz) < 25 {
|
||||
continue
|
||||
}
|
||||
c.Resources = append(c.Resources, p.Entity{ID: fmt.Sprintf("r:%d:%d:%s:%d", x, z, r.ID, i), Kind: r.Model, Name: r.Name, ResourceID: stringPtr(r.ID), SkillID: stringPtr(r.SkillID), RequiredLevel: &r.RequiredLevel, Position: t.Position(px, pz), HP: 1, MaxHP: 1, State: "available"})
|
||||
c.Resources = append(c.Resources, p.Entity{ID: fmt.Sprintf("r:%d:%d:%s:%d", x, z, r.ID, i), Kind: r.Model, Appearance: r.Appearance, Name: r.Name, ResourceID: stringPtr(r.ID), SkillID: stringPtr(r.SkillID), RequiredLevel: &r.RequiredLevel, Position: t.Position(px, pz), HP: 1, MaxHP: 1, State: "available"})
|
||||
}
|
||||
}
|
||||
if x == 0 && z == 0 {
|
||||
for i, id := range []string{"tree", "ore", "herb"} {
|
||||
for _, r := range t.B.Gathering.Resources {
|
||||
if r.ID == id {
|
||||
c.Resources = append(c.Resources, p.Entity{ID: "arrival:" + id, Kind: r.Model, Name: r.Name, ResourceID: stringPtr(id), SkillID: stringPtr(r.SkillID), RequiredLevel: &r.RequiredLevel, Position: t.Position(12+float64(i)*5, 12), HP: 1, MaxHP: 1, State: "available"})
|
||||
c.Resources = append(c.Resources, p.Entity{ID: "arrival:" + id, Kind: r.Model, Appearance: r.Appearance, Name: r.Name, ResourceID: stringPtr(id), SkillID: stringPtr(r.SkillID), RequiredLevel: &r.RequiredLevel, Position: t.Position(12+float64(i)*5, 12), HP: 1, MaxHP: 1, State: "available"})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func (w *World) newMob(id string, d content.MobDefinition, pos p.Vec3, respawn f
|
||||
scale := float64(d.Level) * (1 + w.Age()/86400*d.ScalePerDay)
|
||||
hp := d.HP * scale
|
||||
home := pos
|
||||
m := &Mob{Entity: p.Entity{ID: id, Kind: "mob", Model: stringPtr(d.Model), Name: d.Name, Position: pos, HP: hp, MaxHP: hp, State: "alive"}, Definition: &d, Home: &home, HomeX: ChunkCoord(pos.X, w.Balance.ChunkSize), HomeZ: ChunkCoord(pos.Z, w.Balance.ChunkSize), RespawnDelay: respawn, Power: d.Damage * scale}
|
||||
m := &Mob{Entity: p.Entity{ID: id, Kind: "mob", Model: stringPtr(d.Model), Appearance: d.Appearance, Name: d.Name, Position: pos, HP: hp, MaxHP: hp, State: "alive"}, Definition: &d, Home: &home, HomeX: ChunkCoord(pos.X, w.Balance.ChunkSize), HomeZ: ChunkCoord(pos.Z, w.Balance.ChunkSize), RespawnDelay: respawn, Power: d.Damage * scale}
|
||||
for _, a := range w.Balance.Combat.Attacks {
|
||||
if a.ID == d.AttackID {
|
||||
m.Attack = protocolAttack(a)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
p "aeternalis/server/internal/protocol"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
@@ -152,6 +153,8 @@ func TestCastingInterruptMissAndWeaponUnlock(t *testing.T) {
|
||||
|
||||
func TestCorpseRevivalKeepsLootAndDailyBudget(t *testing.T) {
|
||||
w, c := fixture(t)
|
||||
appearance := p.Appearance{Version: 1, Family: "human", Variant: 2, Seed: 42, Height: 1, Width: 1, Detail: .5, Primary: "#d8a582", Secondary: "#493947", Accent: "#578f8b"}
|
||||
c.View.Entity.Appearance = &appearance
|
||||
rescuer, e := w.Join("rescuer", "Rescuer")
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
@@ -179,6 +182,9 @@ func TestCorpseRevivalKeepsLootAndDailyBudget(t *testing.T) {
|
||||
if len(c.View.Inventory) != 0 || len(c.View.Items) != 0 || c.DailySeconds != 123 || rescuer.View.Inventory["wood"] != 7 || rescuer.View.Inventory["revival_stone"] != 1 {
|
||||
t.Fatal("revival recreated loot or daily time")
|
||||
}
|
||||
if !reflect.DeepEqual(c.View.Entity.Appearance, &appearance) {
|
||||
t.Fatal("revival changed character appearance")
|
||||
}
|
||||
if _, e = w.Revive(rescuer, corpse, "item"); e == nil || rescuer.View.Inventory["revival_stone"] != 1 {
|
||||
t.Fatal("revived twice")
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ type ContentCatalog struct {
|
||||
Stats ContentStatsRules `json:"stats"`
|
||||
Titles []TitleDefinition `json:"titles"`
|
||||
Version int64 `json:"version"`
|
||||
Visuals []VisualPreset `json:"visuals,omitempty"`
|
||||
}
|
||||
|
||||
type BuildingContent struct {
|
||||
@@ -94,22 +95,36 @@ type LootEntry struct {
|
||||
}
|
||||
|
||||
type MobDefinition struct {
|
||||
AggroRange float64 `json:"aggroRange"`
|
||||
AttackID string `json:"attackId"`
|
||||
Behavior string `json:"behavior"`
|
||||
Damage float64 `json:"damage"`
|
||||
Defence float64 `json:"defence"`
|
||||
Description string `json:"description"`
|
||||
HP float64 `json:"hp"`
|
||||
ID string `json:"id"`
|
||||
LeashRange float64 `json:"leashRange"`
|
||||
Level int64 `json:"level"`
|
||||
LootID string `json:"lootId"`
|
||||
Model string `json:"model"`
|
||||
Name string `json:"name"`
|
||||
ScalePerDay float64 `json:"scalePerDay"`
|
||||
Speed float64 `json:"speed"`
|
||||
XP int64 `json:"xp"`
|
||||
AggroRange float64 `json:"aggroRange"`
|
||||
Appearance *Appearance `json:"appearance,omitempty"`
|
||||
AttackID string `json:"attackId"`
|
||||
Behavior string `json:"behavior"`
|
||||
Damage float64 `json:"damage"`
|
||||
Defence float64 `json:"defence"`
|
||||
Description string `json:"description"`
|
||||
HP float64 `json:"hp"`
|
||||
ID string `json:"id"`
|
||||
LeashRange float64 `json:"leashRange"`
|
||||
Level int64 `json:"level"`
|
||||
LootID string `json:"lootId"`
|
||||
Model string `json:"model"`
|
||||
Name string `json:"name"`
|
||||
ScalePerDay float64 `json:"scalePerDay"`
|
||||
Speed float64 `json:"speed"`
|
||||
XP int64 `json:"xp"`
|
||||
}
|
||||
|
||||
type Appearance struct {
|
||||
Accent string `json:"accent"`
|
||||
Detail float64 `json:"detail"`
|
||||
Family string `json:"family"`
|
||||
Height float64 `json:"height"`
|
||||
Primary string `json:"primary"`
|
||||
Secondary string `json:"secondary"`
|
||||
Seed int64 `json:"seed"`
|
||||
Variant int64 `json:"variant"`
|
||||
Version int64 `json:"version"`
|
||||
Width float64 `json:"width"`
|
||||
}
|
||||
|
||||
type MobSpawn struct {
|
||||
@@ -224,19 +239,20 @@ type ItemUseEffect struct {
|
||||
}
|
||||
|
||||
type ResourceDefinition struct {
|
||||
Amount int64 `json:"amount"`
|
||||
Biomes []string `json:"biomes"`
|
||||
Density int64 `json:"density"`
|
||||
Description string `json:"description"`
|
||||
ID string `json:"id"`
|
||||
Model string `json:"model"`
|
||||
Name string `json:"name"`
|
||||
Output string `json:"output"`
|
||||
RequiredLevel int64 `json:"requiredLevel"`
|
||||
RespawnSeconds float64 `json:"respawnSeconds"`
|
||||
Seconds float64 `json:"seconds"`
|
||||
SkillID string `json:"skillId"`
|
||||
XP int64 `json:"xp"`
|
||||
Amount int64 `json:"amount"`
|
||||
Appearance *Appearance `json:"appearance,omitempty"`
|
||||
Biomes []string `json:"biomes"`
|
||||
Density int64 `json:"density"`
|
||||
Description string `json:"description"`
|
||||
ID string `json:"id"`
|
||||
Model string `json:"model"`
|
||||
Name string `json:"name"`
|
||||
Output string `json:"output"`
|
||||
RequiredLevel int64 `json:"requiredLevel"`
|
||||
RespawnSeconds float64 `json:"respawnSeconds"`
|
||||
Seconds float64 `json:"seconds"`
|
||||
SkillID string `json:"skillId"`
|
||||
XP int64 `json:"xp"`
|
||||
}
|
||||
|
||||
type ItemDefinition struct {
|
||||
@@ -340,6 +356,13 @@ type TitleEffects struct {
|
||||
MoveSpeed float64 `json:"moveSpeed"`
|
||||
}
|
||||
|
||||
type VisualPreset struct {
|
||||
Appearance Appearance `json:"appearance"`
|
||||
Description string `json:"description"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type ContentChange struct {
|
||||
Attack *CombatAttackDraft `json:"attack,omitempty"`
|
||||
Biome *BiomeDefinitionDraft `json:"biome,omitempty"`
|
||||
@@ -367,6 +390,7 @@ type ContentChange struct {
|
||||
Stats *ContentStatsRules `json:"stats,omitempty"`
|
||||
TargetID *string `json:"targetId,omitempty"`
|
||||
Title *TitleDraft `json:"title,omitempty"`
|
||||
Visual *VisualPresetDraft `json:"visual,omitempty"`
|
||||
Weapon *GatheringSkillDraft `json:"weapon,omitempty"`
|
||||
}
|
||||
|
||||
@@ -481,22 +505,23 @@ type LootTableDraft struct {
|
||||
}
|
||||
|
||||
type MobDefinitionDraft struct {
|
||||
AggroRange float64 `json:"aggroRange"`
|
||||
AttackID string `json:"attackId"`
|
||||
Behavior string `json:"behavior"`
|
||||
Damage float64 `json:"damage"`
|
||||
Defence float64 `json:"defence"`
|
||||
Description string `json:"description"`
|
||||
HP float64 `json:"hp"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
LeashRange float64 `json:"leashRange"`
|
||||
Level int64 `json:"level"`
|
||||
LootID string `json:"lootId"`
|
||||
Model string `json:"model"`
|
||||
Name string `json:"name"`
|
||||
ScalePerDay float64 `json:"scalePerDay"`
|
||||
Speed float64 `json:"speed"`
|
||||
XP int64 `json:"xp"`
|
||||
AggroRange float64 `json:"aggroRange"`
|
||||
Appearance *Appearance `json:"appearance,omitempty"`
|
||||
AttackID string `json:"attackId"`
|
||||
Behavior string `json:"behavior"`
|
||||
Damage float64 `json:"damage"`
|
||||
Defence float64 `json:"defence"`
|
||||
Description string `json:"description"`
|
||||
HP float64 `json:"hp"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
LeashRange float64 `json:"leashRange"`
|
||||
Level int64 `json:"level"`
|
||||
LootID string `json:"lootId"`
|
||||
Model string `json:"model"`
|
||||
Name string `json:"name"`
|
||||
ScalePerDay float64 `json:"scalePerDay"`
|
||||
Speed float64 `json:"speed"`
|
||||
XP int64 `json:"xp"`
|
||||
}
|
||||
|
||||
type PowerDraft struct {
|
||||
@@ -530,19 +555,20 @@ type RequirementSetDraft struct {
|
||||
}
|
||||
|
||||
type ResourceDefinitionDraft struct {
|
||||
Amount int64 `json:"amount"`
|
||||
Biomes []string `json:"biomes"`
|
||||
Density int64 `json:"density"`
|
||||
Description string `json:"description"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
Model string `json:"model"`
|
||||
Name string `json:"name"`
|
||||
Output string `json:"output"`
|
||||
RequiredLevel int64 `json:"requiredLevel"`
|
||||
RespawnSeconds float64 `json:"respawnSeconds"`
|
||||
Seconds float64 `json:"seconds"`
|
||||
SkillID string `json:"skillId"`
|
||||
XP int64 `json:"xp"`
|
||||
Amount int64 `json:"amount"`
|
||||
Appearance *Appearance `json:"appearance,omitempty"`
|
||||
Biomes []string `json:"biomes"`
|
||||
Density int64 `json:"density"`
|
||||
Description string `json:"description"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
Model string `json:"model"`
|
||||
Name string `json:"name"`
|
||||
Output string `json:"output"`
|
||||
RequiredLevel int64 `json:"requiredLevel"`
|
||||
RespawnSeconds float64 `json:"respawnSeconds"`
|
||||
Seconds float64 `json:"seconds"`
|
||||
SkillID string `json:"skillId"`
|
||||
XP int64 `json:"xp"`
|
||||
}
|
||||
|
||||
type MobSpawnDraft struct {
|
||||
@@ -568,6 +594,13 @@ type TitleDraft struct {
|
||||
Scope string `json:"scope"`
|
||||
}
|
||||
|
||||
type VisualPresetDraft struct {
|
||||
Appearance Appearance `json:"appearance"`
|
||||
Description string `json:"description"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type ContentPreview struct {
|
||||
BasedOnVersion int64 `json:"basedOnVersion"`
|
||||
ProposedVersion int64 `json:"proposedVersion"`
|
||||
@@ -635,21 +668,22 @@ type HouseSummary struct {
|
||||
}
|
||||
|
||||
type Entity struct {
|
||||
Depth *float64 `json:"depth,omitempty"`
|
||||
HP float64 `json:"hp"`
|
||||
Height *float64 `json:"height,omitempty"`
|
||||
ID string `json:"id"`
|
||||
Kind string `json:"kind"`
|
||||
MaxHP float64 `json:"maxHp"`
|
||||
Model *string `json:"model,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Position Vec3 `json:"position"`
|
||||
Radius *float64 `json:"radius,omitempty"`
|
||||
RequiredLevel *int64 `json:"requiredLevel,omitempty"`
|
||||
ResourceID *string `json:"resourceId,omitempty"`
|
||||
SkillID *string `json:"skillId,omitempty"`
|
||||
State string `json:"state"`
|
||||
Width *float64 `json:"width,omitempty"`
|
||||
Appearance *Appearance `json:"appearance,omitempty"`
|
||||
Depth *float64 `json:"depth,omitempty"`
|
||||
HP float64 `json:"hp"`
|
||||
Height *float64 `json:"height,omitempty"`
|
||||
ID string `json:"id"`
|
||||
Kind string `json:"kind"`
|
||||
MaxHP float64 `json:"maxHp"`
|
||||
Model *string `json:"model,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Position Vec3 `json:"position"`
|
||||
Radius *float64 `json:"radius,omitempty"`
|
||||
RequiredLevel *int64 `json:"requiredLevel,omitempty"`
|
||||
ResourceID *string `json:"resourceId,omitempty"`
|
||||
SkillID *string `json:"skillId,omitempty"`
|
||||
State string `json:"state"`
|
||||
Width *float64 `json:"width,omitempty"`
|
||||
}
|
||||
|
||||
type Vec3 struct {
|
||||
|
||||
@@ -17,6 +17,7 @@ var ErrCatalogInvalid = errors.New("invalid catalog change")
|
||||
var catalogRequestID = regexp.MustCompile(`^[a-f0-9-]{32,36}$`)
|
||||
|
||||
type CatalogChange struct {
|
||||
Visual *content.VisualPreset `json:"visual,omitempty"`
|
||||
Building *content.BuildingDefinition `json:"building,omitempty"`
|
||||
Power *content.PowerDefinition `json:"power,omitempty"`
|
||||
Weapon *content.GatheringSkill `json:"weapon,omitempty"`
|
||||
@@ -54,6 +55,9 @@ type CatalogResult struct {
|
||||
// Explicit definition IDs are reserved for trusted seed/import code. Browser
|
||||
// publications omit them; the server assigns an ID after resolving request replay.
|
||||
func (c CatalogChange) HasDefinitionID() bool {
|
||||
if c.Visual != nil && c.Visual.ID != "" {
|
||||
return true
|
||||
}
|
||||
return (c.Building != nil && c.Building.ID != "") || (c.Power != nil && c.Power.ID != "") || (c.Weapon != nil && c.Weapon.ID != "") || (c.CraftRecipe != nil && c.CraftRecipe.ID != "") || (c.CraftProfession != nil && c.CraftProfession.ID != "") || (c.CraftMaterial != nil && c.CraftMaterial.ID != "") || (c.Attack != nil && c.Attack.ID != "") || (c.Mob != nil && c.Mob.ID != "") || (c.Loot != nil && c.Loot.ID != "") || (c.Spawn != nil && c.Spawn.ID != "") || (c.GatheringSkill != nil && c.GatheringSkill.ID != "") || (c.Resource != nil && c.Resource.ID != "") || (c.Biome != nil && c.Biome.ID != "") || (c.Consumable != nil && c.Consumable.ID != "") || (c.Title != nil && c.Title.ID != "") || (c.Item != nil && c.Item.ID != "") || (c.RequirementSet != nil && c.RequirementSet.ID != "") || (c.EffectSet != nil && c.EffectSet.ID != "")
|
||||
}
|
||||
|
||||
@@ -196,12 +200,17 @@ func (c CatalogChange) validate() error {
|
||||
}
|
||||
valid := false
|
||||
count := 0
|
||||
if c.Visual != nil {
|
||||
count++
|
||||
}
|
||||
for _, present := range []bool{c.Building != nil, c.Power != nil, c.Weapon != nil, c.CraftRecipe != nil, c.CraftProfession != nil, c.CraftMaterial != nil, c.CraftRules != nil, c.Attack != nil, c.Mob != nil, c.Loot != nil, c.Spawn != nil, c.GatheringSkill != nil, c.Resource != nil, c.Biome != nil, c.Consumable != nil, c.Title != nil, c.Item != nil, c.Stats != nil, c.RequirementSet != nil, c.EffectSet != nil} {
|
||||
if present {
|
||||
count++
|
||||
}
|
||||
}
|
||||
switch c.Op {
|
||||
case "create-visual":
|
||||
valid = c.Visual != nil
|
||||
case "create-building":
|
||||
valid = c.Building != nil
|
||||
case "create-power":
|
||||
|
||||
@@ -35,6 +35,9 @@ func (d *DB) PreviewCatalog(ctx context.Context, change CatalogChange) (CatalogP
|
||||
}
|
||||
// Preview validates a provisional identity but does not reserve or expose it.
|
||||
if !change.HasDefinitionID() {
|
||||
if resolved.Visual != nil {
|
||||
resolved.Visual.ID = ""
|
||||
}
|
||||
if resolved.Building != nil {
|
||||
resolved.Building.ID = ""
|
||||
}
|
||||
@@ -152,6 +155,14 @@ func buildCatalog(c content.Catalog, change CatalogChange) (content.Catalog, str
|
||||
building := *c.Building
|
||||
c.Building = &building
|
||||
switch change.Op {
|
||||
case "create-visual":
|
||||
v := *change.Visual
|
||||
if v.ID == "" {
|
||||
v.ID = "visual_" + game.ID()
|
||||
}
|
||||
resolved.Visual = &v
|
||||
c.Visuals = append(slices.Clone(c.Visuals), v)
|
||||
target = v.ID
|
||||
case "create-building":
|
||||
v := *change.Building
|
||||
if v.ID == "" {
|
||||
|
||||
@@ -64,6 +64,7 @@ func runTravelTests(t *testing.T, dsn string) {
|
||||
c.View.Experience = 7
|
||||
c.View.StatPoints = 20
|
||||
c.DailySeconds = 123
|
||||
c.View.Entity.Appearance = &content.Appearance{Version: 1, Family: "human", Variant: 2, Seed: 42, Height: 1, Width: 1, Detail: .5, Primary: "#d8a582", Secondary: "#493947", Accent: "#578f8b"}
|
||||
c.WorldsSurvived = 2
|
||||
if e = source.AdminItems(c, "grant-item", "spear:1"); e != nil {
|
||||
t.Fatal(e)
|
||||
@@ -183,7 +184,7 @@ func runTravelTests(t *testing.T, dsn string) {
|
||||
if copies != 1 {
|
||||
t.Fatalf("arrival copies: %d", copies)
|
||||
}
|
||||
if !reflect.DeepEqual(arrived.View.Powers, c.View.Powers) || !reflect.DeepEqual(arrived.View.Weapons, c.View.Weapons) || !reflect.DeepEqual(arrived.View.Items, c.View.Items) || !reflect.DeepEqual(arrived.View.Gathering, c.View.Gathering) || !reflect.DeepEqual(arrived.View.AllocatedStats, c.View.AllocatedStats) {
|
||||
if !reflect.DeepEqual(arrived.View.Entity.Appearance, c.View.Entity.Appearance) || !reflect.DeepEqual(arrived.View.Powers, c.View.Powers) || !reflect.DeepEqual(arrived.View.Weapons, c.View.Weapons) || !reflect.DeepEqual(arrived.View.Items, c.View.Items) || !reflect.DeepEqual(arrived.View.Gathering, c.View.Gathering) || !reflect.DeepEqual(arrived.View.AllocatedStats, c.View.AllocatedStats) {
|
||||
t.Fatal("item identities or character progression changed during travel")
|
||||
}
|
||||
if arrived.View.Inventory["escape_stone"] != 1 || arrived.View.Inventory["wood"] != 31 || arrived.View.Level != 3 || arrived.View.Experience != 7 || arrived.View.StatPoints != 20 || arrived.View.Skills["combat"] != 29 || arrived.DailySeconds != 123 || arrived.WorldsSurvived != 2 || arrived.View.Entity.ID != id || !reflect.DeepEqual(arrived.View.Titles, c.View.Titles) {
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"aeternalis/server/content"
|
||||
"aeternalis/server/internal/game"
|
||||
"context"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestVisualLibraryPublicationReplayAndResourceCompatibility(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
dsn := "file:" + filepath.ToSlash(filepath.Join(t.TempDir(), "visual.db"))
|
||||
db, err := Open(ctx, dsn)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { db.Close() }()
|
||||
c, err := db.Catalog(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
a := content.Appearance{Version: 1, Family: "tree", Variant: 3, Seed: 42, Height: 1, Width: 1, Detail: .5, Primary: "#80a77a", Secondary: "#785443", Accent: "#d8ae85"}
|
||||
change := CatalogChange{ID: game.ID(), ExpectedVersion: c.Version, Op: "create-visual", Reason: "Create blossom design", Visual: &content.VisualPreset{Name: "Blossom", Appearance: a}}
|
||||
preview, err := db.PreviewCatalog(ctx, change)
|
||||
if err != nil || preview.Resolved.HasDefinitionID() {
|
||||
t.Fatal("preview reserved identity", err)
|
||||
}
|
||||
result, err := db.PublishCatalog(ctx, "artist", change)
|
||||
if err != nil || result.ID == "" {
|
||||
t.Fatal(err)
|
||||
}
|
||||
retry, err := db.PublishCatalog(ctx, "artist", change)
|
||||
if err != nil || retry != result {
|
||||
t.Fatal("replay changed design identity", err)
|
||||
}
|
||||
if change.Visual.ID != "" {
|
||||
t.Fatal("publication mutated submitted design")
|
||||
}
|
||||
if err = db.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
db, err = Open(ctx, dsn)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c, err = db.Catalog(ctx)
|
||||
if err != nil || len(c.Visuals) != 1 || c.Visuals[0].Appearance != a {
|
||||
t.Fatal("visual not durable", err)
|
||||
}
|
||||
r := c.Gathering.Resources[0]
|
||||
r.ID = ""
|
||||
r.Name = "Blossom tree"
|
||||
r.Model = "tree"
|
||||
r.Appearance = &a
|
||||
publication := CatalogChange{ID: game.ID(), ExpectedVersion: c.Version, Op: "create-resource", Reason: "Use reusable blossom design", Resource: &r}
|
||||
if _, err = db.PublishCatalog(ctx, "artist", publication); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c, err = db.Catalog(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r.Model = "ore"
|
||||
publication.ID = game.ID()
|
||||
publication.ExpectedVersion = c.Version
|
||||
if _, err = db.PublishCatalog(ctx, "artist", publication); err == nil {
|
||||
t.Fatal("tree appearance assigned to ore")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package transport
|
||||
|
||||
import (
|
||||
"aeternalis/server/content"
|
||||
p "aeternalis/server/internal/protocol"
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (h *HTTP) appearanceRoutes(mux *http.ServeMux) {
|
||||
mux.HandleFunc("POST /api/appearance", func(w http.ResponseWriter, r *http.Request) {
|
||||
account, err := h.auth.account(r)
|
||||
if err != nil {
|
||||
fail(w, 401, "sign in required")
|
||||
return
|
||||
}
|
||||
var appearance p.Appearance
|
||||
if decode(w, r, &appearance) != nil || content.ValidateAppearance(&appearance, "human") != nil {
|
||||
fail(w, 400, "invalid character appearance")
|
||||
return
|
||||
}
|
||||
h.s.mu.Lock()
|
||||
defer h.s.mu.Unlock()
|
||||
if !h.s.ready.Load() {
|
||||
fail(w, 503, "world unavailable")
|
||||
return
|
||||
}
|
||||
c := h.s.world.ForAccount(account)
|
||||
if c == nil || (c.View.Entity.State != "alive" && c.View.Entity.State != "eligible") {
|
||||
fail(w, 409, "no living character in this world")
|
||||
return
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second)
|
||||
defer cancel()
|
||||
active, err := h.auth.db.ActiveCharacter(ctx, account)
|
||||
if err != nil {
|
||||
fail(w, 503, "character registry unavailable")
|
||||
return
|
||||
}
|
||||
if active == nil || active.WorldID != h.s.world.ID || active.ID != c.View.Entity.ID || active.State == "transit" {
|
||||
fail(w, 409, "character belongs to another world or is traveling")
|
||||
return
|
||||
}
|
||||
previous := c.View.Entity.Appearance
|
||||
c.View.Entity.Appearance = &appearance
|
||||
if err := h.s.persist(ctx, ""); err != nil {
|
||||
c.View.Entity.Appearance = previous
|
||||
fail(w, 503, "appearance could not be saved")
|
||||
return
|
||||
}
|
||||
respond(w, 200, map[string]bool{"saved": true})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package transport
|
||||
|
||||
import (
|
||||
"aeternalis/server/content"
|
||||
"aeternalis/server/internal/game"
|
||||
"aeternalis/server/internal/store"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestCharacterAppearanceOwnershipAndDurability(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
db, err := store.Open(ctx, "file:"+filepath.ToSlash(filepath.Join(t.TempDir(), "appearance.db")))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
b, _ := content.Load()
|
||||
world := game.New("appearance", 1, time.Now(), b)
|
||||
lease, _, err := db.Acquire(ctx, world)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
svc := NewService(world, lease)
|
||||
a := content.Appearance{Version: 1, Family: "human", Variant: 3, Seed: 42, Height: 1, Width: 1, Detail: .5, Primary: "#d8a582", Secondary: "#493947", Accent: "#578f8b"}
|
||||
view, err := svc.join(ctx, "artist", "Artist", "", &a)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if view.Entity.Appearance == nil || *view.Entity.Appearance != a {
|
||||
t.Fatal("new character appearance missing")
|
||||
}
|
||||
other := a
|
||||
other.Primary = "#ffffff"
|
||||
if _, err = svc.join(ctx, "artist", "Artist", "", &other); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if *world.ForAccount("artist").View.Entity.Appearance != a {
|
||||
t.Fatal("join retry overwrote appearance")
|
||||
}
|
||||
auth, _ := NewAuth(ctx, db, true, "http://127.0.0.1", "", "", "")
|
||||
server := httptest.NewServer(NewHTTP(svc, auth, t.TempDir(), nil).Handler())
|
||||
defer server.Close()
|
||||
auth.base = server.URL
|
||||
token := game.ID() + game.ID()
|
||||
if err = db.CreateSession(ctx, hash(token), "artist"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
request := func(value any, cookie, origin string) int {
|
||||
t.Helper()
|
||||
raw, _ := json.Marshal(value)
|
||||
r, _ := http.NewRequest("POST", server.URL+"/api/appearance", strings.NewReader(string(raw)))
|
||||
r.Header.Set("Origin", origin)
|
||||
if cookie != "" {
|
||||
r.AddCookie(&http.Cookie{Name: auth.cookieName(), Value: cookie})
|
||||
}
|
||||
resp, err := server.Client().Do(r)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
return resp.StatusCode
|
||||
}
|
||||
if request(other, "", server.URL) != 401 || request(other, token, "https://elsewhere.example") != 403 {
|
||||
t.Fatal("appearance auth boundary bypassed")
|
||||
}
|
||||
bad := other
|
||||
bad.Family = "creature"
|
||||
if request(bad, token, server.URL) != 400 {
|
||||
t.Fatal("player could choose creature")
|
||||
}
|
||||
before := world.ForAccount("artist").View.Stats["movementSpeed"]
|
||||
if request(other, token, server.URL) != 200 {
|
||||
t.Fatal("appearance save rejected")
|
||||
}
|
||||
record, err := db.ActiveCharacter(ctx, "artist")
|
||||
if err != nil || *record.Character.View.Entity.Appearance != other || record.Character.View.Stats["movementSpeed"] != before {
|
||||
t.Fatal("appearance not durable or changed stats", err)
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,7 @@ func (h *HTTP) Handler() http.Handler {
|
||||
h.powerRoutes(mux)
|
||||
h.housingRoutes(mux)
|
||||
h.catalogRoutes(mux)
|
||||
h.appearanceRoutes(mux)
|
||||
mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) {
|
||||
if !h.s.ready.Load() {
|
||||
fail(w, 503, "world frozen")
|
||||
@@ -196,8 +197,9 @@ func (h *HTTP) Handler() http.Handler {
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
Name string `json:"name"`
|
||||
Passage string `json:"passage"`
|
||||
Name string `json:"name"`
|
||||
Passage string `json:"passage"`
|
||||
Appearance *p.Appearance `json:"appearance,omitempty"`
|
||||
}
|
||||
if decode(w, r, &req) != nil {
|
||||
fail(w, 400, "invalid request")
|
||||
@@ -208,7 +210,7 @@ func (h *HTTP) Handler() http.Handler {
|
||||
fail(w, 400, "Name must be 2-24 letters, numbers, spaces, or hyphens.")
|
||||
return
|
||||
}
|
||||
c, err := h.s.join(r.Context(), account, req.Name, req.Passage)
|
||||
c, err := h.s.join(r.Context(), account, req.Name, req.Passage, req.Appearance)
|
||||
if err != nil {
|
||||
fail(w, 409, err.Error())
|
||||
return
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"aeternalis/server/content"
|
||||
"aeternalis/server/internal/game"
|
||||
p "aeternalis/server/internal/protocol"
|
||||
"aeternalis/server/internal/store"
|
||||
@@ -126,7 +127,7 @@ func (s *Service) Stop(ctx context.Context) error {
|
||||
}
|
||||
return s.lease.Release(ctx)
|
||||
}
|
||||
func (s *Service) join(ctx context.Context, account, name, claim string) (p.Character, error) {
|
||||
func (s *Service) join(ctx context.Context, account, name, claim string, appearance ...*p.Appearance) (p.Character, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if !s.ready.Load() {
|
||||
@@ -152,6 +153,14 @@ func (s *Service) join(ctx context.Context, account, name, claim string) (p.Char
|
||||
}
|
||||
}
|
||||
existing := s.world.ForAccount(account)
|
||||
var chosen *p.Appearance
|
||||
if len(appearance) > 0 && appearance[0] != nil {
|
||||
if err := content.ValidateAppearance(appearance[0], "human"); err != nil {
|
||||
return p.Character{}, err
|
||||
}
|
||||
copy := *appearance[0]
|
||||
chosen = ©
|
||||
}
|
||||
if claim != "" {
|
||||
c, err = s.lease.DB.ReadPassage(ctx, claim, account)
|
||||
if err != nil {
|
||||
@@ -166,6 +175,9 @@ func (s *Service) join(ctx context.Context, account, name, claim string) (p.Char
|
||||
return p.Character{}, err
|
||||
}
|
||||
}
|
||||
if existing == nil && chosen != nil {
|
||||
c.View.Entity.Appearance = chosen
|
||||
}
|
||||
if err = s.lease.Save(ctx, s.world, claim); err != nil {
|
||||
if errors.Is(err, store.ErrLivingCharacter) {
|
||||
if existing == nil {
|
||||
|
||||
Reference in New Issue
Block a user