|
|
@ -8,6 +8,8 @@ import (
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const notInGeneralNerf = 10
|
|
|
|
|
|
|
|
|
|
|
|
var lastMessage = make(map[string]time.Time)
|
|
|
|
var lastMessage = make(map[string]time.Time)
|
|
|
|
var incrementMutex = sync.Mutex{}
|
|
|
|
var incrementMutex = sync.Mutex{}
|
|
|
|
var levelUpRequirementCache [30]int
|
|
|
|
var levelUpRequirementCache [30]int
|
|
|
@ -21,8 +23,11 @@ func init() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func incrementXP(dg *discordgo.Session, discordID string) {
|
|
|
|
func incrementXP(dg *discordgo.Session, discordID string, inGeneral bool) {
|
|
|
|
amountToIncrement := calculateIncrement(discordID)
|
|
|
|
amountToIncrement := calculateIncrement(discordID)
|
|
|
|
|
|
|
|
if !inGeneral {
|
|
|
|
|
|
|
|
amountToIncrement /= notInGeneralNerf
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tx, err := db.Begin()
|
|
|
|
tx, err := db.Begin()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -71,8 +76,8 @@ func calculateIncrement(discordID string) int {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Constructed on Desmos:
|
|
|
|
//Constructed on Desmos:
|
|
|
|
//y=\frac{100}{\left(1+e^{-\left(\frac{x-15}{3}\right)}\right)}
|
|
|
|
//y=\frac{100}{\left(1+e^{-\left(x-5\right)}\right)}
|
|
|
|
return int(100 / (1 + math.Pow(math.E, -((delta.Seconds()-15)/3))))
|
|
|
|
return int(100 / (1 + math.Pow(math.E, -(delta.Seconds()-5))))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func convertXPIntoLevel(xp int) (int, int) {
|
|
|
|
func convertXPIntoLevel(xp int) (int, int) {
|
|
|
|