From a11d9c94d2a8b9929742cbe9506df316c225d8b8 Mon Sep 17 00:00:00 2001 From: Luther Wen Xu Date: Mon, 18 Nov 2019 23:23:40 +0800 Subject: [PATCH] xp: Buff general messages and nerf command messages --- messageCreate.go | 4 +++- xp.go | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/messageCreate.go b/messageCreate.go index c5423a0..71e330b 100644 --- a/messageCreate.go +++ b/messageCreate.go @@ -6,11 +6,13 @@ import ( "github.com/bwmarrin/discordgo" ) +const generalChannelID = "645550570001924098" + func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { if m.Author.Bot { return } - go incrementXP(s, m.Author.ID) + go incrementXP(s, m.Author.ID, m.ChannelID == generalChannelID) if m.Content == "pgqlevel" { handleXPRequest(s, m) diff --git a/xp.go b/xp.go index dd7a312..b90ec82 100644 --- a/xp.go +++ b/xp.go @@ -8,6 +8,8 @@ import ( "github.com/bwmarrin/discordgo" ) +const notInGeneralNerf = 10 + var lastMessage = make(map[string]time.Time) var incrementMutex = sync.Mutex{} 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) + if !inGeneral { + amountToIncrement /= notInGeneralNerf + } tx, err := db.Begin() if err != nil { @@ -71,8 +76,8 @@ func calculateIncrement(discordID string) int { } //Constructed on Desmos: - //y=\frac{100}{\left(1+e^{-\left(\frac{x-15}{3}\right)}\right)} - return int(100 / (1 + math.Pow(math.E, -((delta.Seconds()-15)/3)))) + //y=\frac{100}{\left(1+e^{-\left(x-5\right)}\right)} + return int(100 / (1 + math.Pow(math.E, -(delta.Seconds()-5)))) } func convertXPIntoLevel(xp int) (int, int) {