Class: Fudge::Roll
Overview
This models a standard Fudge RPG dice pool.
Instance Attribute Summary
#dstr, #tree
Instance Method Summary
collapse
#average, #maximum, #minimum, #notes, #notes_to_s, #result
Methods included from RollString
#inspect
Constructor Details
#initialize(number = 4) ⇒ Roll
Returns a new instance of Roll.
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/dicebag/systems/fudge.rb', line 11
def initialize(number = 4)
@number = number
@total = nil
@tally = nil
dstr = (['1d6'] * number).join(' + ')
super(dstr)
end
|
Instance Method Details
#roll ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/dicebag/systems/fudge.rb', line 24
def roll
super
generate_tally
@total = @tally.count('+') - @tally.count('-')
[@total, tally_to_s]
end
|
#tally ⇒ Object
40
41
42
43
44
|
# File 'lib/dicebag/systems/fudge.rb', line 40
def tally
roll unless @tally
@tally
end
|
#to_s ⇒ Object
46
47
48
49
50
|
# File 'lib/dicebag/systems/fudge.rb', line 46
def to_s
base = "#{@number}dF"
@total ? "#{base} #{tally_to_s} => #{@total}" : base
end
|
#total ⇒ Object
34
35
36
37
38
|
# File 'lib/dicebag/systems/fudge.rb', line 34
def total
roll unless @total
@total
end
|