feat(xp): xp update without reseting last event

This commit is contained in:
Anhgelus Morhtuuzh 2024-04-15 18:59:10 +02:00
parent f00941a17a
commit 9de1f3f90b
No known key found for this signature in database
GPG key ID: CF4550297832A29F

View file

@ -56,3 +56,18 @@ func onLastEventUpdate(c *Copaing) {
c.Save()
c.SetLastEvent()
}
func onXPUpdate(c *Copaing) {
h := c.HourSinceLastEvent()
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
c.AddXPAlreadyRemoved(0)
} else {
c.XP -= l - c.XPAlreadyRemoved()
c.AddXPAlreadyRemoved(l - xp)
}
c.Save()
}