forked from syntruth/Dice-Bag
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgurps_dice.rb
More file actions
42 lines (30 loc) · 764 Bytes
/
gurps_dice.rb
File metadata and controls
42 lines (30 loc) · 764 Bytes
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
require "dicelib"
module Dice
class GurpsRoll < SimpleRoll
def initialize
super("3d6")
end
def roll(target, mod=0)
mod = 0 if not mod.is_a?(Fixnum)
crit_success = [3, 4]
crit_failure = [18]
total_target = target + mod
crit_success.push(5) if total_target >= 15
crit_success.push(6) if total_target >= 16
crit_failure.push(17) if total_target <= 15
result = super().total()
success = if crit_success.include?(result)
:critical_success
elsif crit_failure.include?(result)
:critical_failure
elsif result <= total_target
:success
else
:failure
end
return [success, result]
end
# End class
end
# End module
end