summaryrefslogtreecommitdiff
path: root/app/lib/dice/roll.rb
blob: dd4788bd95beb8556008b9a27b618ddbe5510fd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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