clean up db vars fix exp calc calls

This commit is contained in:
Sky Johnson 2025-08-21 13:48:04 -05:00
parent c362475bae
commit 68ec8ce5ea
11 changed files with 3 additions and 25 deletions

View File

@ -33,11 +33,9 @@ func (b *Babble) Validate() error {
// Global store with singleton pattern // Global store with singleton pattern
var store *nigiri.BaseStore[Babble] var store *nigiri.BaseStore[Babble]
var db *nigiri.Collection
// Init sets up the Nigiri store and indices // Init sets up the Nigiri store and indices
func Init(collection *nigiri.Collection) { func Init(collection *nigiri.Collection) {
db = collection
store = nigiri.NewBaseStore[Babble]() store = nigiri.NewBaseStore[Babble]()
// Register custom indices // Register custom indices

View File

@ -9,7 +9,6 @@ import (
var ( var (
store *nigiri.BaseStore[Control] store *nigiri.BaseStore[Control]
db *nigiri.Collection
global *Control global *Control
mu sync.RWMutex mu sync.RWMutex
) )
@ -27,7 +26,6 @@ type Control struct {
// Init sets up the Nigiri store for control settings // Init sets up the Nigiri store for control settings
func Init(collection *nigiri.Collection) { func Init(collection *nigiri.Collection) {
db = collection
store = nigiri.NewBaseStore[Control]() store = nigiri.NewBaseStore[Control]()
// Load or create the singleton control instance // Load or create the singleton control instance

View File

@ -22,11 +22,9 @@ const (
// Global store // Global store
var store *nigiri.BaseStore[Drop] var store *nigiri.BaseStore[Drop]
var db *nigiri.Collection
// Init sets up the Nigiri store and indices // Init sets up the Nigiri store and indices
func Init(collection *nigiri.Collection) { func Init(collection *nigiri.Collection) {
db = collection
store = nigiri.NewBaseStore[Drop]() store = nigiri.NewBaseStore[Drop]()
// Register custom indices // Register custom indices

View File

@ -32,11 +32,9 @@ type Fight struct {
// Global store // Global store
var store *nigiri.BaseStore[Fight] var store *nigiri.BaseStore[Fight]
var db *nigiri.Collection
// Init sets up the Nigiri store and indices // Init sets up the Nigiri store and indices
func Init(collection *nigiri.Collection) { func Init(collection *nigiri.Collection) {
db = collection
store = nigiri.NewBaseStore[Fight]() store = nigiri.NewBaseStore[Fight]()
// Register custom indices // Register custom indices

View File

@ -23,11 +23,9 @@ type Forum struct {
// Global store // Global store
var store *nigiri.BaseStore[Forum] var store *nigiri.BaseStore[Forum]
var db *nigiri.Collection
// Init sets up the Nigiri store and indices // Init sets up the Nigiri store and indices
func Init(collection *nigiri.Collection) { func Init(collection *nigiri.Collection) {
db = collection
store = nigiri.NewBaseStore[Forum]() store = nigiri.NewBaseStore[Forum]()
// Register custom indices // Register custom indices

View File

@ -25,11 +25,9 @@ const (
// Global store // Global store
var store *nigiri.BaseStore[Item] var store *nigiri.BaseStore[Item]
var db *nigiri.Collection
// Init sets up the Nigiri store and indices // Init sets up the Nigiri store and indices
func Init(collection *nigiri.Collection) { func Init(collection *nigiri.Collection) {
db = collection
store = nigiri.NewBaseStore[Item]() store = nigiri.NewBaseStore[Item]()
// Register custom indices // Register custom indices

View File

@ -28,11 +28,9 @@ const (
// Global store // Global store
var store *nigiri.BaseStore[Monster] var store *nigiri.BaseStore[Monster]
var db *nigiri.Collection
// Init sets up the Nigiri store and indices // Init sets up the Nigiri store and indices
func Init(collection *nigiri.Collection) { func Init(collection *nigiri.Collection) {
db = collection
store = nigiri.NewBaseStore[Monster]() store = nigiri.NewBaseStore[Monster]()
// Register custom indices // Register custom indices

View File

@ -18,11 +18,9 @@ type News struct {
// Global store // Global store
var store *nigiri.BaseStore[News] var store *nigiri.BaseStore[News]
var db *nigiri.Collection
// Init sets up the Nigiri store and indices // Init sets up the Nigiri store and indices
func Init(collection *nigiri.Collection) { func Init(collection *nigiri.Collection) {
db = collection
store = nigiri.NewBaseStore[News]() store = nigiri.NewBaseStore[News]()
// Register custom indices // Register custom indices

View File

@ -27,11 +27,9 @@ const (
// Global store // Global store
var store *nigiri.BaseStore[Spell] var store *nigiri.BaseStore[Spell]
var db *nigiri.Collection
// Init sets up the Nigiri store and indices // Init sets up the Nigiri store and indices
func Init(collection *nigiri.Collection) { func Init(collection *nigiri.Collection) {
db = collection
store = nigiri.NewBaseStore[Spell]() store = nigiri.NewBaseStore[Spell]()
// Register custom indices // Register custom indices

View File

@ -27,7 +27,6 @@ type Town struct {
// Global store // Global store
var store *nigiri.BaseStore[Town] var store *nigiri.BaseStore[Town]
var db *nigiri.Collection
// coordsKey creates a key for coordinate-based lookup // coordsKey creates a key for coordinate-based lookup
func coordsKey(x, y int) string { func coordsKey(x, y int) string {
@ -36,7 +35,6 @@ func coordsKey(x, y int) string {
// Init sets up the Nigiri store and indices // Init sets up the Nigiri store and indices
func Init(collection *nigiri.Collection) { func Init(collection *nigiri.Collection) {
db = collection
store = nigiri.NewBaseStore[Town]() store = nigiri.NewBaseStore[Town]()
// Register custom indices // Register custom indices

View File

@ -8,6 +8,7 @@ import (
"time" "time"
"dk/internal/helpers" "dk/internal/helpers"
"dk/internal/helpers/exp"
nigiri "git.sharkk.net/Sharkk/Nigiri" nigiri "git.sharkk.net/Sharkk/Nigiri"
) )
@ -61,11 +62,9 @@ type User struct {
// Global store // Global store
var store *nigiri.BaseStore[User] var store *nigiri.BaseStore[User]
var db *nigiri.Collection
// Init sets up the Nigiri store and indices // Init sets up the Nigiri store and indices
func Init(collection *nigiri.Collection) { func Init(collection *nigiri.Collection) {
db = collection
store = nigiri.NewBaseStore[User]() store = nigiri.NewBaseStore[User]()
// Register custom indices // Register custom indices
@ -348,8 +347,7 @@ func (u *User) SetPosition(x, y int) {
} }
func (u *User) ExpNeededForNextLevel() int { func (u *User) ExpNeededForNextLevel() int {
level := u.Level + 1 return exp.Calc(u.Level + 1)
return level * level * level
} }
func (u *User) GrantExp(expAmount int) { func (u *User) GrantExp(expAmount int) {
@ -382,7 +380,7 @@ func (u *User) ExpProgress() float64 {
return float64(u.Exp) / float64(u.ExpNeededForNextLevel()) * 100 return float64(u.Exp) / float64(u.ExpNeededForNextLevel()) * 100
} }
currentLevelExp := u.Level * u.Level * u.Level currentLevelExp := exp.Calc(u.Level)
nextLevelExp := u.ExpNeededForNextLevel() nextLevelExp := u.ExpNeededForNextLevel()
progressExp := u.Exp progressExp := u.Exp