diff --git a/reactions.go b/reactions.go index 1c5acdc..4108e0b 100644 --- a/reactions.go +++ b/reactions.go @@ -32,7 +32,6 @@ func reactions(message model.Message) (string, bool) { reactionContent = decisions(message.From, message.Content) case "!dadjoke": reactionContent = jokeTrigger() - } return reactionContent, reactionContent != "" diff --git a/trollLauncher.go b/trollLauncher.go new file mode 100644 index 0000000..47f67e9 --- /dev/null +++ b/trollLauncher.go @@ -0,0 +1,55 @@ +package main + +import ( + "math/rand" + "strings" +) + +func troll(nick, msg string) string { + const TROLL_USAGE = "Usage: !troll " + + msg = strings.Trim(msg, "!troll ") + if len(msg) > 1 || len(msg) < 1 { + return TROLL_USAGE + } + + target := string(msg) + numTrolls, dmg, dmgType := launchTrolls() + + switch dmg { + case "": + return "The troll launcher has malfunctioned." + case "miss": + return "Wha?! The trolls missed! That, like, never happens!" + } + + return nick + " fires " + numTrolls + " at " + target + ", dealing " + dmg + " points of " + dmgType + " damage!" +} + +func launchTrolls() (numTrolls, dmg, dmgType string) { + damage_type := [13]string{"bludgeoning", "piercing", "slashing", "cold", "fire", "acid", "poison", + "psychic", "necrotic", "radiant", "lightning", "thunder", "force"} + + trolls := rand.Intn(10) + if trolls == 0 { + return string(trolls), "", "" + } + + dmg = trollDamage(trolls) + + return string(trolls), dmg, damage_type[rand.Intn(12)] +} + +func trollDamage(trolls int) string { + i := 0 + trollDmg := 0 + for i < trolls { + trollDmg += rand.Intn(20) + } + + if trollDmg == 0 { + return "miss" + } + + return string(trollDmg) +}