feat(xp): xp update without reseting last event
This commit is contained in:
parent
f00941a17a
commit
9de1f3f90b
1 changed files with 15 additions and 0 deletions
15
xp/level.go
15
xp/level.go
|
@ -56,3 +56,18 @@ func onLastEventUpdate(c *Copaing) {
|
||||||
c.Save()
|
c.Save()
|
||||||
c.SetLastEvent()
|
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()
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue