-
Notifications
You must be signed in to change notification settings - Fork 2
/
roll.rb
executable file
·60 lines (45 loc) · 1.39 KB
/
roll.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env ruby
# roll.rb
# descriptive die rolls for FUDGE/Fate, as per an idea developed
# by Vincent Baker for his Jastenave game.
# cf. https://twitter.com/lumpleygames/status/403556521579384832
#
# Also appeared later (and surely independently) in Pyramid Vol2
# "Dice of Destiny" by Justin Bacon
# http://www.sjgames.com/pyramid/sample.html?id=1686
# http://thealexandrian.net/wordpress/2781/roleplaying-games/dice-of-destiny
class Roll
DESCRIPTIONS = {
# https://twitter.com/lumpleygames/status/403556521579384832
jastenave: %w[environment instinct training equipment],
# http://thealexandrian.net/wordpress/2793/roleplaying-games/dice-of-destiny-part-2-qualities
destiny: ['time required', 'outside influences', 'skill', 'style']
# 'knowledge', 'luck', 'power', 'finesse',
}.freeze
FORMAT_DF = {
-1 => "-",
0 => " ",
1 => "+"
}
def initialize(set)
@results_h = DESCRIPTIONS[set].inject({}, &method(:get_results))
@total = @results_h.map(&:last).inject(:+)
end
def results
[@total, @results_h.inject({}, &method(:format))]
end
private
def dF
rand(-1..1)
end
def format(memo, pair)
concern, result = *pair
new_pair = { concern => FORMAT_DF[result] }
memo.merge(new_pair)
end
def get_results(memo, desc)
memo.merge(desc => dF)
end
end
set = ARGV[0] || :destiny
puts Roll.new(set.to_sym).results