feat(xp): storage of already removed xp

This commit is contained in:
Anhgelus Morhtuuzh 2024-04-15 18:56:21 +02:00
parent 2aaeb2115b
commit f00941a17a
No known key found for this signature in database
GPG key ID: CF4550297832A29F
2 changed files with 79 additions and 4 deletions

View file

@ -45,7 +45,14 @@ func onNewLevel(s *discordgo.Session, m *discordgo.Member, level uint) {
func onLastEventUpdate(c *Copaing) {
h := c.HourSinceLastEvent()
c.XP -= Lose(h, c.XP)
l := Lose(h, c.XP)
xp := c.XPAlreadyRemoved()
if l-xp < 0 {
utils.SendWarn("lose - xp already removed is negative", "lose", l, "xp", xp)
c.XP = 0
} else {
c.XP -= l - c.XPAlreadyRemoved()
}
c.Save()
c.SetLastEvent()
}