xp: Obfuscate current XP

master
Luther Wen Xu 2019-11-19 20:25:08 +07:00
parent 78c26c7ade
commit 05e08ce216
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
1 changed files with 5 additions and 1 deletions

@ -1,6 +1,7 @@
package main
import (
"crypto/rand"
"fmt"
"math"
"time"
@ -32,7 +33,10 @@ func messageCreate(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]
if level > 1 {
levelUpRequirement -= levelUpRequirementCache[level-2]