Add spells, weapon abilities, and durable corpse resurrection
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"aeternalis/server/content"
|
||||
p "aeternalis/server/internal/protocol"
|
||||
"errors"
|
||||
"strconv"
|
||||
@@ -30,6 +31,11 @@ func (w *World) AdminItems(c *Character, op, value string) error {
|
||||
}
|
||||
if op == "grant-item" {
|
||||
known := false
|
||||
for key := range (content.Catalog{Powers: w.Balance.Powers}).PowerItems() {
|
||||
if key == id {
|
||||
known = true
|
||||
}
|
||||
}
|
||||
if w.Balance.Gathering != nil {
|
||||
for _, r := range w.Balance.Gathering.Resources {
|
||||
if r.Output == "self" && r.ID == id {
|
||||
|
||||
@@ -11,6 +11,8 @@ import (
|
||||
)
|
||||
|
||||
type Projectile struct {
|
||||
Credit *CombatCredit `json:"credit,omitempty"`
|
||||
MovingAura bool `json:"movingAura"`
|
||||
Target string `json:"target"`
|
||||
ID string `json:"id"`
|
||||
Source string `json:"source"`
|
||||
@@ -101,6 +103,9 @@ func (w *World) terrainHit(a, b p.Vec3) (p.Vec3, bool) {
|
||||
return b, false
|
||||
}
|
||||
func (w *World) attack(c *Character, target string) error {
|
||||
if c.PendingCast != nil {
|
||||
return errors.New("finish or cancel the current cast")
|
||||
}
|
||||
if !w.AllowsXP() {
|
||||
return errors.New("combat is unavailable here")
|
||||
}
|
||||
@@ -147,7 +152,7 @@ func (w *World) attack(c *Character, target string) error {
|
||||
c.AttackReadyAt = w.Age() + a.Cooldown
|
||||
c.View.Stamina -= a.Stamina
|
||||
w.dirty = true
|
||||
shot := Projectile{ID: w.combatID("projectile"), Source: c.View.Entity.ID, Player: true, Target: target, Position: from, Destination: to, Attack: a, Power: power}
|
||||
shot := Projectile{Credit: &CombatCredit{Weapon: w.weaponType(c)}, ID: w.combatID("projectile"), Source: c.View.Entity.ID, Player: true, Target: target, Position: from, Destination: to, Attack: a, Power: power}
|
||||
if a.Delivery == "projectile" {
|
||||
w.Projectiles[shot.ID] = &shot
|
||||
w.projectileVisual(shot, "launch", "")
|
||||
@@ -218,6 +223,9 @@ func (w *World) combatHit(shot Projectile, target string) {
|
||||
return
|
||||
}
|
||||
if healing && shot.Player {
|
||||
if shot.Power > 0 && c.View.Entity.HP < c.View.Entity.MaxHP {
|
||||
w.awardCombatCredit(shot)
|
||||
}
|
||||
c.View.Entity.HP = math.Min(c.View.Entity.MaxHP, c.View.Entity.HP+shot.Power)
|
||||
} else if !healing && !shot.Player {
|
||||
w.damageCharacter(c, shot.Power)
|
||||
@@ -235,6 +243,9 @@ func (w *World) combatHit(shot Projectile, target string) {
|
||||
if healing && !shot.Player {
|
||||
w.BossHP = math.Min(w.Balance.BossHp, w.BossHP+shot.Power)
|
||||
} else if !healing && shot.Player {
|
||||
if shot.Power > 0 {
|
||||
w.awardCombatCredit(shot)
|
||||
}
|
||||
w.damageBoss(w.Characters[shot.Source], shot.Power)
|
||||
}
|
||||
w.dirty = true
|
||||
@@ -251,6 +262,9 @@ func (w *World) combatHit(shot Projectile, target string) {
|
||||
if m.Definition != nil {
|
||||
defence = m.Definition.Defence
|
||||
}
|
||||
if shot.Power > defence {
|
||||
w.awardCombatCredit(shot)
|
||||
}
|
||||
m.Entity.HP = math.Max(0, m.Entity.HP-math.Max(0, shot.Power-defence))
|
||||
m.Target = shot.Source
|
||||
if m.Entity.HP == 0 {
|
||||
@@ -341,6 +355,11 @@ func (w *World) updateCombat(dt float64) {
|
||||
w.dirty = true
|
||||
continue
|
||||
}
|
||||
if area.MovingAura {
|
||||
if c := w.Characters[area.Source]; c != nil {
|
||||
area.Position = body(c.View.Entity.Position)
|
||||
}
|
||||
}
|
||||
if w.Age() >= area.NextAt {
|
||||
w.areaPulse(area.Projectile)
|
||||
area.NextAt = w.Age() + area.Attack.Interval
|
||||
|
||||
@@ -135,7 +135,7 @@ func TestCraftedStackSplitDeathLootAndReplacement(t *testing.T) {
|
||||
t.Fatal("pickup changed crafter")
|
||||
}
|
||||
w.kill(c, "test")
|
||||
corpse := w.Corpses["corpse:"+c.View.Entity.ID]
|
||||
corpse := w.Corpses[c.RevivalCorpse]
|
||||
if len(c.View.CraftedStacks) != 0 || len(corpse.CraftedStacks) != 1 {
|
||||
t.Fatal("death duplicated crafted stock")
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ func (w *World) addInventoryItems(inventory *map[string]int64, items *[]p.ItemIn
|
||||
created := make([]p.ItemInstance, 0, int(quantity))
|
||||
for n := int64(0); n < quantity; n++ {
|
||||
item := p.ItemInstance{ID: ID(), DefinitionID: definition.ID, Name: definition.Name, Description: definition.Description, Slot: definition.Slot, Weight: definition.Weight,
|
||||
Requirements: p.ItemRequirements{Level: definition.Requirements.Level, Stats: map[string]float64{}, Titles: append([]string{}, definition.Requirements.Titles...)}, Modifiers: []p.StatModifier{}}
|
||||
WeaponType: stringPtr(definition.WeaponType), Requirements: p.ItemRequirements{Level: definition.Requirements.Level, Stats: map[string]float64{}, Titles: append([]string{}, definition.Requirements.Titles...)}, Modifiers: []p.StatModifier{}}
|
||||
for stat, value := range definition.Requirements.Stats {
|
||||
item.Requirements.Stats[stat] = value
|
||||
}
|
||||
@@ -352,7 +352,13 @@ func (w *World) lootCorpse(c *Character, target string) error {
|
||||
c.View.Inventory[name] += quantity
|
||||
}
|
||||
c.View.Items = append(c.View.Items, corpse.Items...)
|
||||
delete(w.Corpses, target)
|
||||
if corpse.CharacterID != "" {
|
||||
corpse.Inventory = map[string]int64{}
|
||||
corpse.Items = []p.ItemInstance{}
|
||||
corpse.CraftedStacks = nil
|
||||
} else {
|
||||
delete(w.Corpses, target)
|
||||
}
|
||||
w.RefreshStats(c)
|
||||
w.dirty = true
|
||||
return nil
|
||||
|
||||
@@ -125,7 +125,7 @@ func TestEquipmentDeathDropLootAndRestart(t *testing.T) {
|
||||
}
|
||||
count := len(survivor.View.Items)
|
||||
next.kill(survivor, "test death")
|
||||
corpse := next.Corpses["corpse:"+survivor.View.Entity.ID]
|
||||
corpse := next.Corpses[survivor.RevivalCorpse]
|
||||
if len(corpse.Items) != count || len(survivor.View.Items) != 0 || len(survivor.View.Equipment) != 0 {
|
||||
t.Fatal("death duplicated/lost items")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,370 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"aeternalis/server/content"
|
||||
p "aeternalis/server/internal/protocol"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"math"
|
||||
"slices"
|
||||
)
|
||||
|
||||
type PendingCast struct {
|
||||
Power string `json:"power"`
|
||||
Target string `json:"target"`
|
||||
Origin p.Vec3 `json:"origin"`
|
||||
Finish float64 `json:"finish"`
|
||||
}
|
||||
type CombatCredit struct {
|
||||
Power string `json:"power"`
|
||||
Weapon string `json:"weapon"`
|
||||
Rewarded bool `json:"rewarded"`
|
||||
}
|
||||
|
||||
func (w *World) refreshPowers(c *Character) {
|
||||
if c.View.Powers == nil {
|
||||
c.View.Powers = map[string]p.LearnedPower{}
|
||||
}
|
||||
if c.View.Weapons == nil {
|
||||
c.View.Weapons = map[string]p.WeaponProgress{}
|
||||
}
|
||||
if w.Balance.Powers == nil {
|
||||
return
|
||||
}
|
||||
for _, s := range w.Balance.Powers.Weapons {
|
||||
v := c.View.Weapons[s.ID]
|
||||
v.ID = s.ID
|
||||
v.Name = s.Name
|
||||
v.Level, v.XPToNextLevel = content.SkillLevel(s, v.XP)
|
||||
c.View.Weapons[s.ID] = v
|
||||
}
|
||||
for id, v := range c.View.Powers {
|
||||
d := v.Definition
|
||||
v.Level, v.XPToNextLevel = content.SkillLevel(content.GatheringSkill{BaseXP: d.BaseXP, XPPerLevel: d.XPPerLevel, MaxLevel: d.MaxLevel}, v.XP)
|
||||
c.View.Powers[id] = v
|
||||
}
|
||||
for id, name := range (content.Catalog{Powers: w.Balance.Powers}).PowerItems() {
|
||||
if c.View.Inventory[id] > 0 {
|
||||
c.View.StackNames[id] = name
|
||||
}
|
||||
}
|
||||
c.View.Casting = nil
|
||||
if c.PendingCast != nil {
|
||||
message := "Casting " + c.View.Powers[c.PendingCast.Power].Definition.Name
|
||||
c.View.Casting = &message
|
||||
}
|
||||
}
|
||||
func (w *World) restorePowers(c *Character) error {
|
||||
if len(c.View.Powers) > 256 || len(c.View.Weapons) > 64 {
|
||||
return errors.New("invalid learned power history")
|
||||
}
|
||||
for id, v := range c.View.Powers {
|
||||
if id != v.Definition.ID || v.XP < 0 || v.XP > 1000000000000 || !finiteCraft(v.ReadyAt) || v.Definition.BaseXP < 1 || v.Definition.XPPerLevel < 1 || v.Definition.MaxLevel < 1 || v.Definition.MaxLevel > 1000 {
|
||||
return errors.New("invalid learned spell")
|
||||
}
|
||||
d := v.Definition
|
||||
if len(id) > 64 || !finiteCraft(d.Mana) || d.Mana > 10000 || !finiteCraft(d.BasePower) || d.BasePower > 100000 || !finiteCraft(d.RankScaling) || d.RankScaling > 1 || !finiteCraft(d.Cooldown) || d.Cooldown < .1 || d.Cooldown > 120 || !finiteCraft(d.CastSeconds) || d.CastSeconds > 30 || len(d.Parents) > 16 || len(d.Requirements.Stats) > 32 || len(d.Requirements.Titles) > 16 {
|
||||
return errors.New("invalid saved power definition")
|
||||
}
|
||||
if !d.Resurrection {
|
||||
raw, _ := json.Marshal(v.Attack)
|
||||
var attack content.CombatAttack
|
||||
_ = json.Unmarshal(raw, &attack)
|
||||
if e := attack.Validate(); e != nil {
|
||||
return e
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, v := range c.View.Weapons {
|
||||
if v.XP < 0 || v.XP > 1000000000000 {
|
||||
return errors.New("invalid weapon XP")
|
||||
}
|
||||
}
|
||||
// Casts cancel on reconnect/restart/travel; no cast cost is taken until resolution.
|
||||
c.PendingCast = nil
|
||||
c.View.Casting = nil
|
||||
for i := range c.View.Items {
|
||||
if c.View.Items[i].WeaponType == nil {
|
||||
for _, d := range w.Balance.Items {
|
||||
if d.ID == c.View.Items[i].DefinitionID && d.WeaponType != "" {
|
||||
v := d.WeaponType
|
||||
c.View.Items[i].WeaponType = &v
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (w *World) powerRequirements(c *Character, d p.PowerDefinition) bool {
|
||||
if c.View.Level < d.Requirements.Level {
|
||||
return false
|
||||
}
|
||||
stats := w.statValues(c, false)
|
||||
for key, n := range d.Requirements.Stats {
|
||||
if stats[key].Final < n {
|
||||
return false
|
||||
}
|
||||
}
|
||||
for _, id := range d.Requirements.Titles {
|
||||
if !slices.ContainsFunc(c.View.Titles, func(t p.TitleAward) bool { return t.ID == id }) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if d.Kind == "ability" && c.View.Weapons[d.Weapon].Level < d.WeaponLevel {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (w *World) acquirePower(c *Character, d content.PowerDefinition) {
|
||||
var definition p.PowerDefinition
|
||||
raw, _ := json.Marshal(d)
|
||||
_ = json.Unmarshal(raw, &definition)
|
||||
v := p.LearnedPower{Definition: definition, Level: 1, XPToNextLevel: d.BaseXP}
|
||||
for _, a := range w.Balance.Combat.Attacks {
|
||||
if a.ID == d.AttackID {
|
||||
v.Attack = protocolAttack(a)
|
||||
}
|
||||
}
|
||||
c.View.Powers[d.ID] = v
|
||||
w.dirty = true
|
||||
}
|
||||
func (w *World) unlockPowers(c *Character) {
|
||||
w.refreshPowers(c)
|
||||
if w.Balance.Powers == nil {
|
||||
return
|
||||
}
|
||||
// Topological fixed point is bounded by the validated catalog size.
|
||||
for pass := 0; pass < len(w.Balance.Powers.Powers); pass++ {
|
||||
changed := false
|
||||
for _, d := range w.Balance.Powers.Powers {
|
||||
if _, ok := c.View.Powers[d.ID]; ok || d.Book {
|
||||
continue
|
||||
}
|
||||
var definition p.PowerDefinition
|
||||
raw, _ := json.Marshal(d)
|
||||
_ = json.Unmarshal(raw, &definition)
|
||||
if !w.powerRequirements(c, definition) {
|
||||
continue
|
||||
}
|
||||
ready := true
|
||||
for id, rank := range d.Parents {
|
||||
if c.View.Powers[id].Level < rank {
|
||||
ready = false
|
||||
}
|
||||
}
|
||||
if ready {
|
||||
w.acquirePower(c, d)
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
if !changed {
|
||||
break
|
||||
}
|
||||
}
|
||||
w.refreshPowers(c)
|
||||
}
|
||||
func (w *World) LearnPower(c *Character, book string) error {
|
||||
if c == nil || !c.Online || c.Sheltered || c.View.RemainingSeconds <= 0 || (c.View.Entity.State != "alive" && c.View.Entity.State != "eligible") || w.Phase == "lost" {
|
||||
return errors.New("cannot learn a spell now")
|
||||
}
|
||||
if c.View.Inventory[book] < 1 {
|
||||
return errors.New("spell book not owned")
|
||||
}
|
||||
for _, d := range w.Balance.Powers.Powers {
|
||||
if d.Book && "book_"+d.ID == book {
|
||||
if _, ok := c.View.Powers[d.ID]; ok {
|
||||
return errors.New("spell already learned; book retained")
|
||||
}
|
||||
var definition p.PowerDefinition
|
||||
raw, _ := json.Marshal(d)
|
||||
_ = json.Unmarshal(raw, &definition)
|
||||
if !w.powerRequirements(c, definition) {
|
||||
return errors.New("spell requirements not met")
|
||||
}
|
||||
for id, rank := range d.Parents {
|
||||
if c.View.Powers[id].Level < rank {
|
||||
return errors.New("predecessor spell rank required")
|
||||
}
|
||||
}
|
||||
TakeStack(c, book, 1)
|
||||
w.acquirePower(c, d)
|
||||
w.unlockPowers(c)
|
||||
c.Message = "Learned " + d.Name
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return errors.New("unknown spell book")
|
||||
}
|
||||
func (w *World) weaponType(c *Character) string {
|
||||
for _, i := range c.View.Items {
|
||||
if i.ID == c.View.Equipment["weapon"] && i.WeaponType != nil {
|
||||
return *i.WeaponType
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
func (w *World) awardCombatCredit(shot Projectile) {
|
||||
credit := shot.Credit
|
||||
if credit == nil || credit.Rewarded || !shot.Player || !w.AllowsXP() {
|
||||
return
|
||||
}
|
||||
c := w.Characters[shot.Source]
|
||||
if c == nil || c.View.Entity.State != "alive" {
|
||||
return
|
||||
}
|
||||
credit.Rewarded = true
|
||||
if credit.Power != "" {
|
||||
v, ok := c.View.Powers[credit.Power]
|
||||
if ok && v.Definition.Kind == "spell" {
|
||||
v.XP = min(int64(1000000000000), v.XP+w.Balance.Powers.SpellXP)
|
||||
c.View.Powers[credit.Power] = v
|
||||
}
|
||||
}
|
||||
if credit.Weapon != "" {
|
||||
v, ok := c.View.Weapons[credit.Weapon]
|
||||
if ok {
|
||||
v.XP = min(int64(1000000000000), v.XP+w.Balance.Powers.WeaponXP)
|
||||
c.View.Weapons[credit.Weapon] = v
|
||||
}
|
||||
}
|
||||
w.unlockPowers(c)
|
||||
w.dirty = true
|
||||
}
|
||||
func (w *World) CastPower(c *Character, id, target string) error {
|
||||
w.unlockPowers(c)
|
||||
v, ok := c.View.Powers[id]
|
||||
if !ok {
|
||||
return errors.New("power not learned")
|
||||
}
|
||||
d := v.Definition
|
||||
if d.Resurrection {
|
||||
return errors.New("use corpse resurrection")
|
||||
}
|
||||
if c.PendingCast != nil {
|
||||
return errors.New("already casting")
|
||||
}
|
||||
if err := w.checkPower(c, v, target); err != nil {
|
||||
return err
|
||||
}
|
||||
if d.CastSeconds > 0 {
|
||||
c.PendingCast = &PendingCast{Power: id, Target: target, Origin: c.View.Entity.Position, Finish: float64(w.now.UnixMilli())/1000 + d.CastSeconds}
|
||||
w.refreshPowers(c)
|
||||
w.dirty = true
|
||||
return nil
|
||||
}
|
||||
return w.releasePower(c, id, target)
|
||||
}
|
||||
func (w *World) checkPower(c *Character, v p.LearnedPower, target string) error {
|
||||
d := v.Definition
|
||||
if !c.Online || c.Sheltered || c.View.Entity.State != "alive" || c.View.RemainingSeconds <= 0 || w.Phase == "lost" || w.Phase == "won" {
|
||||
return errors.New("cannot cast here")
|
||||
}
|
||||
if w.IsHub() && v.Attack.Effect != "heal" {
|
||||
return errors.New("damage powers unavailable in hub")
|
||||
}
|
||||
if !w.powerRequirements(c, d) || (d.Kind == "ability" && w.weaponType(c) != d.Weapon) {
|
||||
return errors.New("power requirements or equipped weapon not met")
|
||||
}
|
||||
if c.View.Mana < d.Mana || c.View.Stamina < v.Attack.Stamina {
|
||||
return errors.New("not enough mana or stamina")
|
||||
}
|
||||
if float64(w.now.UnixMilli())/1000 < v.ReadyAt {
|
||||
return errors.New("power cooldown")
|
||||
}
|
||||
if d.Targeting == "self" || d.Targeting == "aura" {
|
||||
target = c.View.Entity.ID
|
||||
}
|
||||
found := false
|
||||
for _, e := range w.combatTargets(true, v.Attack.Effect) {
|
||||
if e.ID == target {
|
||||
if length3(body(c.View.Entity.Position), body(e.Position)) > v.Attack.Range+func() float64 {
|
||||
if target == "boss" {
|
||||
return 4
|
||||
}
|
||||
return 0
|
||||
}() {
|
||||
return errors.New("power target out of range")
|
||||
}
|
||||
if _, blocked := w.terrainHit(body(c.View.Entity.Position), body(e.Position)); blocked {
|
||||
return errors.New("terrain blocks power")
|
||||
}
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if d.Targeting == "aura" {
|
||||
found = true
|
||||
}
|
||||
if !found {
|
||||
return errors.New("invalid power target")
|
||||
}
|
||||
if v.Attack.Delivery == "projectile" && len(w.Projectiles) >= w.Balance.CombatRules.MaxProjectiles {
|
||||
return errors.New("projectile limit")
|
||||
}
|
||||
if v.Attack.Duration > 0 && len(w.Areas)+w.pendingAreas() >= w.Balance.CombatRules.MaxAreas {
|
||||
return errors.New("area limit")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (w *World) releasePower(c *Character, id, target string) error {
|
||||
v := c.View.Powers[id]
|
||||
if err := w.checkPower(c, v, target); err != nil {
|
||||
return err
|
||||
}
|
||||
d := v.Definition
|
||||
if d.Targeting == "self" || d.Targeting == "aura" {
|
||||
target = c.View.Entity.ID
|
||||
}
|
||||
to := body(c.View.Entity.Position)
|
||||
for _, e := range w.combatTargets(true, v.Attack.Effect) {
|
||||
if e.ID == target {
|
||||
to = body(e.Position)
|
||||
}
|
||||
}
|
||||
a := v.Attack
|
||||
if a.Delivery == "projectile" {
|
||||
if a.DexteritySpeed != nil {
|
||||
a.Speed += c.View.Stats["dexterity"].Final * *a.DexteritySpeed
|
||||
}
|
||||
if a.StrengthSpeed != nil {
|
||||
a.Speed += c.View.Stats["strength"].Final * *a.StrengthSpeed
|
||||
}
|
||||
a.Speed = math.Min(100, math.Max(1, a.Speed))
|
||||
}
|
||||
c.View.Mana -= d.Mana
|
||||
c.View.Stamina -= a.Stamina
|
||||
v.ReadyAt = float64(w.now.UnixMilli())/1000 + d.Cooldown
|
||||
c.View.Powers[id] = v
|
||||
credit := &CombatCredit{Power: id}
|
||||
if d.Kind == "ability" {
|
||||
credit.Weapon = w.weaponType(c)
|
||||
}
|
||||
shot := Projectile{ID: w.combatID("projectile"), Source: c.View.Entity.ID, Player: true, Target: target, Position: body(c.View.Entity.Position), Destination: to, Attack: a, Power: (d.BasePower + c.View.Stats[a.Stat].Final*a.Multiplier) * (1 + float64(v.Level-1)*d.RankScaling), Credit: credit, MovingAura: d.Targeting == "aura"}
|
||||
if a.Delivery == "projectile" {
|
||||
w.Projectiles[shot.ID] = &shot
|
||||
w.projectileVisual(shot, "launch", "")
|
||||
} else {
|
||||
shot.Position = to
|
||||
w.impact(shot, target)
|
||||
}
|
||||
c.Message = "Used " + d.Name
|
||||
w.dirty = true
|
||||
return nil
|
||||
}
|
||||
func (w *World) updatePowers() {
|
||||
for _, c := range w.orderedCharacters() {
|
||||
if cast := c.PendingCast; cast != nil {
|
||||
if !c.Online || c.Sheltered || c.View.Entity.State != "alive" || length3(c.View.Entity.Position, cast.Origin) > .1 {
|
||||
c.PendingCast = nil
|
||||
c.Message = "Casting interrupted"
|
||||
w.dirty = true
|
||||
} else if float64(w.now.UnixMilli())/1000 >= cast.Finish {
|
||||
c.PendingCast = nil
|
||||
if e := w.releasePower(c, cast.Power, cast.Target); e != nil {
|
||||
c.Message = e.Error()
|
||||
}
|
||||
w.dirty = true
|
||||
}
|
||||
w.refreshPowers(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestSpellBooksRanksAuraAndHubXP(t *testing.T) {
|
||||
w, c := fixture(t)
|
||||
c.View.Inventory["book_mend"] = 2
|
||||
c.View.Mana = 100
|
||||
if e := w.LearnPower(c, "book_mend"); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if c.View.Powers["mend"].Level != 1 || c.View.Inventory["book_mend"] != 1 {
|
||||
t.Fatal("book did not teach rank one exactly once")
|
||||
}
|
||||
if w.LearnPower(c, "book_mend") == nil || c.View.Inventory["book_mend"] != 1 {
|
||||
t.Fatal("duplicate learning consumed book")
|
||||
}
|
||||
if e := w.CastPower(c, "mend", c.View.Entity.ID); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if c.View.Powers["mend"].XP != 0 {
|
||||
t.Fatal("full health healing gained XP")
|
||||
}
|
||||
for i := 0; i < 10; i++ {
|
||||
w.now = w.now.Add(3 * time.Second)
|
||||
c.View.Mana = 100
|
||||
c.View.Entity.HP = 10
|
||||
if e := w.CastPower(c, "mend", c.View.Entity.ID); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
}
|
||||
if c.View.Powers["mend"].Level != 2 || c.View.Powers["renewal"].Level != 1 {
|
||||
t.Fatal("spell rank did not unlock successor", c.View.Powers)
|
||||
}
|
||||
w.now = w.now.Add(10 * time.Second)
|
||||
c.View.Mana = 100
|
||||
c.View.Entity.HP = 10
|
||||
if e := w.CastPower(c, "renewal", ""); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if c.View.Powers["renewal"].XP != 10 {
|
||||
t.Fatal("useful aura did not grant one award")
|
||||
}
|
||||
c.View.Entity.Position.X += 2
|
||||
c.View.Entity.HP = 10
|
||||
advanceProjectiles(w, 30)
|
||||
for _, a := range w.Areas {
|
||||
if a.MovingAura && a.Position != body(c.View.Entity.Position) {
|
||||
t.Fatal("aura did not follow caster")
|
||||
}
|
||||
}
|
||||
if c.View.Powers["renewal"].XP != 10 {
|
||||
t.Fatal("aura tick multiplied XP")
|
||||
}
|
||||
raw, _ := json.Marshal(w)
|
||||
var restored World
|
||||
if e := json.Unmarshal(raw, &restored); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if e := restored.Restore(w.now); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
rc := restored.Characters[c.View.Entity.ID]
|
||||
if !reflect.DeepEqual(rc.View.Powers, c.View.Powers) {
|
||||
t.Fatal("restart changed learned powers")
|
||||
}
|
||||
w.Kind = "hub"
|
||||
w.Phase = "hub"
|
||||
w.now = w.now.Add(20 * time.Second)
|
||||
c.View.Mana = 100
|
||||
c.View.Entity.HP = 10
|
||||
before := c.View.Powers["mend"].XP
|
||||
if e := w.CastPower(c, "mend", c.View.Entity.ID); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if c.View.Powers["mend"].XP != before || c.View.Mana >= 100 {
|
||||
t.Fatal("hub spell gained XP or bypassed cost")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCastingInterruptMissAndWeaponUnlock(t *testing.T) {
|
||||
w, c, m := combatFixture(t)
|
||||
c.View.Inventory["book_arc_bolt"] = 1
|
||||
c.View.Mana = 100
|
||||
if e := w.LearnPower(c, "book_arc_bolt"); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if e := w.CastPower(c, "arc_bolt", m.Entity.ID); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
c.View.Entity.Position.X += 1
|
||||
w.updatePowers()
|
||||
if c.PendingCast != nil || len(w.Projectiles) != 0 || c.View.Mana != 100 {
|
||||
t.Fatal("movement failed to interrupt cast without cost")
|
||||
}
|
||||
if e := w.CastPower(c, "arc_bolt", m.Entity.ID); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
w.now = w.now.Add(time.Second)
|
||||
w.updatePowers()
|
||||
if len(w.Projectiles) != 1 || c.View.Mana != 95 {
|
||||
t.Fatal("cast did not release after delay")
|
||||
}
|
||||
m.Entity.Position.Z += 20
|
||||
advanceProjectiles(w, 40)
|
||||
if c.View.Powers["arc_bolt"].XP != 0 {
|
||||
t.Fatal("miss gained spell XP")
|
||||
}
|
||||
w, c, m = combatFixture(t)
|
||||
c.View.Equipment = map[string]string{}
|
||||
for _, i := range c.View.Items {
|
||||
if i.DefinitionID == "knife" {
|
||||
c.View.Equipment["weapon"] = i.ID
|
||||
}
|
||||
}
|
||||
w.RefreshStats(c)
|
||||
m.Entity.Position = c.View.Entity.Position
|
||||
m.Entity.Position.X += 1
|
||||
m.Entity.HP = 10000
|
||||
m.Entity.MaxHP = 10000
|
||||
c.View.AllocatedStats["strength"] = 2
|
||||
w.RefreshStats(c)
|
||||
for i := 0; i < 10; i++ {
|
||||
w.now = w.now.Add(3 * time.Second)
|
||||
if e := w.attack(c, m.Entity.ID); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
}
|
||||
if c.View.Weapons["blades"].Level != 2 || c.View.Powers["cleave"].Definition.ID != "cleave" {
|
||||
t.Fatal("meaningful weapon hits did not unlock ability")
|
||||
}
|
||||
if e := w.unequip(c, "weapon"); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if w.CastPower(c, "cleave", m.Entity.ID) == nil {
|
||||
t.Fatal("ability used without matching weapon")
|
||||
}
|
||||
w.kill(c, "test")
|
||||
replacement, e := w.Join(c.Account, "Replacement")
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if len(replacement.View.Powers) != 0 || replacement.View.Weapons["blades"].XP != 0 {
|
||||
t.Fatal("replacement inherited powers")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCorpseRevivalKeepsLootAndDailyBudget(t *testing.T) {
|
||||
w, c := fixture(t)
|
||||
rescuer, e := w.Join("rescuer", "Rescuer")
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
_ = w.Connect(rescuer.View.Entity.ID)
|
||||
rescuer.View.Entity.Position = c.View.Entity.Position
|
||||
rescuer.View.Inventory["revival_stone"] = 2
|
||||
c.DailySeconds = 123
|
||||
c.View.Inventory["wood"] = 7
|
||||
w.kill(c, "test")
|
||||
corpse := c.RevivalCorpse
|
||||
if _, e = w.Revive(rescuer, corpse, "item"); e == nil {
|
||||
t.Fatal("revived without consent")
|
||||
}
|
||||
c.RevivalAllowed = true
|
||||
if e = w.lootCorpse(rescuer, corpse); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if w.Corpses[corpse] == nil || len(w.Corpses[corpse].Inventory) != 0 {
|
||||
t.Fatal("fully looted corpse no longer targetable")
|
||||
}
|
||||
if _, e = w.Revive(rescuer, corpse, "item"); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
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 _, e = w.Revive(rescuer, corpse, "item"); e == nil || rescuer.View.Inventory["revival_stone"] != 1 {
|
||||
t.Fatal("revived twice")
|
||||
}
|
||||
w.kill(c, "again")
|
||||
if c.RevivalCorpse == corpse {
|
||||
t.Fatal("death reused corpse identity")
|
||||
}
|
||||
c.RevivalAllowed = true
|
||||
rescuer.View.Inventory["book_revive"] = 1
|
||||
rescuer.View.Mana = 100
|
||||
if e = w.LearnPower(rescuer, "book_revive"); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
c.DailySeconds = w.Balance.DailyPlaySeconds
|
||||
if _, e = w.Revive(rescuer, c.RevivalCorpse, "revive"); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if c.View.RemainingSeconds != 0 || !c.Sheltered || !c.View.HasKeystone || c.ReturnPosition == nil || rescuer.View.Mana != 80 || rescuer.View.Powers["revive"].XP != 10 {
|
||||
t.Fatal("spell revival changed daily budget or costs")
|
||||
}
|
||||
w.kill(c, "final")
|
||||
c.RevivalAllowed = true
|
||||
w.Phase = "lost"
|
||||
if _, e = w.Revive(rescuer, c.RevivalCorpse, "item"); e == nil {
|
||||
t.Fatal("revived after destruction")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"math"
|
||||
)
|
||||
|
||||
// The owning store additionally fences this against account replacement, the
|
||||
// persisted death occurrence, and world ownership in the same save transaction.
|
||||
func (w *World) Revive(caster *Character, corpseID, power string) (*Character, error) {
|
||||
corpse := w.Corpses[corpseID]
|
||||
if corpse == nil || corpse.CharacterID == "" || w.Phase == "lost" {
|
||||
return nil, errors.New("corpse cannot be revived")
|
||||
}
|
||||
target := w.Characters[corpse.CharacterID]
|
||||
if caster == nil || target == nil || caster == target || !caster.Online || caster.Sheltered || caster.View.RemainingSeconds <= 0 || (caster.View.Entity.State != "alive" && caster.View.Entity.State != "eligible") || target.View.Entity.State != "dead" || target.RevivalCorpse != corpseID || !target.RevivalAllowed {
|
||||
return nil, errors.New("revival requires an active rescuer and the dead player's consent")
|
||||
}
|
||||
if length3(caster.View.Entity.Position, corpse.Entity.Position) > w.Balance.Powers.RevivalRange {
|
||||
return nil, errors.New("stand next to the corpse")
|
||||
}
|
||||
if _, blocked := w.terrainHit(body(caster.View.Entity.Position), body(corpse.Entity.Position)); blocked {
|
||||
return nil, errors.New("terrain blocks the corpse")
|
||||
}
|
||||
if caster.PendingCast != nil {
|
||||
return nil, errors.New("finish or cancel the current cast")
|
||||
}
|
||||
if power == "item" {
|
||||
if caster.View.Inventory["revival_stone"] < 1 {
|
||||
return nil, errors.New("revival stone required")
|
||||
}
|
||||
} else {
|
||||
v, ok := caster.View.Powers[power]
|
||||
if !ok || !v.Definition.Resurrection || !w.powerRequirements(caster, v.Definition) || caster.View.Mana < v.Definition.Mana || float64(w.now.UnixMilli())/1000 < v.ReadyAt {
|
||||
return nil, errors.New("resurrection spell unavailable")
|
||||
}
|
||||
}
|
||||
if e := validateOwnedItems(corpse.Items, map[string]bool{}); e != nil {
|
||||
return nil, e
|
||||
}
|
||||
if e := ValidateCraftedStacks(corpse.Inventory, corpse.CraftedStacks, map[string]bool{}); e != nil {
|
||||
return nil, e
|
||||
}
|
||||
if power == "item" {
|
||||
TakeStack(caster, "revival_stone", 1)
|
||||
} else {
|
||||
v := caster.View.Powers[power]
|
||||
caster.View.Mana -= v.Definition.Mana
|
||||
v.ReadyAt = float64(w.now.UnixMilli())/1000 + v.Definition.Cooldown
|
||||
caster.View.Powers[power] = v
|
||||
w.awardCombatCredit(Projectile{Source: caster.View.Entity.ID, Player: true, Credit: &CombatCredit{Power: power}})
|
||||
}
|
||||
target.View.Inventory = corpse.Inventory
|
||||
target.View.Items = corpse.Items
|
||||
target.View.CraftedStacks = corpse.CraftedStacks
|
||||
target.View.Entity.State = "alive"
|
||||
if w.Phase == "won" {
|
||||
target.View.Entity.State = "eligible"
|
||||
}
|
||||
target.View.Entity.Position = corpse.Entity.Position
|
||||
target.RevivalAllowed = false
|
||||
target.DiedAt = nil
|
||||
target.DeathReason = ""
|
||||
target.PendingCast = nil
|
||||
target.JumpVelocity = 0
|
||||
target.MoveX = 0
|
||||
target.MoveZ = 0
|
||||
target.Sheltered = false
|
||||
target.ReturnPosition = nil
|
||||
target.View.HasKeystone = false
|
||||
w.RefreshStats(target)
|
||||
target.View.Entity.HP = math.Max(1, target.View.Entity.MaxHP*w.Balance.Powers.RevivalHealth)
|
||||
target.View.Mana = 0
|
||||
target.View.Stamina = 0
|
||||
// Daily usage is retained; capped players cannot reconnect or act until reset.
|
||||
w.resetDay(target)
|
||||
if target.View.RemainingSeconds <= 0 {
|
||||
target.Online = false
|
||||
position := target.View.Entity.Position
|
||||
target.ReturnPosition = &position
|
||||
target.Sheltered = true
|
||||
target.View.HasKeystone = true
|
||||
target.View.Entity.Position = w.terrain.Position(0, 0)
|
||||
target.View.Entity.HP = math.Min(target.View.Entity.MaxHP, math.Max(50, target.View.Entity.HP))
|
||||
}
|
||||
delete(w.Corpses, corpseID)
|
||||
target.Message = "Revived with the belongings left on your corpse"
|
||||
caster.Message = "Revived " + target.View.Entity.Name
|
||||
w.dirty = true
|
||||
return target, nil
|
||||
}
|
||||
@@ -90,6 +90,7 @@ func (w *World) RefreshStats(c *Character) {
|
||||
c.View.Stats = w.statValues(c, true)
|
||||
w.refreshGathering(c)
|
||||
w.refreshCrafting(c)
|
||||
w.unlockPowers(c)
|
||||
attack := w.playerAttack(c)
|
||||
c.View.Attack = &attack
|
||||
c.View.Entity.MaxHP = c.View.Stats["healthPoints"].Final
|
||||
@@ -172,6 +173,9 @@ func (w *World) ApplyCatalog(catalog content.Catalog) error {
|
||||
if catalog.Combat != nil {
|
||||
w.Balance.Combat = catalog.Combat
|
||||
}
|
||||
if catalog.Powers != nil {
|
||||
w.Balance.Powers = catalog.Powers
|
||||
}
|
||||
if catalog.Crafting != nil {
|
||||
w.Balance.Crafting = catalog.Crafting
|
||||
}
|
||||
@@ -211,5 +215,11 @@ func (w *World) damageCharacter(c *Character, amount float64) {
|
||||
if w.roll(c.View.Stats["dodgeChance"].Final) {
|
||||
return
|
||||
}
|
||||
c.View.Entity.HP -= math.Max(0, amount-c.View.Stats["defence"].Final)
|
||||
damage := math.Max(0, amount-c.View.Stats["defence"].Final)
|
||||
if damage > 0 && c.PendingCast != nil {
|
||||
c.PendingCast = nil
|
||||
c.View.Casting = nil
|
||||
c.Message = "Casting interrupted by damage"
|
||||
}
|
||||
c.View.Entity.HP -= damage
|
||||
}
|
||||
|
||||
@@ -14,10 +14,14 @@ import (
|
||||
)
|
||||
|
||||
type Character struct {
|
||||
CraftReadyAt float64 `json:"craftReadyAt"`
|
||||
AttackReadyAt float64 `json:"attackReadyAt"`
|
||||
JumpVelocity float64 `json:"jumpVelocity"`
|
||||
GatherReadyAt float64 `json:"gatherReadyAt"`
|
||||
PendingCast *PendingCast `json:"pendingCast,omitempty"`
|
||||
RevivalCorpse string `json:"revivalCorpse,omitempty"`
|
||||
RevivalAllowed bool `json:"revivalAllowed"`
|
||||
DeathCount int64 `json:"deathCount"`
|
||||
CraftReadyAt float64 `json:"craftReadyAt"`
|
||||
AttackReadyAt float64 `json:"attackReadyAt"`
|
||||
JumpVelocity float64 `json:"jumpVelocity"`
|
||||
GatherReadyAt float64 `json:"gatherReadyAt"`
|
||||
|
||||
View p.Character `json:"view"`
|
||||
Account string `json:"account"`
|
||||
@@ -42,6 +46,7 @@ type Character struct {
|
||||
StatsVersion int `json:"statsVersion"`
|
||||
}
|
||||
type Corpse struct {
|
||||
CharacterID string `json:"characterId,omitempty"`
|
||||
CraftedStacks []p.CraftedStack `json:"craftedStacks,omitempty"`
|
||||
Entity p.Entity `json:"entity"`
|
||||
Inventory map[string]int64 `json:"inventory"`
|
||||
@@ -187,6 +192,17 @@ func (w *World) Restore(now time.Time) error {
|
||||
if w.ResourceLayouts == nil {
|
||||
w.ResourceLayouts = map[string]ResourceLayout{}
|
||||
}
|
||||
if w.Balance.Powers == nil {
|
||||
b, e := content.Load()
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
cat := content.Catalog{Items: w.Balance.Items, Combat: w.Balance.Combat}
|
||||
cat.RestorePowers(b)
|
||||
w.Balance.Powers = cat.Powers
|
||||
w.Balance.Combat = cat.Combat
|
||||
w.Balance.Items = cat.Items
|
||||
}
|
||||
if w.Balance.Crafting == nil {
|
||||
b, e := content.Load()
|
||||
if e != nil {
|
||||
@@ -228,6 +244,9 @@ func (w *World) Restore(now time.Time) error {
|
||||
if err := w.restoreEquipment(c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := w.restorePowers(c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := w.restoreCrafting(c); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -342,6 +361,9 @@ func (w *World) Join(account, name string) (*Character, error) {
|
||||
if err := w.restoreEquipment(c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := w.restorePowers(c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := w.restoreCrafting(c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -373,6 +395,9 @@ func (w *World) Import(c *Character) error {
|
||||
if err := w.checkImportedEquipment(c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := w.restorePowers(c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := w.restoreCrafting(c); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -399,6 +424,7 @@ func (w *World) Import(c *Character) error {
|
||||
c.JumpVelocity = 0
|
||||
c.ReturnPosition = nil
|
||||
c.Sheltered = false
|
||||
c.PendingCast = nil
|
||||
c.View.HasKeystone = false
|
||||
c.WorldKills = 0
|
||||
w.resetDay(c)
|
||||
@@ -422,7 +448,7 @@ func (w *World) Connect(id string) error {
|
||||
}
|
||||
w.resetDay(c)
|
||||
if c.View.Entity.State == "dead" {
|
||||
return errors.New("this character has died permanently")
|
||||
return errors.New("this character is dead; corpse revival is required before reconnecting")
|
||||
}
|
||||
if c.View.RemainingSeconds <= 0 {
|
||||
return errors.New("daily play limit reached; resets at 00:00 UTC")
|
||||
@@ -483,7 +509,7 @@ func (w *World) Intent(id string, i p.Intent) error {
|
||||
if i.Seq <= c.View.ACK || i.Seq > c.View.ACK+10000 {
|
||||
return errors.New("invalid input sequence")
|
||||
}
|
||||
if math.IsNaN(i.X) || math.IsNaN(i.Z) || math.IsInf(i.X, 0) || math.IsInf(i.Z, 0) || math.Abs(i.X) > 1 || math.Abs(i.Z) > 1 || len(i.Target) > 100 || len(i.Slot) > 30 {
|
||||
if math.IsNaN(i.X) || math.IsNaN(i.Z) || math.IsInf(i.X, 0) || math.IsInf(i.Z, 0) || math.Abs(i.X) > 1 || math.Abs(i.Z) > 1 || len(i.Target) > 100 || len(i.Slot) > 64 {
|
||||
return errors.New("invalid intent")
|
||||
}
|
||||
c.View.ACK = i.Seq
|
||||
@@ -491,7 +517,7 @@ func (w *World) Intent(id string, i p.Intent) error {
|
||||
c.Sheltered = false
|
||||
w.dirty = true
|
||||
}
|
||||
if w.Phase == "won" && i.Op != "move" && i.Op != "jump" && i.Op != "return" {
|
||||
if w.Phase == "won" && i.Op != "move" && i.Op != "jump" && i.Op != "return" && i.Op != "learn" {
|
||||
return errors.New("use the victory portal to continue")
|
||||
}
|
||||
if w.IsHub() && (i.Op == "attack" || i.Op == "gather") {
|
||||
@@ -520,6 +546,15 @@ func (w *World) Intent(id string, i p.Intent) error {
|
||||
return w.consumeGathering(c, i.Target)
|
||||
case "gather":
|
||||
return w.gather(c, i.Target)
|
||||
case "learn":
|
||||
return w.LearnPower(c, i.Target)
|
||||
case "cast":
|
||||
return w.CastPower(c, i.Slot, i.Target)
|
||||
case "cancel-cast":
|
||||
c.PendingCast = nil
|
||||
w.refreshPowers(c)
|
||||
w.dirty = true
|
||||
return nil
|
||||
case "craft":
|
||||
return errors.New("use the crafting workbench to offer ingredients")
|
||||
case "attack":
|
||||
@@ -580,11 +615,15 @@ func (w *World) kill(c *Character, reason string) {
|
||||
e := c.View.Entity
|
||||
e.Position = w.terrain.Position(e.Position.X, e.Position.Z)
|
||||
c.View.Entity.Position = e.Position
|
||||
e.ID = "corpse:" + e.ID
|
||||
c.DeathCount++
|
||||
c.PendingCast = nil
|
||||
c.RevivalAllowed = false
|
||||
e.ID = "corpse:" + e.ID + ":" + ID()
|
||||
c.RevivalCorpse = e.ID
|
||||
e.Kind = "corpse"
|
||||
e.State = "dead"
|
||||
e.HP = 0
|
||||
w.Corpses[e.ID] = &Corpse{Entity: e, Inventory: c.View.Inventory, Items: c.View.Items, CraftedStacks: c.View.CraftedStacks}
|
||||
w.Corpses[e.ID] = &Corpse{CharacterID: c.View.Entity.ID, Entity: e, Inventory: c.View.Inventory, Items: c.View.Items, CraftedStacks: c.View.CraftedStacks}
|
||||
c.View.CraftedStacks = nil
|
||||
c.View.Inventory = map[string]int64{}
|
||||
c.View.Items = []p.ItemInstance{}
|
||||
@@ -749,6 +788,9 @@ func (w *World) Advance(now time.Time, dt float64) {
|
||||
}
|
||||
if !w.IsHub() && w.Phase != "won" {
|
||||
w.updateMobs(active, dt)
|
||||
}
|
||||
w.updatePowers()
|
||||
if w.Phase != "won" {
|
||||
w.updateCombat(dt)
|
||||
}
|
||||
if w.Phase == "cataclysm" {
|
||||
|
||||
@@ -143,7 +143,7 @@ func TestGatherCraftAndPermanentDeath(t *testing.T) {
|
||||
if c.DiedAt == nil || c.DeathReason != "test death" {
|
||||
t.Fatal("missing durable death record")
|
||||
}
|
||||
if len(c.View.Inventory) != 0 || gearCount(w.Corpses["corpse:"+id].Items, "spear") != 1 {
|
||||
if len(c.View.Inventory) != 0 || gearCount(w.Corpses[c.RevivalCorpse].Items, "spear") != 1 {
|
||||
t.Fatal("corpse inventory")
|
||||
}
|
||||
raw, _ := json.Marshal(w)
|
||||
|
||||
Reference in New Issue
Block a user