diff --git a/internal/models/babble/babble.go b/internal/models/babble/babble.go index c29e418..07514a3 100644 --- a/internal/models/babble/babble.go +++ b/internal/models/babble/babble.go @@ -33,11 +33,9 @@ func (b *Babble) Validate() error { // Global store with singleton pattern var store *nigiri.BaseStore[Babble] -var db *nigiri.Collection // Init sets up the Nigiri store and indices func Init(collection *nigiri.Collection) { - db = collection store = nigiri.NewBaseStore[Babble]() // Register custom indices diff --git a/internal/models/control/control.go b/internal/models/control/control.go index 4dd1afb..8e37c14 100644 --- a/internal/models/control/control.go +++ b/internal/models/control/control.go @@ -9,7 +9,6 @@ import ( var ( store *nigiri.BaseStore[Control] - db *nigiri.Collection global *Control mu sync.RWMutex ) @@ -27,7 +26,6 @@ type Control struct { // Init sets up the Nigiri store for control settings func Init(collection *nigiri.Collection) { - db = collection store = nigiri.NewBaseStore[Control]() // Load or create the singleton control instance diff --git a/internal/models/drops/drops.go b/internal/models/drops/drops.go index 16d6ec7..df910db 100644 --- a/internal/models/drops/drops.go +++ b/internal/models/drops/drops.go @@ -22,11 +22,9 @@ const ( // Global store var store *nigiri.BaseStore[Drop] -var db *nigiri.Collection // Init sets up the Nigiri store and indices func Init(collection *nigiri.Collection) { - db = collection store = nigiri.NewBaseStore[Drop]() // Register custom indices diff --git a/internal/models/fights/fights.go b/internal/models/fights/fights.go index 013b950..f0b34bf 100644 --- a/internal/models/fights/fights.go +++ b/internal/models/fights/fights.go @@ -32,11 +32,9 @@ type Fight struct { // Global store var store *nigiri.BaseStore[Fight] -var db *nigiri.Collection // Init sets up the Nigiri store and indices func Init(collection *nigiri.Collection) { - db = collection store = nigiri.NewBaseStore[Fight]() // Register custom indices diff --git a/internal/models/forum/forum.go b/internal/models/forum/forum.go index 32ede75..c3f12b9 100644 --- a/internal/models/forum/forum.go +++ b/internal/models/forum/forum.go @@ -23,11 +23,9 @@ type Forum struct { // Global store var store *nigiri.BaseStore[Forum] -var db *nigiri.Collection // Init sets up the Nigiri store and indices func Init(collection *nigiri.Collection) { - db = collection store = nigiri.NewBaseStore[Forum]() // Register custom indices diff --git a/internal/models/items/items.go b/internal/models/items/items.go index 77b11d3..4f89884 100644 --- a/internal/models/items/items.go +++ b/internal/models/items/items.go @@ -25,11 +25,9 @@ const ( // Global store var store *nigiri.BaseStore[Item] -var db *nigiri.Collection // Init sets up the Nigiri store and indices func Init(collection *nigiri.Collection) { - db = collection store = nigiri.NewBaseStore[Item]() // Register custom indices diff --git a/internal/models/monsters/monsters.go b/internal/models/monsters/monsters.go index 655a340..6ea12f8 100644 --- a/internal/models/monsters/monsters.go +++ b/internal/models/monsters/monsters.go @@ -28,11 +28,9 @@ const ( // Global store var store *nigiri.BaseStore[Monster] -var db *nigiri.Collection // Init sets up the Nigiri store and indices func Init(collection *nigiri.Collection) { - db = collection store = nigiri.NewBaseStore[Monster]() // Register custom indices diff --git a/internal/models/news/news.go b/internal/models/news/news.go index d259512..bc54c9b 100644 --- a/internal/models/news/news.go +++ b/internal/models/news/news.go @@ -18,11 +18,9 @@ type News struct { // Global store var store *nigiri.BaseStore[News] -var db *nigiri.Collection // Init sets up the Nigiri store and indices func Init(collection *nigiri.Collection) { - db = collection store = nigiri.NewBaseStore[News]() // Register custom indices diff --git a/internal/models/spells/spells.go b/internal/models/spells/spells.go index 77eb282..92be606 100644 --- a/internal/models/spells/spells.go +++ b/internal/models/spells/spells.go @@ -27,11 +27,9 @@ const ( // Global store var store *nigiri.BaseStore[Spell] -var db *nigiri.Collection // Init sets up the Nigiri store and indices func Init(collection *nigiri.Collection) { - db = collection store = nigiri.NewBaseStore[Spell]() // Register custom indices diff --git a/internal/models/towns/towns.go b/internal/models/towns/towns.go index b4886d4..b2ae8df 100644 --- a/internal/models/towns/towns.go +++ b/internal/models/towns/towns.go @@ -27,7 +27,6 @@ type Town struct { // Global store var store *nigiri.BaseStore[Town] -var db *nigiri.Collection // coordsKey creates a key for coordinate-based lookup func coordsKey(x, y int) string { @@ -36,7 +35,6 @@ func coordsKey(x, y int) string { // Init sets up the Nigiri store and indices func Init(collection *nigiri.Collection) { - db = collection store = nigiri.NewBaseStore[Town]() // Register custom indices diff --git a/internal/models/users/users.go b/internal/models/users/users.go index ab65569..e579c36 100644 --- a/internal/models/users/users.go +++ b/internal/models/users/users.go @@ -8,6 +8,7 @@ import ( "time" "dk/internal/helpers" + "dk/internal/helpers/exp" nigiri "git.sharkk.net/Sharkk/Nigiri" ) @@ -61,11 +62,9 @@ type User struct { // Global store var store *nigiri.BaseStore[User] -var db *nigiri.Collection // Init sets up the Nigiri store and indices func Init(collection *nigiri.Collection) { - db = collection store = nigiri.NewBaseStore[User]() // Register custom indices @@ -348,8 +347,7 @@ func (u *User) SetPosition(x, y int) { } func (u *User) ExpNeededForNextLevel() int { - level := u.Level + 1 - return level * level * level + return exp.Calc(u.Level + 1) } func (u *User) GrantExp(expAmount int) { @@ -382,7 +380,7 @@ func (u *User) ExpProgress() float64 { return float64(u.Exp) / float64(u.ExpNeededForNextLevel()) * 100 } - currentLevelExp := u.Level * u.Level * u.Level + currentLevelExp := exp.Calc(u.Level) nextLevelExp := u.ExpNeededForNextLevel() progressExp := u.Exp