diff --git a/pkg/constants/levels.go b/pkg/constants/levels.go index c265131..a29a3c4 100644 --- a/pkg/constants/levels.go +++ b/pkg/constants/levels.go @@ -1,7 +1,7 @@ package constants // StandardXPTable represents the standard skill XP curve -var StandardXPTable = []uint64{ +var StandardXPTable = []int64{ 0, 83, 174, @@ -131,7 +131,7 @@ var StandardXPTable = []uint64{ } // EliteXPTable represents the elite skill XP curve -var EliteXPTable = []uint64{ +var EliteXPTable = []int64{ 0, 830, 1861, diff --git a/pkg/types/skills.go b/pkg/types/skills.go index bc21351..d618bc0 100644 --- a/pkg/types/skills.go +++ b/pkg/types/skills.go @@ -42,18 +42,16 @@ const ( ) // GetVirtualLevel gets the virtual level for the given XP -func (s Skill) GetVirtualLevel(XP uint64) uint32 { +func (s Skill) GetVirtualLevel(XP int64) int { table := constants.StandardXPTable if s.IsEliteSkill() { table = constants.EliteXPTable } - i := sort.Search(len(table), func(i int) bool { + return sort.Search(len(table), func(i int) bool { return table[i] > XP }) - - return uint32(i) } // IsStandardSkill determines if the provided skill is a standard skill diff --git a/pkg/types/skills_test.go b/pkg/types/skills_test.go index 4ee6069..8390d6e 100644 --- a/pkg/types/skills_test.go +++ b/pkg/types/skills_test.go @@ -53,8 +53,8 @@ func TestGetVirtualLevel(t *testing.T) { cases := []struct { name string skill types.Skill - XP uint64 - expected uint32 + XP int64 + expected int }{ {"standard skill 0 xp", types.Attack, 0, 1}, {"elite skill 0 xp", types.Invention, 0, 1},