cinch-dicebag 1.0.5 → 1.0.6
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.
@@ -18,8 +18,9 @@ module Cinch::Plugins
|
|
18
18
|
'use .roll (dice count)d(sides) to roll specific dice ' +
|
19
19
|
'(e.g. .roll 4d6 3d20)'
|
20
20
|
|
21
|
-
match /dicebag/,
|
22
|
-
match /roll
|
21
|
+
match /dicebag/, method: :roll_dicebag
|
22
|
+
match /roll(?:\s(.*))/, method: :roll
|
23
|
+
match /roll\z/, method: :roll
|
23
24
|
|
24
25
|
def initialize(*args)
|
25
26
|
super
|
@@ -51,9 +52,7 @@ module Cinch::Plugins
|
|
51
52
|
# @param [String] dice Space delimited string of dice to role.
|
52
53
|
# (i.e. '6d12 4d20 d10'
|
53
54
|
# @return [String] String describing the dice that were rolled
|
54
|
-
def roll(m, dice)
|
55
|
-
return if dice.nil?
|
56
|
-
|
55
|
+
def roll(m, dice = '1d20')
|
57
56
|
result = roll_dice(dice.split(' '))
|
58
57
|
|
59
58
|
if result.is_a?(String)
|
data/spec/cinch-dicebag_spec.rb
CHANGED
@@ -13,6 +13,11 @@ describe Cinch::Plugins::Dicebag do
|
|
13
13
|
should_not be_nil
|
14
14
|
end
|
15
15
|
|
16
|
+
it 'should return a roll from using a blank roll' do
|
17
|
+
get_replies(make_message(@bot, '!roll', { nick: 'ted' })).first.
|
18
|
+
should_not be_nil
|
19
|
+
end
|
20
|
+
|
16
21
|
it 'should return a roll in bounds from rolling dice' do
|
17
22
|
roll = get_replies(make_message(@bot, '!roll 3d3', { nick: 'ted' })).first.text
|
18
23
|
roll = roll[/totalling (\d+)/, 1]
|
@@ -45,11 +50,6 @@ describe Cinch::Plugins::Dicebag do
|
|
45
50
|
should_not be_nil
|
46
51
|
end
|
47
52
|
|
48
|
-
it 'should not return a string from rolling dice without a name' do
|
49
|
-
get_replies(make_message(@bot, '!roll .' , { nick: 'ted' })).first.
|
50
|
-
should be_nil
|
51
|
-
end
|
52
|
-
|
53
53
|
it 'should return a string describing the dice that were rolled' do
|
54
54
|
text = get_replies(make_message(@bot, '!roll 3d3', { nick: 'ted' })).first.text
|
55
55
|
text.should match(/rolls\s3d3\stotalling\s\d+/)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-dicebag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
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: 2014-01-
|
12
|
+
date: 2014-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|