Class: FifthedSim::MultiplicationNode

Inherits:
DiceExpression show all
Defined in:
lib/fifthed_sim/nodes/multiplication_node.rb

Instance Method Summary collapse

Methods inherited from DiceExpression

#*, #+, #-, #/, #average, #difference_from_average, #max, #min, #or_greater, #or_least, #percentile, #range, #test_then, #to_dice_expression, #to_f, #to_i

Constructor Details

#initialize(lhs, rhs) ⇒ MultiplicationNode

Returns a new instance of MultiplicationNode.



6
7
8
9
# File 'lib/fifthed_sim/nodes/multiplication_node.rb', line 6

def initialize(lhs, rhs)
  @lhs = lhs
  @rhs = rhs
end

Instance Method Details

#distributionObject



15
16
17
# File 'lib/fifthed_sim/nodes/multiplication_node.rb', line 15

def distribution
  @lhs.distribution.convolve_multiply(@rhs.distribution)
end

#rerollObject



19
20
21
# File 'lib/fifthed_sim/nodes/multiplication_node.rb', line 19

def reroll
  self.class.new(@lhs.reroll, @rhs.reroll)
end

#valueObject



11
12
13
# File 'lib/fifthed_sim/nodes/multiplication_node.rb', line 11

def value
  @lhs.value * @rhs.value
end