dice_roller 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/dice_roller/dice_result.rb +17 -9
  2. metadata +2 -2
@@ -85,21 +85,29 @@ class DiceRoller::DiceResult
85
85
 
86
86
  # loop through the rolled results and count successes. values greater than
87
87
  # the reroll value are rolled again.
88
- @ten_result.each do |result|
89
- count += 1 if result >= min
90
- count -= 1 if subtract and result == 1
91
-
92
- # each pass through this loop is a rerolled dice
93
- while result >= reroll
94
- result = bonus_dice.roll
88
+ final_result = []
95
89
 
96
- # add the result for historical accuracy
97
- @ten_result << result
90
+ @ten_result.each do |dice|
91
+ this_dice = [dice]
98
92
 
93
+ this_dice.each do |result|
99
94
  count += 1 if result >= min
95
+ count -= 1 if subtract and result == 1
96
+
97
+ # each pass through this loop is a rerolled dice
98
+ if result >= reroll
99
+ bonus_result = bonus_dice.roll
100
+
101
+ # add the reroll result to the current dice's results, this will
102
+ # reroll as appropriate
103
+ this_dice << bonus_result
104
+ end
100
105
  end
106
+
107
+ final_result += this_dice
101
108
  end
102
109
 
110
+ @ten_result = final_result
103
111
  @rerolled = true
104
112
  count
105
113
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dice_roller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-01 00:00:00.000000000 Z
12
+ date: 2012-05-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! " dice_roller is a pure ruby application that rolls dice for role
15
15
  playing games.\n it is primarily built to handle d20 or Storytelling style rolls.\n"