Unify XP progression and enable ability ranks
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"aeternalis/server/content"
|
||||
"errors"
|
||||
)
|
||||
|
||||
func (w *World) migrateXPCurve(c *Character) error {
|
||||
if c.XPCurveVersion == 1 {
|
||||
return nil
|
||||
}
|
||||
if c.XPCurveVersion != 0 {
|
||||
return errors.New("unsupported XP curve version")
|
||||
}
|
||||
if c.View.Level < c.Progression.MaxLevel {
|
||||
old := c.Progression.BaseXP + (c.View.Level-1)*c.Progression.XPPerLevel
|
||||
if c.View.Experience >= old {
|
||||
return errors.New("invalid legacy level XP")
|
||||
}
|
||||
c.View.Experience = content.RebaseLevelXP(c.View.Experience, old, content.XPForLevel(c.View.Level+1))
|
||||
}
|
||||
valid := func(xp int64) bool { return xp >= 0 && xp <= 1000000000000 }
|
||||
if w.Balance.Gathering != nil {
|
||||
for _, s := range w.Balance.Gathering.Skills {
|
||||
xp := c.View.Skills[s.ID]
|
||||
if !valid(xp) {
|
||||
return errors.New("invalid legacy skill XP")
|
||||
}
|
||||
if xp > 0 {
|
||||
c.View.Skills[s.ID] = content.RebaseSkillXP(s, xp)
|
||||
}
|
||||
}
|
||||
}
|
||||
if w.Balance.Crafting != nil {
|
||||
for _, s := range w.Balance.Crafting.Professions {
|
||||
v, ok := c.View.Crafting[s.ID]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if !valid(v.XP) {
|
||||
return errors.New("invalid legacy crafting XP")
|
||||
}
|
||||
v.XP = content.RebaseSkillXP(s, v.XP)
|
||||
c.View.Crafting[s.ID] = v
|
||||
}
|
||||
}
|
||||
if w.Balance.Powers != nil {
|
||||
for _, s := range w.Balance.Powers.Weapons {
|
||||
v, ok := c.View.Weapons[s.ID]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if !valid(v.XP) {
|
||||
return errors.New("invalid legacy weapon XP")
|
||||
}
|
||||
v.XP = content.RebaseSkillXP(s, v.XP)
|
||||
c.View.Weapons[s.ID] = v
|
||||
}
|
||||
}
|
||||
for id, v := range c.View.Powers {
|
||||
d := v.Definition
|
||||
if !valid(v.XP) || d.BaseXP < 1 || d.XPPerLevel < 1 || d.MaxLevel < 1 || d.MaxLevel > 1000 {
|
||||
return errors.New("invalid legacy power XP")
|
||||
}
|
||||
v.XP = content.RebaseSkillXP(content.GatheringSkill{BaseXP: d.BaseXP, XPPerLevel: d.XPPerLevel, MaxLevel: d.MaxLevel}, v.XP)
|
||||
if d.Kind == "ability" && d.MaxLevel == 1 {
|
||||
v.Definition.MaxLevel = 1000
|
||||
}
|
||||
c.View.Powers[id] = v
|
||||
}
|
||||
c.XPCurveVersion = 1
|
||||
w.dirty = true
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user