snow/person/season.go
Eccentric 250e85732d feat: update to latest;
new shop system
more config options
arena & hype
per season stats
battle pass
better variant system
complete vbuck & starter pack store
fix bugs related to deleting account
update launcher endpoints
fixed gift loot not deleting
2024-03-10 18:16:42 +00:00

55 lines
1010 B
Go

package person
import (
"github.com/ectrc/snow/storage"
"github.com/google/uuid"
)
type SeasonStats struct {
ID string
PersonID string
Season int
SeasonXP int
BookXP int
BookPurchased bool
Hype int
}
func NewSeasonStats(season int) *SeasonStats {
return &SeasonStats{
ID: uuid.New().String(),
Season: season,
}
}
func (s *SeasonStats) ToDatabase(personId string) *storage.DB_SeasonStat {
return &storage.DB_SeasonStat{
ID: s.ID,
PersonID: personId,
Season: s.Season,
SeasonXP: s.SeasonXP,
BookXP: s.BookXP,
BookPurchased: s.BookPurchased,
Hype: s.Hype,
}
}
func (s *SeasonStats) Save() {
storage.Repo.SaveSeasonStats(s.ToDatabase(s.PersonID))
}
func (s *SeasonStats) Delete() {
storage.Repo.DeleteSeasonStats(s.ID)
}
func FromDatabaseSeasonStats(db storage.DB_SeasonStat) *SeasonStats {
return &SeasonStats{
ID: db.ID,
PersonID: db.PersonID,
Season: db.Season,
SeasonXP: db.SeasonXP,
BookXP: db.BookXP,
BookPurchased: db.BookPurchased,
Hype: db.Hype,
}
}