Class: CARPS::RolePlayInterface

Inherits:
QuitInterface show all
Defined in:
lib/carps/mod/interface.rb

Overview

Interface for roleplaying

Direct Known Subclasses

DM::Interface, Player::Interface

Instance Method Summary collapse

Methods inherited from Interface

#run

Constructor Details

#initializeRolePlayInterface

Returns a new instance of RolePlayInterface.



29
30
31
32
33
34
# File 'lib/carps/mod/interface.rb', line 29

def initialize
   super
   add_command "d", "Roll a dice with a given number of sides.", "SIDES"
   add_command "int", "An random integer between MIN and MAX.", "MIN", "MAX"
   add_command "dec", "A decimal between MIN and MAX.", "MIN", "MAX"
end

Instance Method Details

#d(n) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/carps/mod/interface.rb', line 36

def d n
   i = n.to_i
   if i <= 1
      UI::put_error "A dice must have more than 1 side."
   else
      puts Dice::rint(1, i)
   end
end

#dec(min, max) ⇒ Object



55
56
57
58
59
60
61
62
63
# File 'lib/carps/mod/interface.rb', line 55

def dec min, max
   min = min.to_f
   max = max.to_f
   if min >= max
      bounds_err
   else
      puts Dice::rfloat(min, max)
   end
end

#int(min, max) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/carps/mod/interface.rb', line 45

def int min, max
   min = min.to_i
   max = max.to_i
   if min >= max
      bounds_err
   else
      puts Dice::rint(min, max)
   end
end