droll 1.0rc5.3.1 → 1.0rc5.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,18 +4,23 @@ Droll, for "d roll" (as in "die roll"), is a dice rolling library and a command
4
4
  line utility. Drollbot is an IRC bot that uses the droll and Isaac libraries
5
5
  to provide dicebot functionality over IRC.
6
6
 
7
- At present, droll provides both normal die rolling capability and simplistic
8
- exploding die rolling capability (exploding automatically on die rolls that
9
- return the highest value available on the die). Alternate thresholds for
10
- exploding can be used. Use NdN as the pattern for normal die rolls (where N
11
- stands in for a number), and NxN for exploding die rolls. Modifiers can be
12
- included as well: NdN+N or NdN-N. Die codes, at this time, do not work if they
13
- have spaces in them. Certain die codes are rejected (i.e. 0x0). Exploding is
14
- limited to an unreasonably high number (1000), to prevent crashing. Changing
15
- the exploding threshold uses a .N syntax (NxN.N). Die values are chosen
16
- (pseudo)randomly from numbers between 1 and N (the number following the x or
17
- d), or between 0 and N if the N is preceded by a 0 character. An example of
18
- the full sophistication of die code parsing is:
7
+ At present, droll provides a number of different die rolling techniques,
8
+ including simplistic roll-and-sum, various exploding roll schemes, counting
9
+ dice that meet a threshhold, and rolling several dice then discarding some by
10
+ threshhold before summing. Threshholds are typically the highest possible
11
+ number for the die type, or the maximum possible for the sum in some cases, or
12
+ even the lowest possible number for the die type, though alternate thresholds
13
+ can be used.
14
+
15
+ Use NdN as the pattern for normal die rolls (where N stands in for a number),
16
+ and NxN for exploding die rolls. Modifiers can be included as well: NdN+N or
17
+ NdN-N. Die codes, at this time, do not work if they have spaces in them.
18
+ Certain die codes are rejected (i.e. 0x0). Exploding is limited to an
19
+ unreasonably high number (1000), to prevent crashing. Specifying alternate
20
+ thresholds uses a .N syntax (NxN.N). Die values are chosen (pseudo)randomly
21
+ from numbers between 1 and N (the number following the x or d), or between 0
22
+ and N if the N is preceded by a 0 character. An example of the full
23
+ sophistication of die code parsing is:
19
24
 
20
25
  4x05.4+7
21
26
 
@@ -26,10 +31,6 @@ total to yield a final number.
26
31
  The first number following each 4 or 5 in this example is the result of a die
27
32
  immediately rolled to handle exploding die values.
28
33
 
29
- This brief explanation of capabilities is slightly out of date. See RDoc and
30
- code comments for details. In fact, anything in this file might be out of date
31
- at any given time, though I will try to update it in a timely manner.
32
-
33
34
 
34
35
  ## installation
35
36
 
data/bin/droll CHANGED
@@ -45,7 +45,9 @@ SYNTAX
45
45
  "K", use the lowest die values instead.
46
46
 
47
47
  n Count the number of dice that yield values equal to or
48
- higher than a threshhold value.
48
+ higher than a threshhold value. When the "n" is capitalized
49
+ "N", count values equal to or lower than the threshhold
50
+ instead.
49
51
 
50
52
  3. Die Value (Mandatory; No Default)
51
53
 
@@ -113,6 +115,12 @@ EXAMPLES
113
115
  3n10.6 Same as 3n10, but count the number of dice whose values are 6
114
116
  or higher.
115
117
 
118
+ 3N10 Roll three ten-sided dice for values between 1 and 10, and count
119
+ only the number of dice whose values are 1.
120
+
121
+ 3N10.5 Same as 3N10, but count the number of dice whose values are 5 or
122
+ lower.
123
+
116
124
  EOF
117
125
 
118
126
  version_help = <<EOF
data/lib/droll.rb CHANGED
@@ -136,7 +136,7 @@ This method returns the version number for the Droll gem.
136
136
 
137
137
  =end
138
138
 
139
- def self.version; '1.0rc5.3.1'; end
139
+ def self.version; '1.0rc5.4.0'; end
140
140
 
141
141
  =begin rdoc
142
142
 
