feat(debug): adapt xp functions while debug is enabled

This commit is contained in:
Anhgelus Morhtuuzh 2024-04-15 19:15:37 +02:00
parent 84bf4caed2
commit 9f9c27f422
No known key found for this signature in database
GPG key ID: CF4550297832A29F
2 changed files with 13 additions and 1 deletions

View file

@ -1,6 +1,9 @@
package xp package xp
import "math" import (
"github.com/anhgelus/gokord"
"math"
)
func XPMessage(length uint, diversity uint) uint { func XPMessage(length uint, diversity uint) uint {
return uint(math.Floor( return uint(math.Floor(
@ -27,6 +30,11 @@ func XPForLevel(level uint) uint {
} }
func Lose(time uint, xp uint) uint { func Lose(time uint, xp uint) uint {
if gokord.Debug {
return uint(math.Floor(
math.Pow(float64(time), 3) * math.Pow(10, -2+math.Log(float64(time))) * math.Floor(float64(xp/500)+1),
)) // a little bit faster to lose xp
}
return uint(math.Floor( return uint(math.Floor(
math.Pow(float64(time), 2) * math.Pow(10, -2+math.Log(float64(time/85))) * math.Floor(float64(xp/500)+1), math.Pow(float64(time), 2) * math.Pow(10, -2+math.Log(float64(time/85))) * math.Floor(float64(xp/500)+1),
)) ))

View file

@ -9,6 +9,7 @@ import (
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
"gorm.io/gorm" "gorm.io/gorm"
"math"
"strconv" "strconv"
"time" "time"
) )
@ -98,6 +99,9 @@ func (c *Copaing) HourSinceLastEvent() uint {
) )
return 0 return 0
} }
if gokord.Debug {
return uint(math.Floor(float64(t-int64(last)) / 60)) // not hours of unix, is minutes of unix
}
return utils.HoursOfUnix(t - int64(last)) return utils.HoursOfUnix(t - int64(last))
} }