Add anatomical character customization at initial creation
This commit is contained in:
@@ -1,36 +1,42 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"aeternalis/server/content"
|
||||
p "aeternalis/server/internal/protocol"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"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")
|
||||
for _, a := range []*p.Appearance{
|
||||
{Version: 1, Family: "human", Variant: 1, Seed: 42, Height: 1, Width: 1, Detail: .5, Primary: "#d8a582", Secondary: "#493947", Accent: "#578f8b"},
|
||||
content.DefaultCharacterAppearance(),
|
||||
} {
|
||||
w, c := fixture(t)
|
||||
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 !reflect.DeepEqual(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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
p "aeternalis/server/internal/protocol"
|
||||
"aeternalis/server/content"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
@@ -153,7 +153,7 @@ 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"}
|
||||
appearance := *content.DefaultCharacterAppearance()
|
||||
c.View.Entity.Appearance = &appearance
|
||||
rescuer, e := w.Join("rescuer", "Rescuer")
|
||||
if e != nil {
|
||||
|
||||
Reference in New Issue
Block a user