cinch-dice 0.0.1
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.
- data/LICENSE +19 -0
- data/README.md +38 -0
- data/lib/cinch/plugins/dice.rb +33 -0
- metadata +61 -0
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2012 by Dominik Honnef
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Dice plugin
|
2
|
+
|
3
|
+
This plugin provides dice for your channel.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
First install the gem by running:
|
7
|
+
[sudo] gem install cinch-dice
|
8
|
+
|
9
|
+
Then load it in your bot:
|
10
|
+
require "cinch"
|
11
|
+
require "cinch/plugins/dice"
|
12
|
+
|
13
|
+
bot = Cinch::Bot.new do
|
14
|
+
configure do |c|
|
15
|
+
# add all required options here
|
16
|
+
c.plugins.plugins = [Cinch::Plugins::Dice] # optionally add more plugins
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
bot.start
|
21
|
+
|
22
|
+
## Commands
|
23
|
+
roll [[<repeats>#]<rolls>]d<sides>[<+/-><offset>]
|
24
|
+
|
25
|
+
### Examples
|
26
|
+
roll 5d6 # roll 5 6-sided dice
|
27
|
+
roll 2#5d6 # roll 5 6-sided dice, twice
|
28
|
+
|
29
|
+
## Options
|
30
|
+
### :format
|
31
|
+
|
32
|
+
With this option you can set the format string used for saying the
|
33
|
+
dice score. The default is `"Your dice roll was: %d"`.
|
34
|
+
|
35
|
+
### Example configuration
|
36
|
+
configure do |c|
|
37
|
+
c.plugins.options[Cinch::Plugins::Dice][:format] = "Score: %d"
|
38
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'cinch'
|
2
|
+
|
3
|
+
module Cinch
|
4
|
+
module Plugins
|
5
|
+
class Dice
|
6
|
+
include Cinch::Plugin
|
7
|
+
|
8
|
+
# [[<repeats>#]<rolls>]d<sides>[<+/-><offset>]
|
9
|
+
match(/roll (?:(?:(\d+)#)?(\d+))?d(\d+)(?:([+-])(\d+))?/)
|
10
|
+
def execute(m, repeats, rolls, sides, offset_op, offset)
|
11
|
+
repeats = repeats.to_i
|
12
|
+
repeats = 1 if repeats < 1
|
13
|
+
rolls = rolls.to_i
|
14
|
+
rolls = 1 if rolls < 1
|
15
|
+
|
16
|
+
total = 0
|
17
|
+
|
18
|
+
repeats.times do
|
19
|
+
rolls.times do
|
20
|
+
score = rand(sides.to_i) + 1
|
21
|
+
if offset_op
|
22
|
+
score = score.send(offset_op, offset.to_i)
|
23
|
+
end
|
24
|
+
total += score
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
fmt = config[:format] || "Your dice roll was: %d"
|
29
|
+
m.reply fmt % total, true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cinch-dice
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dominik Honnef
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cinch
|
16
|
+
requirement: &12182700 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *12182700
|
25
|
+
description: Dice plugin, perfect for role-playing games or generic decision making.
|
26
|
+
email:
|
27
|
+
- dominikh@fork-bomb.org
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- LICENSE
|
33
|
+
- README.md
|
34
|
+
- lib/cinch/plugins/dice.rb
|
35
|
+
homepage: http://rubydoc.info/github/cinchrb/cinch-dice
|
36
|
+
licenses:
|
37
|
+
- MIT
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.9.1
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.8.15
|
57
|
+
signing_key:
|
58
|
+
specification_version: 3
|
59
|
+
summary: Dice plugin, perfect for role-playing games or generic decision making.
|
60
|
+
test_files: []
|
61
|
+
has_rdoc:
|