1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-12 07:16:57 -05:00
OpenDiablo2/d2core/d2records/experience_loader.go

78 lines
1.7 KiB
Go
Raw Normal View History

package d2records
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
/* first column of experience.txt
Level
Amazon
Sorceress
Necromancer
Paladin
Barbarian
Druid
Assassin
ExpRatio
second row is special case, shows max levels
MaxLvl
99
99
99
99
99
99
99
10
the rest are the breakpoints records
*/
func experienceLoader(r *RecordManager, d *d2txt.DataDictionary) error {
breakpoints := make(ExperienceBreakpoints)
d.Next() // move to the first row, the max level data
// parse the max level data
maxLevels := ExperienceMaxLevels{
d2enum.HeroAmazon: d.Number("Amazon"),
d2enum.HeroBarbarian: d.Number("Barbarian"),
d2enum.HeroDruid: d.Number("Druid"),
d2enum.HeroAssassin: d.Number("Assassin"),
d2enum.HeroNecromancer: d.Number("Necromancer"),
d2enum.HeroPaladin: d.Number("Paladin"),
d2enum.HeroSorceress: d.Number("Sorceress"),
}
for d.Next() {
2020-12-18 01:40:54 -05:00
record := &ExperienceBreakpointRecord{
Level: d.Number("Level"),
HeroBreakpoints: map[d2enum.Hero]int{
d2enum.HeroAmazon: d.Number("Amazon"),
d2enum.HeroBarbarian: d.Number("Barbarian"),
d2enum.HeroDruid: d.Number("Druid"),
d2enum.HeroAssassin: d.Number("Assassin"),
d2enum.HeroNecromancer: d.Number("Necromancer"),
d2enum.HeroPaladin: d.Number("Paladin"),
d2enum.HeroSorceress: d.Number("Sorceress"),
},
Ratio: d.Number("ExpRatio"),
}
breakpoints[record.Level] = record
}
if d.Err != nil {
return d.Err
}
2020-12-18 01:40:54 -05:00
r.Debugf("Loaded %d ExperienceBreakpoint records", len(breakpoints))
r.Character.MaxLevel = maxLevels
r.Character.Experience = breakpoints
return nil
}