summaryrefslogtreecommitdiff
path: root/app/lib/dice/roll.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/dice/roll.rb')
-rw-r--r--app/lib/dice/roll.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/lib/dice/roll.rb b/app/lib/dice/roll.rb
new file mode 100644
index 0000000..dd4788b
--- /dev/null
+++ b/app/lib/dice/roll.rb
@@ -0,0 +1,14 @@
+class Dice::Roll
+ attr_reader :sides, :face
+
+ # @param sides [Integer]
+ # @param face [Integer] (Optional) Rolled if not provided.
+ def initialize(sides, face = nil)
+ @sides = sides
+ @face = face || rand(1..sides)
+ end
+
+ def increase_side_below_max(max_value, increase_by)
+ @face += increase_by if @face < max_value
+ end
+end