diff options
| author | Anhgelus Morhtuuzh <anhgelus.morhtuuzh@proton.me> | 2024-04-15 18:56:21 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <anhgelus.morhtuuzh@proton.me> | 2024-04-15 18:56:21 +0200 |
| commit | f00941a17ad1c789b7354c685d84386ed7904163 (patch) | |
| tree | 49c4140aa02214380439682e3ebf3d0b8746bbf1 /xp/level.go | |
| parent | 2aaeb2115b25952b71113a683b466c00cb92e690 (diff) | |
feat(xp): storage of already removed xp
Diffstat (limited to 'xp/level.go')
| -rw-r--r-- | xp/level.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/xp/level.go b/xp/level.go index 574a127..2ec6106 100644 --- a/xp/level.go +++ b/xp/level.go @@ -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() } |
