|
|
@ -27,10 +27,17 @@ func GetXP(userID string) int64 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func IncrementXP(userID string, value int64, newTime time.Time) {
|
|
|
|
func IncrementXP(userID string, value int64, newTime time.Time) {
|
|
|
|
db.Model(&PlayerLevel{}).
|
|
|
|
result := db.Model(&PlayerLevel{}).
|
|
|
|
Where(&PlayerLevel{UserID: userID}).
|
|
|
|
Where(&PlayerLevel{UserID: userID}).
|
|
|
|
UpdateColumn("xp", gorm.Expr("xp + ?", value)).
|
|
|
|
UpdateColumn("xp", gorm.Expr("xp + ?", value)).
|
|
|
|
UpdateColumn("last_active", newTime)
|
|
|
|
UpdateColumn("last_active", newTime)
|
|
|
|
|
|
|
|
if result.RowsAffected == 0 {
|
|
|
|
|
|
|
|
db.Create(&PlayerLevel{
|
|
|
|
|
|
|
|
UserID: userID,
|
|
|
|
|
|
|
|
XP: value,
|
|
|
|
|
|
|
|
LastActive: newTime,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func GetLastActive(userID string) time.Time {
|
|
|
|
func GetLastActive(userID string) time.Time {
|
|
|
|