class Meshchat::Ui::Command::Roll

Constants

REGEX

Public Class Methods

description() click to toggle source
# File lib/meshchat/ui/command/roll.rb, line 8
def self.description
  'rolls a die in the XdY+Z format'
end
new(input, message_dispatcher, message_factory, input_factory) click to toggle source
Calls superclass method Meshchat::Ui::Command::Base::new
# File lib/meshchat/ui/command/roll.rb, line 12
def initialize(input, message_dispatcher, message_factory, input_factory)
  super
  # input, X, Y, +Z, Z
  _, num, size, modifier, _operator, number = REGEX.match(input).to_a

  result = Array.new(num.to_i) { rand(size.to_i) + 1 }.inject(:+) + modifier.to_i
  @_input = "rolls #{num}d#{size}#{modifier != 0 ? modifier : ''} and gets #{result}"
end

Public Instance Methods

show_myself(message) click to toggle source
# File lib/meshchat/ui/command/roll.rb, line 21
def show_myself(message)
  Display.emote message.display
end
type() click to toggle source
# File lib/meshchat/ui/command/roll.rb, line 25
def type
  EMOTE
end