module Crapshoot

line 33 “lib/crapshoot/parser/scan.rl”

Constants

VERSION

Public Class Methods

roll(expression) click to toggle source

Rolls dice for the given expression. @param [String] crapshoot expression to evaluate, such as ‘4d6v + 8’ @return [Crapshoot::Result] the result of the expression, can be used as a normal Integer

# File lib/crapshoot.rb, line 12
def self.roll(expression)
  scanner = Scanner.new
  postfixer = Postfixer.new
  evaluator = Evaluator.new

  tokens = scanner.parse expression
  postfix_tokens = postfixer.postfixify tokens
  result = evaluator.evaluate postfix_tokens

  return result
end