|
|
@ -1,6 +1,7 @@
|
|
|
|
package main
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"crypto/rand"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"math"
|
|
|
|
"math"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
@ -32,7 +33,10 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func handleXPRequest(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|
|
|
func handleXPRequest(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|
|
|
level, xp := getLevelAndXP(s, m.Author.ID)
|
|
|
|
level, rawXP := getLevelAndXP(s, m.Author.ID)
|
|
|
|
|
|
|
|
randomSource := make([]byte, 1)
|
|
|
|
|
|
|
|
rand.Read(randomSource)
|
|
|
|
|
|
|
|
xp := rawXP - (rawXP % 100) + ((int(randomSource[0]) + 128) % 100)
|
|
|
|
levelUpRequirement := levelUpRequirementCache[level-1]
|
|
|
|
levelUpRequirement := levelUpRequirementCache[level-1]
|
|
|
|
if level > 1 {
|
|
|
|
if level > 1 {
|
|
|
|
levelUpRequirement -= levelUpRequirementCache[level-2]
|
|
|
|
levelUpRequirement -= levelUpRequirementCache[level-2]
|
|
|
|