Class: Waylon::Skills::Dice

Inherits:
Waylon::Skill
  • Object
show all
Defined in:
lib/waylon/skills/dice.rb

Overview

A Waylon Skill for rolling some dice

Instance Method Summary collapse

Instance Method Details

#roll_diceObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/waylon/skills/dice.rb', line 16

def roll_dice
  react :game_die

  dice_size = tokens.last

  if dice_size
    reply "You rolled a #{(1..dice_size.to_i).to_a.sample}"
  else
    results = 2.times.map { (1..6).to_a.sample }
    reply "You rolled a #{results.first} and a #{results.last}"
  end
end