crapshoot 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -1
- data/crapshoot.gemspec +0 -1
- data/lib/crapshoot/result.rb +3 -0
- data/lib/crapshoot/tokens/arithmetic.rb +1 -0
- data/lib/crapshoot/tokens/constant.rb +1 -0
- data/lib/crapshoot/tokens/series.rb +1 -0
- data/lib/crapshoot/version.rb +1 -1
- data/test/crapshoot_test.rb +23 -1
- metadata +10 -10
data/README.rdoc
CHANGED
@@ -37,10 +37,12 @@ Generally, whitespace is allowed around arithmetic operations, but not inside a
|
|
37
37
|
== Describing a Roll
|
38
38
|
|
39
39
|
The return value from +Crapshoot.roll+ is a Crapshoot::Result object,
|
40
|
-
which is an Integer with a description field
|
40
|
+
which is an Integer with a +description+ field and a +detailed_description+
|
41
|
+
field:
|
41
42
|
|
42
43
|
r = Crapshoot.roll '4d4^ + 6d6 - 10' # => 22
|
43
44
|
r.description # => "(2+2+2+3-3)+(1+3+5+5+6+6)-10"
|
45
|
+
r.detailed_description # => [["4d4^", "2+2+2+3-3"], ["+", "+"], ["6d6", "1+3+5+5+6+6"], ["-", "-"], ["10", "10"]]
|
44
46
|
r + 5 # => 27
|
45
47
|
|
46
48
|
== Developing with Ragel
|
data/crapshoot.gemspec
CHANGED
@@ -7,7 +7,6 @@ Gem::Specification.new do |s|
|
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.authors = ["Bryce Kerley"]
|
10
|
-
s.date = %q{2011-09-03}
|
11
10
|
s.description = "Crapshoot is a dice-rolling gem for most of your pen-and-paper gaming needs; roll 4d6v to find out how much time it will save."
|
12
11
|
s.email = "bkerley@brycekerley.net"
|
13
12
|
s.extra_rdoc_files = [
|
data/lib/crapshoot/result.rb
CHANGED
@@ -23,6 +23,7 @@ module Crapshoot
|
|
23
23
|
l = stack.pop
|
24
24
|
@result = Result.new l.send(@operation.to_sym, r)
|
25
25
|
@result.description = "#{l.description}#{@operation}#{r.description}"
|
26
|
+
@result.detailed_description = l.detailed_description + [[@operation, @operation]] + r.detailed_description
|
26
27
|
return @result
|
27
28
|
end
|
28
29
|
|
data/lib/crapshoot/version.rb
CHANGED
data/test/crapshoot_test.rb
CHANGED
@@ -15,12 +15,23 @@ class TestCrapshoot < Test::Unit::TestCase
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.should_describe(from, matcher)
|
18
|
-
should "
|
18
|
+
should "describe #{from.inspect} into something resembling #{matcher.inspect}" do
|
19
19
|
result = Crapshoot.roll from
|
20
20
|
assert_match matcher, result.description
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def self.should_array_describe(from, matcher)
|
25
|
+
should "describe #{from.inspect} into a big array resembling #{matcher.inspect}" do
|
26
|
+
result = Crapshoot.roll from
|
27
|
+
result.detailed_description.zip(matcher) do |result_piece, matcher_piece|
|
28
|
+
result_piece.zip(matcher_piece) do |r, m|
|
29
|
+
assert_match m, r
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
24
35
|
context 'The Crapshoot module' do
|
25
36
|
should_roll '4d6', '>='=>4, '<='=>24
|
26
37
|
should_roll '4d6 + 200', '>='=>204, '<='=>224
|
@@ -40,5 +51,16 @@ class TestCrapshoot < Test::Unit::TestCase
|
|
40
51
|
should_describe '2d6 + 5', /\(\d\+\d\)\+5/
|
41
52
|
should_describe '2d6 + 5 + 4d2v', /\(\d\+\d\)\+5\+\(\d\+\d\+\d\+\d\-\d\)/
|
42
53
|
should_describe '2d6 + 5 + 4d2^', /\(\d\+\d\)\+5\+\(\d\+\d\+\d\+\d\-\d\)/
|
54
|
+
|
55
|
+
should_array_describe '1 + 2', [['1', '1'], ['+', '+'], ['2', '2']]
|
56
|
+
should_array_describe '10 - 5', [['10', '10'], ['-', '-'], ['5', '5']]
|
57
|
+
should_array_describe '2d6', [['2d6', /\d\+\d/]]
|
58
|
+
should_array_describe '2d6 + 5', [['2d6', /\d\+\d/], ['+', '+'], ['5', '5']]
|
59
|
+
should_array_describe '2d6 + 5 + 4d2v', [['2d6', /\d\+\d/],
|
60
|
+
['+', '+'],
|
61
|
+
['5', '5'],
|
62
|
+
['+', '+'],
|
63
|
+
['4d2v', /\d\+\d\+\d\+\d\-\d/]]
|
64
|
+
|
43
65
|
end
|
44
66
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crapshoot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
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: 2011-
|
12
|
+
date: 2011-12-26 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &70102833186080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.9.2
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70102833186080
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: guard-test
|
27
|
-
requirement: &
|
27
|
+
requirement: &70102833185500 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.1.4
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70102833185500
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: shoulda
|
38
|
-
requirement: &
|
38
|
+
requirement: &70102833184980 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.11.3
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70102833184980
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70102833184220 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.0.7
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70102833184220
|
58
58
|
description: Crapshoot is a dice-rolling gem for most of your pen-and-paper gaming
|
59
59
|
needs; roll 4d6v to find out how much time it will save.
|
60
60
|
email: bkerley@brycekerley.net
|