dice_stats 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/Dice_Set.rb +13 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b9f6d1a0c998b07b539e685e61268aa6a226d138
|
|
4
|
+
data.tar.gz: 4d14abaaeb4367ba9de944faa4f0af38bb54271f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d455e7a7290ce64409899f2cde961ee9f0022c45b4b1df28e6f5c66e42c8fcb12803de87c1ba70cd7d1ac963c66b46c2c229ab55765186dee592fc98830a457
|
|
7
|
+
data.tar.gz: 46807c1896347316554414e5e34242e2e0b3308c75e2284a9395f4729d365fd22f37d3df2cca76cef4ade8d883ef359a17d6b22e1aad7cba9f03874149965b88
|
data/lib/Dice_Set.rb
CHANGED
|
@@ -83,7 +83,13 @@ module Dice_Stats
|
|
|
83
83
|
sub_string_split = split_string[i].downcase.split('d')
|
|
84
84
|
|
|
85
85
|
# Skip calculating the sub-die distribution if the total one is already cached
|
|
86
|
-
|
|
86
|
+
number_of_dice = sub_string_split[0].to_i
|
|
87
|
+
dice_faces = sub_string_split[1].to_i
|
|
88
|
+
|
|
89
|
+
calculate_probability = (probability_distribution == nil) && (number_of_dice * dice_faces <= 1000)
|
|
90
|
+
@aborted_probability_distribution = true if !calculate_probability
|
|
91
|
+
|
|
92
|
+
@dice << Dice.new(number_of_dice, dice_faces, calculate_probability)
|
|
87
93
|
elsif (split_string[i].to_i > 0)
|
|
88
94
|
@constant += split_string[i].to_i
|
|
89
95
|
else
|
|
@@ -96,7 +102,12 @@ module Dice_Stats
|
|
|
96
102
|
if probability_distribution != nil
|
|
97
103
|
@probability_distribution = probability_distribution
|
|
98
104
|
else
|
|
99
|
-
@
|
|
105
|
+
if @aborted_probability_distribution || (100_000 < @dice.inject(0) { |m,d| m + (d.sides * d.count) })
|
|
106
|
+
@probability_distribution = {}
|
|
107
|
+
@aborted_probability_distribution = true
|
|
108
|
+
else
|
|
109
|
+
@probability_distribution = combine_probability_distributions
|
|
110
|
+
end
|
|
100
111
|
end
|
|
101
112
|
|
|
102
113
|
if (@probability_distribution.inject(0) { |memo,(k,v)| memo + v }.round(3).to_f != 1.0)
|