Browse Source

Add function for ceelo to roll until it gets a hand

develop
Matthew Faltys 6 years ago
parent
commit
2fc6f9e66c
  1. 28
      lorebot/lorebot.go

28
lorebot/lorebot.go

@ -355,9 +355,33 @@ func dicerollhandler(rtm *slack.RTM, ev *slack.MessageEvent) {
} }
func ceelorollhandler(rtm *slack.RTM, ev *slack.MessageEvent) { func ceelorollhandler(rtm *slack.RTM, ev *slack.MessageEvent) {
//fmt.Print(rand.Intn(100))
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())
rtm.SendMessage(rtm.NewOutgoingMessage(fmt.Sprintf("%d, %d, %d", (rand.Intn(6)+1), (rand.Intn(6)+1), (rand.Intn(6)+1)), ev.Channel))
// set condition
hand := false
for !hand {
roll0 := rand.Intn(6) + 1
roll1 := rand.Intn(6) + 1
roll2 := rand.Intn(6) + 1
rtm.SendMessage(rtm.NewOutgoingMessage(fmt.Sprintf("%d, %d, %d", roll0, roll1, roll2), ev.Channel))
// check for pair
if (roll0 == roll1) || (roll0 == roll2) || (roll1 == roll2) {
hand = true
}
a := fmt.Sprintf("%d%d%d", roll0, roll1, roll2)
// check for instant win
if strings.Contains(a, "4") && strings.Contains(a, "5") && strings.Contains(a, "6") {
hand = true
}
// check for instant loss
if strings.Contains(a, "1") && strings.Contains(a, "2") && strings.Contains(a, "3") {
hand = true
}
time.Sleep(1000 * time.Millisecond)
}
} }
func rrhandler(rtm *slack.RTM, ev *slack.MessageEvent) { func rrhandler(rtm *slack.RTM, ev *slack.MessageEvent) {

Loading…
Cancel
Save