droll 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +3 -6
- data/README.md +15 -36
- data/bin/droll +3 -2
- data/bin/drollbot +2 -0
- data/coil.txt +30 -0
- data/etc/drollbot.conf.sample +1 -1
- data/lib/droll.rb +119 -127
- metadata +31 -28
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 71a0119998fc4e1291ae71ee98e3a8a4c56b535310607c833e8d66d658c01656
|
4
|
+
data.tar.gz: 616037b0b9d048d07ffdc9bb38f56b3242d8c20bd7d98965d01dee78f3e9512a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8a57820b01036c4558a9927dddaef16225df3730c20004a73f45787c9854b887b0e6fd3eb12578ed1097fdb6187dd4cc497a41746f82c3970dbe8f7fa3c5421f
|
7
|
+
data.tar.gz: 26c82de51ba9a45f7f09446ff6669ee12c41c650cb1bed32a408ac98148b9e0bf718286515fa3b33d8563d78c7bad5fa63f3e52171018cebe57d4398c183ee25
|
data/COPYING
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
The droll project is copyright 2010 Chad Perrin, and may be distributed under
|
2
|
-
the terms of the Open
|
3
|
-
|
4
|
-
The Rubinius implementation of Ruby allows distribution under the terms of the
|
5
|
-
MIT/X11 license. See the [Rubinius project](http://rubini.us) for more details
|
6
|
-
about it.
|
2
|
+
the terms of the Copyfree Open Innovation License or the Open Works License, at
|
3
|
+
your discretion. See the owl.txt and coil.txt files for license text.
|
7
4
|
|
8
5
|
The MRI/YARV implementation of Ruby is distributed under the terms of the Ruby
|
9
6
|
license, which also allows distribution under the terms of the Simplified
|
@@ -11,4 +8,4 @@ license, which also allows distribution under the terms of the Simplified
|
|
11
8
|
|
12
9
|
Drollbot, in addition to the standard library, requires the Isaac library.
|
13
10
|
Isaac may be distributed under the terms of the MIT/X11 license. See the
|
14
|
-
[Isaac project](https://github.com/
|
11
|
+
[Isaac project](https://github.com/vangberg/isaac) for more details.
|
data/README.md
CHANGED
@@ -58,8 +58,8 @@ Just use the gem command:
|
|
58
58
|
|
59
59
|
$ gem install droll
|
60
60
|
|
61
|
-
You can also download the gem package from the [
|
62
|
-
|
61
|
+
You can also download the gem package from the [FossRec project][fossrec] and
|
62
|
+
use the gem command to install it:
|
63
63
|
|
64
64
|
$ gem install droll-<version>.gem
|
65
65
|
|
@@ -79,11 +79,11 @@ file.
|
|
79
79
|
|
80
80
|
### Ruby 1.8
|
81
81
|
|
82
|
-
Droll assumes Ruby 1.9.x, and some die code validation (for zero-based
|
83
|
-
codes, e.g. 1d05) does not work properly with older Ruby versions.
|
84
|
-
it will not install on a system using a version of Ruby older than
|
85
|
-
this can be overridden if you wish by using the `-f` option with the
|
86
|
-
install` command:
|
82
|
+
Droll assumes Ruby 1.9.x or later, and some die code validation (for zero-based
|
83
|
+
die codes, e.g. 1d05) does not work properly with older Ruby versions.
|
84
|
+
Normally, it will not install on a system using a version of Ruby older than
|
85
|
+
1.9, but this can be overridden if you wish by using the `-f` option with the
|
86
|
+
`gem install` command:
|
87
87
|
|
88
88
|
$ gem install -f droll
|
89
89
|
|
@@ -165,39 +165,18 @@ under the `etc` subdirectory. The example configuration file is called
|
|
165
165
|
to see more information about configuring drollbot.
|
166
166
|
|
167
167
|
|
168
|
-
##
|
168
|
+
## licenses
|
169
169
|
|
170
|
-
Droll project files may be redistributed under the terms of the [
|
171
|
-
License][owl]
|
172
|
-
|
173
|
-
|
170
|
+
Droll project files may be redistributed under the terms of the [COIL][coil] or
|
171
|
+
the [Open Works License][owl], at your option; it is "dual-licensed". These
|
172
|
+
licenses were chosen with a conscious adherence to copyfree policies. See the
|
173
|
+
[Copyfree Initiative][copyfree] site for more details about the copyfree
|
174
|
+
philosophy of licensing.
|
174
175
|
|
175
176
|
See the COPYING file in the project repository for more information about
|
176
177
|
copyright and licensing for droll and the code associated with it.
|
177
178
|
|
178
|
-
|
179
|
-
## contributions
|
180
|
-
|
181
|
-
If you wish to contribute to the project, please feel free to do so.
|
182
|
-
|
183
|
-
Mercurial (in the form of the hg tool) offers a simple way to produce a patch,
|
184
|
-
using the `export` command. To produce a patch based on the most recent
|
185
|
-
commits in your local clone of the project, this command should suffice to
|
186
|
-
produce a usable patch for an update from the immediately previous commit:
|
187
|
-
|
188
|
-
$ hg export tip
|
189
|
-
|
190
|
-
* Patches may be submitted via the issue tracker, as a comment with attachment
|
191
|
-
in response to whatever issue it fixes.
|
192
|
-
* Patches can also be submitted to Chad Perrin via email, using the code at
|
193
|
-
apotheon dot net address.
|
194
|
-
* Another way to submit contributions is to clone the project on
|
195
|
-
[Bitbucket][bitbucket] and send a "pull request" from the clone when changes
|
196
|
-
have been made. The process of submitting contributions via fork and pull
|
197
|
-
request is described in a TechRepublic article:
|
198
|
-
[*Contribute to Bitbucket Projects Using Forks and Pull Requests*][forkpull].
|
199
|
-
|
179
|
+
[coil]: http://coil.apotheon.org
|
200
180
|
[owl]: http://owl.apotheon.org
|
201
181
|
[copyfree]: http://copyfree.org
|
202
|
-
[
|
203
|
-
[forkpull]: http://blogs.techrepublic.com.com/programming-and-development/?p=4028
|
182
|
+
[fossrec]: http://droll.fossrec.com
|
data/bin/droll
CHANGED
@@ -127,8 +127,9 @@ EOF
|
|
127
127
|
version_help = <<EOF
|
128
128
|
|
129
129
|
Droll #{Droll.version}, Copyright 2010, 2011, 2012 Chad Perrin
|
130
|
-
This software may be distributed under the terms of the Open
|
131
|
-
|
130
|
+
This software may be distributed under the terms of the Copyfree Open
|
131
|
+
Innovation License or Open Works License, at recipient's option.
|
132
|
+
See https://owl.apotheon.org and https://coil.apotheon.org for license details.
|
132
133
|
|
133
134
|
EOF
|
134
135
|
|
data/bin/drollbot
CHANGED
data/coil.txt
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Copyfree Open Innovation License
|
2
|
+
|
3
|
+
This is version 0.6 of the Copyfree Open Innovation License.
|
4
|
+
|
5
|
+
## Terms and Conditions
|
6
|
+
|
7
|
+
Redistributions, modified or unmodified, in whole or in part, must retain
|
8
|
+
applicable notices of copyright or other legal privilege, these conditions, and
|
9
|
+
the following license terms and disclaimer. Subject to these conditions, each
|
10
|
+
holder of copyright or other legal privileges, author or assembler, and
|
11
|
+
contributor of this work, henceforth "licensor", hereby grants to any person
|
12
|
+
who obtains a copy of this work in any form:
|
13
|
+
|
14
|
+
1. Permission to reproduce, modify, distribute, publish, sell, sublicense, use,
|
15
|
+
and/or otherwise deal in the licensed material without restriction.
|
16
|
+
|
17
|
+
2. A perpetual, worldwide, non-exclusive, royalty-free, gratis, irrevocable
|
18
|
+
patent license to make, have made, provide, transfer, import, use, and/or
|
19
|
+
otherwise deal in the licensed material without restriction, for any and all
|
20
|
+
patents held by such licensor and necessarily infringed by the form of the work
|
21
|
+
upon distribution of that licensor's contribution to the work under the terms
|
22
|
+
of this license.
|
23
|
+
|
24
|
+
NO WARRANTY OF ANY KIND IS IMPLIED BY, OR SHOULD BE INFERRED FROM, THIS LICENSE
|
25
|
+
OR THE ACT OF DISTRIBUTION UNDER THE TERMS OF THIS LICENSE, INCLUDING BUT NOT
|
26
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
|
27
|
+
AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, ASSEMBLERS, OR HOLDERS OF
|
28
|
+
COPYRIGHT OR OTHER LEGAL PRIVILEGE BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
|
29
|
+
LIABILITY, WHETHER IN ACTION OF CONTRACT, TORT, OR OTHERWISE ARISING FROM, OUT
|
30
|
+
OF, OR IN CONNECTION WITH THE WORK OR THE USE OF OR OTHER DEALINGS IN THE WORK.
|
data/etc/drollbot.conf.sample
CHANGED
data/lib/droll.rb
CHANGED
@@ -48,7 +48,7 @@ exploding occurs, leaving an 11 result from the virtual dice. As normal, when
|
|
48
48
|
all die rolling is resolved and summed, the modifier (+7 in this case) is
|
49
49
|
applied to the total.
|
50
50
|
|
51
|
-
====
|
51
|
+
==== Threshold Acceptance
|
52
52
|
|
53
53
|
Using k instead of d, x, or e in the die code indicates that out of the number
|
54
54
|
of dice rolled, only the highest of them will be kept ("k" is for "keep").
|
@@ -58,7 +58,7 @@ Thus, for this die code, only the highest result is kept:
|
|
58
58
|
|
59
59
|
If the k is capitalized, the lowest result is kept instead of the highest.
|
60
60
|
|
61
|
-
====
|
61
|
+
==== Threshold Counting
|
62
62
|
|
63
63
|
In some cases, it may be desirable to count the number of dice that produce a
|
64
64
|
result of the maximum value the die can produce. Use n instead of d, x, e, or
|
@@ -67,12 +67,12 @@ k in this die code:
|
|
67
67
|
3n4
|
68
68
|
|
69
69
|
This will yield a result that is a count of four-sided dice that meet a
|
70
|
-
|
71
|
-
"number", as in "the number of dice that meet or exceed the
|
70
|
+
threshold equal to the maximum value of the die (4). The "n" is short for
|
71
|
+
"number", as in "the number of dice that meet or exceed the threshold".
|
72
72
|
|
73
|
-
==== Alternate
|
73
|
+
==== Alternate Thresholds
|
74
74
|
|
75
|
-
A
|
75
|
+
A threshold number may be specified by a period/fullstop character followed by
|
76
76
|
a number, with any modifiers coming after it:
|
77
77
|
|
78
78
|
3x4.3+7
|
@@ -80,21 +80,21 @@ a number, with any modifiers coming after it:
|
|
80
80
|
In this case, the die code is treated the same way as in the previous 3x4+7
|
81
81
|
example, except that it explodes on 3 or 4, and not just on 4.
|
82
82
|
|
83
|
-
For
|
83
|
+
For threshold acceptance, the threshold number is used to determine how many
|
84
84
|
of the highest or lowest die values will be kept. In this die code, then, the
|
85
85
|
result is the sum of the highest three die values:
|
86
86
|
|
87
87
|
4k6.3
|
88
88
|
|
89
|
-
In the case of
|
90
|
-
four-sided dice that meet or exceed a
|
89
|
+
In the case of threshold counting, it would yield a result that is a count of
|
90
|
+
four-sided dice that meet or exceed a threshold of 3, which means a count of
|
91
91
|
all dice with values of 3 or 4, before adding the number 7 to the total with
|
92
92
|
this die code:
|
93
93
|
|
94
94
|
3n4.3+7
|
95
95
|
|
96
|
-
Note that for
|
97
|
-
|
96
|
+
Note that for threshold counting, the modifier is applied to the count, and not
|
97
|
+
to die roll values.
|
98
98
|
|
99
99
|
==== Alternate Minimum Value
|
100
100
|
|
@@ -129,6 +129,7 @@ The above example produces output like the API usage example.
|
|
129
129
|
|
130
130
|
|
131
131
|
class Droll
|
132
|
+
attr_reader :dcode, :dice, :dmax, :dval, :modifier, :pcode, :roll_type, :sign, :threshold
|
132
133
|
|
133
134
|
=begin rdoc
|
134
135
|
|
@@ -136,55 +137,47 @@ This method returns the version number for the Droll gem.
|
|
136
137
|
|
137
138
|
=end
|
138
139
|
|
139
|
-
def self.version; '1.0.
|
140
|
+
def self.version; '1.0.3'; end
|
140
141
|
|
141
142
|
=begin rdoc
|
142
143
|
|
143
|
-
The +
|
144
|
+
The +die_code+ argument is any valid die code recognized by Droll.
|
144
145
|
|
145
146
|
Droll.new '4x7+3'
|
146
147
|
|
147
148
|
=end
|
148
149
|
|
149
|
-
def initialize
|
150
|
-
@dcode =
|
151
|
-
@
|
150
|
+
def initialize die_code
|
151
|
+
@dcode = die_code.strip
|
152
|
+
@allowed = Regexp.new(
|
153
|
+
/^[1-9]{,2}[A-Za-z]\d?[1-9]{1,2}(\.\d+)?([+-]\d+)?(\s*.+)?$/
|
154
|
+
)
|
155
|
+
|
156
|
+
process_die
|
152
157
|
end
|
153
158
|
|
154
159
|
private
|
155
160
|
|
156
161
|
def valid?
|
157
|
-
|
158
|
-
/^[1-9]*[0-9]*[A-Za-z][0-9]?[1-9]+[0-9]?(\.\d+)?[+-]?[0-9]*\s*(.*)$/
|
159
|
-
)
|
160
|
-
validation = true
|
161
|
-
else
|
162
|
-
validation = false
|
163
|
-
end
|
162
|
+
validation = dcode.match @allowed
|
164
163
|
|
165
|
-
if
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
if 0 == @pcode['val'][0].to_i
|
178
|
-
if 1 > @pcode['val'].to_i
|
179
|
-
return false
|
164
|
+
if dcode.size < 2
|
165
|
+
validation = false
|
166
|
+
elsif 1 > dmax
|
167
|
+
validation = false
|
168
|
+
elsif 1 > threshold
|
169
|
+
validation = false
|
170
|
+
elsif 1 > dice
|
171
|
+
validation = false
|
172
|
+
elsif 0 == dval[0].to_i
|
173
|
+
if 1 > dmax
|
174
|
+
validation = false
|
180
175
|
end
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
elsif @pcode['type'].match(/[^Kk]/) and 2 > @pcode['thresh'].to_i
|
187
|
-
return false
|
176
|
+
elsif 0 != dval[0].to_i
|
177
|
+
if 2 > dmax
|
178
|
+
validation = false
|
179
|
+
elsif roll_type.match(/[^Kk]/) and 2 > threshold
|
180
|
+
validation = false
|
188
181
|
end
|
189
182
|
end
|
190
183
|
|
@@ -192,41 +185,36 @@ The +dcode+ argument is any valid die code recognized by Droll.
|
|
192
185
|
end
|
193
186
|
|
194
187
|
def process_die
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
if
|
202
|
-
|
188
|
+
die_roll, @sign, mod = dcode.split(/([+-])/)
|
189
|
+
num, @roll_type, die_vals = die_roll.split(/([A-Za-z])/)
|
190
|
+
@dval, thresh = die_vals.to_s.split(/\./)
|
191
|
+
@dval = dval.to_s
|
192
|
+
@dmax = dval.to_i
|
193
|
+
|
194
|
+
if thresh
|
195
|
+
@threshold = thresh.to_i
|
203
196
|
else
|
204
|
-
|
197
|
+
@threshold = roll_type.match(/[KkN]/) ? 1 : dmax
|
205
198
|
end
|
206
199
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
return d
|
200
|
+
@dice = (num == '' ? 1 : num.to_i)
|
201
|
+
sign ||= '+'
|
202
|
+
@modifier = mod.to_i
|
212
203
|
end
|
213
204
|
|
214
205
|
def get_discrete(dval)
|
215
|
-
dval.match(/^0/) ? rand(
|
206
|
+
dval.match(/^0/) ? rand(dmax + 1) : 1 + (rand dmax)
|
216
207
|
end
|
217
208
|
|
218
|
-
def roll_die(die_value, die_type,
|
209
|
+
def roll_die(die_value, die_type, die_threshold)
|
219
210
|
discrete_rolls = [get_discrete(die_value)]
|
220
211
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
while c < 1000
|
225
|
-
if discrete_rolls[-1] >= die_threshhold.to_i
|
226
|
-
discrete_rolls.push get_discrete(die_value)
|
227
|
-
c += 1
|
228
|
-
else
|
212
|
+
if die_type == 'x'
|
213
|
+
0.upto(999) do
|
214
|
+
if discrete_rolls.last < die_threshold
|
229
215
|
break
|
216
|
+
else
|
217
|
+
discrete_rolls.push get_discrete die_value
|
230
218
|
end
|
231
219
|
end
|
232
220
|
end
|
@@ -234,16 +222,29 @@ The +dcode+ argument is any valid die code recognized by Droll.
|
|
234
222
|
discrete_rolls.compact
|
235
223
|
end
|
236
224
|
|
225
|
+
def analyze_rolls method, results
|
226
|
+
case method
|
227
|
+
when 'k'
|
228
|
+
sum_thresh_high_dice results
|
229
|
+
when 'K'
|
230
|
+
sum_thresh_low_dice results
|
231
|
+
when 'n'
|
232
|
+
count_dice_min_thresh results
|
233
|
+
when 'N'
|
234
|
+
count_dice_max_thresh results
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
237
238
|
public
|
238
239
|
|
239
240
|
=begin rdoc
|
240
241
|
|
241
242
|
This method takes an array of numeric values as its sole argument, and compares
|
242
|
-
it to the instantiated die code's
|
243
|
-
|
244
|
-
greater than the
|
243
|
+
it to the instantiated die code's threshold value. It returns an integer value
|
244
|
+
equal to the number of values in the array argument that are equal to or
|
245
|
+
greater than the threshold value.
|
245
246
|
|
246
|
-
Given a
|
247
|
+
Given a threshold of 2:
|
247
248
|
|
248
249
|
count_dice_min_thresh([0,1,2,3]) #=> 2
|
249
250
|
|
@@ -251,17 +252,18 @@ Given a threshhold of 2:
|
|
251
252
|
|
252
253
|
=end
|
253
254
|
|
254
|
-
def count_dice_min_thresh
|
255
|
-
|
256
|
-
n < @pcode['thresh'].to_i
|
257
|
-
end.size
|
255
|
+
def count_dice_min_thresh dresults
|
256
|
+
dresults.reject {|n| n < threshold }.size
|
258
257
|
end
|
259
258
|
|
260
259
|
=begin rdoc
|
261
260
|
|
262
|
-
This method takes an array of numeric values as its sole argument, and compares
|
261
|
+
This method takes an array of numeric values as its sole argument, and compares
|
262
|
+
it to the instantiated die code's threshold value. It returns an integer value
|
263
|
+
equal to the number of values in the array argument that are equal to or
|
264
|
+
greater than the threshold value.
|
263
265
|
|
264
|
-
Given a
|
266
|
+
Given a threshold of 1:
|
265
267
|
|
266
268
|
count_dice_max_thresh([0,1,2,3]) #=> 2
|
267
269
|
|
@@ -269,17 +271,15 @@ Given a thresshold of 1:
|
|
269
271
|
|
270
272
|
=end
|
271
273
|
|
272
|
-
def count_dice_max_thresh
|
273
|
-
|
274
|
-
n > @pcode['thresh'].to_i
|
275
|
-
end.size
|
274
|
+
def count_dice_max_thresh dresults
|
275
|
+
dresults.reject {|n| n > threshold }.size
|
276
276
|
end
|
277
277
|
|
278
278
|
=begin rdoc
|
279
279
|
|
280
280
|
This method takes an array of numeric values as its sole argument, and returns
|
281
281
|
the total of the highest N values in the array, where N is the instantiated die
|
282
|
-
code's
|
282
|
+
code's threshold value.
|
283
283
|
|
284
284
|
Given a die code of 3k02:
|
285
285
|
|
@@ -295,15 +295,15 @@ Given a die code of 3k02.2:
|
|
295
295
|
|
296
296
|
=end
|
297
297
|
|
298
|
-
def sum_thresh_high_dice
|
299
|
-
dresults.sort.reverse[0..(
|
298
|
+
def sum_thresh_high_dice dresults
|
299
|
+
dresults.sort.reverse[0..(threshold - 1)].inject(:+)
|
300
300
|
end
|
301
301
|
|
302
302
|
=begin rdoc
|
303
303
|
|
304
304
|
This method takes an array of numeric values as its sole argument, and returns
|
305
305
|
the total of the lowest N values in the array, where N is the instantiated die
|
306
|
-
code's
|
306
|
+
code's threshold value.
|
307
307
|
|
308
308
|
Given a die code of 3K02:
|
309
309
|
|
@@ -319,13 +319,18 @@ Given a die code of 3K02.2:
|
|
319
319
|
|
320
320
|
=end
|
321
321
|
|
322
|
-
def sum_thresh_low_dice
|
323
|
-
dresults.sort[0..(
|
322
|
+
def sum_thresh_low_dice dresults
|
323
|
+
dresults.sort[0..(threshold - 1)].inject(:+)
|
324
324
|
end
|
325
325
|
|
326
326
|
=begin rdoc
|
327
327
|
|
328
|
-
This method takes an array of numeric values as its sole argument, and compares
|
328
|
+
This method takes an array of numeric values as its sole argument, and compares
|
329
|
+
the total of the values in the array to the product of the instantiated die
|
330
|
+
code's threshold value and number of dice value. Unless that product is
|
331
|
+
greater than that total, the results of a die roll of 1xX.Y are appended to the
|
332
|
+
array provided in the method argument, where X is the value of the instantiated
|
333
|
+
die code and Y is the threshold of the instantiated die code.
|
329
334
|
|
330
335
|
Given a die code of 2e2:
|
331
336
|
|
@@ -335,13 +340,13 @@ Given a die code of 2e2:
|
|
335
340
|
|
336
341
|
=end
|
337
342
|
|
338
|
-
def explode_on_max_total
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
)
|
343
|
+
def explode_on_max_total dresults
|
344
|
+
roll_total = dresults.flatten.map {|result| result.to_i }.inject(:+)
|
345
|
+
|
346
|
+
unless roll_total < (threshold * dice)
|
347
|
+
dresults.push(roll_die dval, 'x', threshold)
|
344
348
|
end
|
349
|
+
|
345
350
|
dresults.flatten
|
346
351
|
end
|
347
352
|
|
@@ -359,50 +364,37 @@ an integer equal to the total result.
|
|
359
364
|
|
360
365
|
=end
|
361
366
|
|
362
|
-
def roll
|
363
|
-
|
367
|
+
def roll formatted=true
|
368
|
+
results = Array.new
|
364
369
|
|
365
|
-
return "bad die code: #{
|
370
|
+
return "bad die code: #{dcode}" unless valid?
|
366
371
|
|
367
|
-
|
368
|
-
|
369
|
-
roll_die
|
370
|
-
)
|
371
|
-
running_totals.flatten!
|
372
|
+
dice.times do
|
373
|
+
results.push(
|
374
|
+
roll_die dval, roll_type, threshold
|
375
|
+
).flatten!
|
372
376
|
end
|
373
377
|
|
374
|
-
if
|
375
|
-
|
378
|
+
if roll_type == 'e'
|
379
|
+
results = explode_on_max_total results
|
376
380
|
end
|
377
381
|
|
378
|
-
if
|
379
|
-
|
380
|
-
elsif @pcode['type'] == 'K'
|
381
|
-
total_result = sum_thresh_low_dice running_totals
|
382
|
-
elsif @pcode['type'] == 'n'
|
383
|
-
total_result = count_dice_min_thresh running_totals
|
384
|
-
elsif @pcode['type'] == 'N'
|
385
|
-
total_result = count_dice_max_thresh running_totals
|
382
|
+
total = if %w(k K n N).include? roll_type
|
383
|
+
analyze_rolls roll_type, results
|
386
384
|
else # "normal" totaling
|
387
|
-
|
388
|
-
sum ? sum+n : n
|
389
|
-
end
|
385
|
+
results.map {|s| s.to_i }.inject(:+)
|
390
386
|
end
|
391
387
|
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
total_result -= @pcode['mod'].to_i
|
388
|
+
if sign == '+'
|
389
|
+
total += modifier
|
390
|
+
elsif sign == '-'
|
391
|
+
total -= modifier
|
397
392
|
end
|
398
393
|
|
399
394
|
if formatted
|
400
|
-
|
401
|
-
result += "#{@pcode['sign']} #{@pcode['mod']} = "
|
402
|
-
|
403
|
-
result + total_result.to_s
|
395
|
+
"#{dcode}: #{results} #{sign} #{modifier} = #{total}"
|
404
396
|
else
|
405
|
-
|
397
|
+
total
|
406
398
|
end
|
407
399
|
end
|
408
400
|
end
|
metadata
CHANGED
@@ -1,32 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: droll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Chad Perrin
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2021-08-06 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: isaac
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0.2'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.2'
|
27
|
+
description: |2
|
28
|
+
Droll is a Ruby library providing dice roller functionality, with a command
|
29
|
+
line utility and an IRC bot as included user interfaces. It was created
|
30
|
+
with roleplaying gamers in mind, with a range of sophisticated capabilities
|
31
|
+
for such users, and comes with command line interface and IRC dicebot front
|
32
|
+
ends.
|
30
33
|
email: code@apotheon.net
|
31
34
|
executables:
|
32
35
|
- droll
|
@@ -36,38 +39,38 @@ extra_rdoc_files: []
|
|
36
39
|
files:
|
37
40
|
- COPYING
|
38
41
|
- README.md
|
39
|
-
- owl.txt
|
40
|
-
- lib/droll.rb
|
41
42
|
- bin/droll
|
42
43
|
- bin/drollbot
|
44
|
+
- coil.txt
|
43
45
|
- etc/drollbot.conf.sample
|
46
|
+
- lib/droll.rb
|
47
|
+
- owl.txt
|
44
48
|
homepage: http://droll.fossrec.com
|
45
49
|
licenses:
|
50
|
+
- COIL
|
46
51
|
- OWL
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
52
|
+
metadata: {}
|
53
|
+
post_install_message: |2
|
54
|
+
Thank you for using droll. In addition to library documentation in RDoc,
|
55
|
+
the "droll" command line utility and "drollbot" IRC dicebot can both be
|
56
|
+
executed from the shell prompt with a "-h" option for more help on how to
|
57
|
+
use and/or configure these tools.
|
51
58
|
rdoc_options: []
|
52
59
|
require_paths:
|
53
60
|
- lib
|
54
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
62
|
requirements:
|
57
|
-
- -
|
63
|
+
- - ">="
|
58
64
|
- !ruby/object:Gem::Version
|
59
65
|
version: 1.9.0
|
60
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
67
|
requirements:
|
63
|
-
- -
|
68
|
+
- - ">="
|
64
69
|
- !ruby/object:Gem::Version
|
65
70
|
version: '0'
|
66
71
|
requirements: []
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
specification_version: 3
|
72
|
+
rubygems_version: 3.2.3
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
71
75
|
summary: Droll - Dice Roller Library
|
72
76
|
test_files: []
|
73
|
-
has_rdoc: true
|