@@ -198,7 +198,7 @@ The +dcode+ argument is any valid die code recognized by Droll.
198
198
  d['val'], d['thresh'] = die_vals.split(/\./)
199
199
  d['val'] = d['val'].to_s
200
200
 
201
- if d['type'].match(/[Kk]/)
201
+ if d['type'].match(/[KkN]/)
202
202
  d['thresh'] ||= 1
203
203
  else
204
204
  d['thresh'] ||= d['val'].sub(/^0/, '')
@@ -259,6 +259,24 @@ Given a threshhold of 2:
259
259
 
260
260
  =begin rdoc
261
261
 
262
+ This method takes an array of numeric values as its sole argument, and compares it to the instantiated die code's threshhold value. It returns an integer value equal to the number of values in the array argument that are equal to or greater than the threshhold value.
263
+
264
+ Given a thresshold of 1:
265
+
266
+ count_dice_max_thresh([0,1,2,3]) #=> 2
267
+
268
+ count_dice_max_thresh([2,3]) #=> 0
269
+
270
+ =end
271
+
272
+ def count_dice_max_thresh(dresults)
273
+ num_dice_max_thresh = dresults.reject do |n|
274
+ n > @pcode['thresh'].to_i
275
+ end.size
276
+ end
277
+
278
+ =begin rdoc
279
+
262
280
  This method takes an array of numeric values as its sole argument, and returns
263
281
  the total of the highest N values in the array, where N is the instantiated die
264
282
  code's threshhold value.
@@ -363,6 +381,8 @@ an integer equal to the total result.
363
381
  total_result = sum_thresh_low_dice running_totals
364
382
  elsif @pcode['type'] == 'n'
365
383
  total_result = count_dice_min_thresh running_totals
384
+ elsif @pcode['type'] == 'N'
385
+ total_result = count_dice_max_thresh running_totals
366
386
  else # "normal" totaling
367
387
  total_result = running_totals.map {|s| s.to_i }.inject do |sum,n|
368
388
  sum ? sum+n : n
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: droll
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0rc5.3.1
4
+ version: 1.0rc5.4.0
5
5
  prerelease: 3
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-31 00:00:00.000000000 Z
12
+ date: 2012-06-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: isaac
16
- requirement: &6030100 !ruby/object:Gem::Requirement
16
+ requirement: &11059500 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,9 +21,12 @@ dependencies:
21
21
  version: '0.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *6030100
24
+ version_requirements: *11059500
25
25
  description: ! " Droll is a Ruby library providing dice roller functionality, with
26
- a\n command line utility and an IRC bot as included user interfaces.\n"
26
+ a command\n line utility and an IRC bot as included user interfaces. It was
27
+ created\n with roleplaying gamers in mind, with a range of sophisticated capabilities\n
28
+ \ for such users, and comes with command line interface and IRC dicebot front\n
29
+ \ ends.\n"
27
30
  email: code@apotheon.net
28
31
  executables:
29
32
  - droll
@@ -32,16 +35,19 @@ extensions: []
32
35
  extra_rdoc_files: []
33
36
  files:
34
37
  - COPYING
35
- - README.markdown
38
+ - README.md
36
39
  - owl.txt
37
40
  - lib/droll.rb
38
41
  - bin/droll
39
42
  - bin/drollbot
40
43
  - etc/drollbot.conf.sample
41
- homepage: https://bitbucket.org/apotheon/droll
44
+ homepage: http://droll.fossrec.com
42
45
  licenses:
43
46
  - OWL
44
- post_install_message:
47
+ post_install_message: ! " Thank you for using droll. In addition to library documentation
48
+ in RDoc,\n the \"droll\" command line utility and \"drollbot\" IRC dicebot can
49
+ both be\n executed from the shell prompt with a \"-h\" option for more help on
50
+ how to\n use and/or configure these tools.\n"
45
51
  rdoc_options: []
46
52
  require_paths:
47
53
  - lib
@@ -50,7 +56,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
56
  requirements:
51
57
  - - ! '>='
52
58
  - !ruby/object:Gem::Version
53
- version: '0'
59
+ version: 1.9.0
54
60
  required_rubygems_version: !ruby/object:Gem::Requirement
55
61
  none: false
56
62
  requirements: