From 3dbdbf046028ef05b8bdda117431a310d9142a0c Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Sat, 9 Jan 2021 11:59:31 +0000 Subject: gotta roll for there to have been a last roll --- iada.rb | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'iada.rb') diff --git a/iada.rb b/iada.rb index 6ee4114..ba14864 100755 --- a/iada.rb +++ b/iada.rb @@ -46,22 +46,32 @@ end bot.command(:again, description: "Repeat your last vs roll.") do |event| roll, vs, fr = last_roll[event.author.id] - roll = rand(100) - last_roll[event.author.id] = [roll, vs, fr] + if roll.nil? + res = "You need to roll something first, #{event.author.display_name}!" + else + roll = rand(100) + last_roll[event.author.id] = [roll, vs, fr] + + res = human_result(event.author.display_name, roll, vs, fr, "Repeat: ") + end - res = human_result(event.author.display_name, roll, vs, fr, "Repeat: ") puts res res end bot.command(:moxie, description: "Perform a moxie digit swap on your last vs roll.") do |event| roll, vs, fr = last_roll[event.author.id] - roll = ((roll % 10) * 10) + (roll / 10) - last_roll[event.author.id] = [roll, vs, fr] + if roll.nil? + res = "You need to roll something first, #{event.author.display_name}!" + else + roll = ((roll % 10) * 10) + (roll / 10) + last_roll[event.author.id] = [roll, vs, fr] + + res = human_result(event.author.display_name, roll, vs, fr, "Moxie swap: ") + end - res = human_result(event.author.display_name, roll, vs, fr, "Moxie swap: ") puts res res end @@ -69,7 +79,12 @@ end bot.command(:remind, description: "Get a reminder of the result of your last vs roll.") do |event| roll, vs, fr = last_roll[event.author.id] - res = human_result(event.author.display_name, roll, vs, fr, "Reminder: ") + if roll.nil? + res = "You need to roll something first, #{event.author.display_name}!" + else + res = human_result(event.author.display_name, roll, vs, fr, "Reminder: ") + end + puts res res end -- cgit v1.2.3