Class: FifthedSim::GreaterNode
Instance Method Summary
collapse
#*, #+, #-, #/, #average, #difference_from_average, #or_greater, #or_least, #percentile, #range, #test_then, #to_dice_expression, #to_f, #to_i
Constructor Details
#initialize(lhs, rhs) ⇒ GreaterNode
Returns a new instance of GreaterNode.
7
8
9
|
# File 'lib/fifthed_sim/nodes/greater_node.rb', line 7
def initialize(lhs, rhs)
@lhs, @rhs = lhs, rhs
end
|
Instance Method Details
#distribution ⇒ Object
15
16
17
|
# File 'lib/fifthed_sim/nodes/greater_node.rb', line 15
def distribution
@lhs.distribution.convolve_greater(@rhs.distribution)
end
|
#expression_equation ⇒ Object
37
38
39
|
# File 'lib/fifthed_sim/nodes/greater_node.rb', line 37
def expression_equation
"max(#{lhs.expression_equation}, #{rhs.expression_equation})"
end
|
#max ⇒ Object
27
28
29
|
# File 'lib/fifthed_sim/nodes/greater_node.rb', line 27
def max
[@lhs.max, @rhs.max].max
end
|
#min ⇒ Object
23
24
25
|
# File 'lib/fifthed_sim/nodes/greater_node.rb', line 23
def min
[@lhs.min, @rhs.min].max
end
|
#reroll ⇒ Object
19
20
21
|
# File 'lib/fifthed_sim/nodes/greater_node.rb', line 19
def reroll
self.class.new(@lhs.reroll, @rhs.reroll)
end
|
#value ⇒ Object
11
12
13
|
# File 'lib/fifthed_sim/nodes/greater_node.rb', line 11
def value
[@lhs.value, @rhs.value].max
end
|
#value_equation(terminal: false) ⇒ Object
31
32
33
34
35
|
# File 'lib/fifthed_sim/nodes/greater_node.rb', line 31
def value_equation(terminal: false)
lhs = @lhs.value_equation(terminal: terminal)
rhs = @rhs.value_equation(terminal: terminal)
"max(#{lhs}, #{rhs}"
end
|