ruboty-slot 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +2 -0
- data/lib/ruboty/actions/slot.rb +15 -0
- data/lib/ruboty/handlers/slot.rb +14 -0
- data/lib/ruboty/slot/gum_fruit.rb +24 -0
- data/lib/ruboty/slot/reel.rb +35 -0
- data/lib/ruboty/slot/slot_machine.rb +24 -0
- data/lib/ruboty/slot/version.rb +6 -0
- data/lib/ruboty/slot.rb +10 -0
- data/ruboty-slot.gemspec +22 -0
- data/screenshot.png +0 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8d9a5d22085471f4384fed7b711511b5ad8cb00f
|
4
|
+
data.tar.gz: 71e14abd5578affc42de355e2bc20006453fdebe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2de13d88d15af021239be5d5c2d94dc3583e73aa4e6e70c626ed7567fcd94d8bea6c9907df6595f71261d0814c9a3eaf2b86c3cad33513f6f9cb40d33e99abe7
|
7
|
+
data.tar.gz: 0f88d52c17d76f5eac7df5e72180ae57843b3cf5e0eaf2c225ad6457f2fe55c07fa5b5023d3e1f9d73c17151932e71f0c694fdb008352db65d4f8b8e5eebb97e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 block_given?
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Ruboty::Slot
|
2
|
+
|
3
|
+
GitHub emoji スロット
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ruboty-slot'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ruboty-slot
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
![slot screenshot](screenshot.png)
|
24
|
+
|
25
|
+
@ruboty スロット
|
26
|
+
@ruboty スロット
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it ( https://github.com/blockgivenh/ruboty-slot/fork )
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
module Ruboty
|
3
|
+
module Actions
|
4
|
+
class Slot < Base
|
5
|
+
def call
|
6
|
+
slot_machine = Ruboty::Slot::GumFruit.new
|
7
|
+
slot_machine.pull_lever
|
8
|
+
slot_machine.reels.count.times do |n|
|
9
|
+
slot_machine.push_stop_button(n)
|
10
|
+
end
|
11
|
+
message.reply("@#{message.from_name}#{$/}#{slot_machine.to_s}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'ruboty/actions/slot'
|
3
|
+
|
4
|
+
module Ruboty
|
5
|
+
module Handlers
|
6
|
+
class Slot < Base
|
7
|
+
on /(?:スロット|slot)/, name: 'slot', description: 'play slot machine'
|
8
|
+
|
9
|
+
def slot(message)
|
10
|
+
Ruboty::Actions::Slot.new(message).call
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require "ruboty/slot/reel"
|
3
|
+
require "ruboty/slot/slot_machine"
|
4
|
+
|
5
|
+
module Ruboty
|
6
|
+
module Slot
|
7
|
+
class GumFruit < SlotMachine
|
8
|
+
B = ":bell:" # ベル
|
9
|
+
O = ":tangerine:" # オレンジ
|
10
|
+
L = ":lemon:" # レモン
|
11
|
+
M = ":herb:" # スペアミント
|
12
|
+
P = ":peach:" # プラム
|
13
|
+
G = ":slot_machine:" # ガム
|
14
|
+
|
15
|
+
def reels
|
16
|
+
@reels ||= [
|
17
|
+
Reel.new(P, M, L, G, B, M, L, O, B, M, O, P, M, L),
|
18
|
+
Reel.new(L, G, O, M, B, O, P, M, B, P, O, M, B, O),
|
19
|
+
Reel.new(G, L, P, O, B, P, O, G, L, P, O, L, B, O)
|
20
|
+
]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
module Ruboty
|
5
|
+
module Slot
|
6
|
+
class Reel
|
7
|
+
DEFAULT_DISPLAY_SIZE = 3
|
8
|
+
|
9
|
+
def initialize(*symbols)
|
10
|
+
@symbols = symbols
|
11
|
+
end
|
12
|
+
|
13
|
+
def default_display_size
|
14
|
+
DEFAULT_DISPLAY_SIZE
|
15
|
+
end
|
16
|
+
|
17
|
+
def roll
|
18
|
+
@rolled_count = SecureRandom.random_number(size)
|
19
|
+
@stopped_at = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def size
|
23
|
+
@symbols.size
|
24
|
+
end
|
25
|
+
|
26
|
+
def stop(stopped_at = SecureRandom.random_number(size))
|
27
|
+
@stopped_at = stopped_at
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_a(size = default_display_size)
|
31
|
+
@symbols.lazy.cycle.drop(@rolled_count + @stopped_at).take(size).to_a
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Ruboty
|
4
|
+
module Slot
|
5
|
+
class SlotMachine
|
6
|
+
def reels
|
7
|
+
[]
|
8
|
+
end
|
9
|
+
|
10
|
+
def pull_lever
|
11
|
+
reels.each(&:roll)
|
12
|
+
end
|
13
|
+
|
14
|
+
def push_stop_button(n)
|
15
|
+
reels[n].stop
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
first, *rest = reels.map(&:to_a)
|
20
|
+
first.zip(*rest).map(&:join).join($/)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/ruboty/slot.rb
ADDED
data/ruboty-slot.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruboty/slot/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruboty-slot"
|
8
|
+
spec.version = Ruboty::Slot::VERSION
|
9
|
+
spec.authors = ["block_given?"]
|
10
|
+
spec.email = ["block_given@outlook.com"]
|
11
|
+
spec.summary = %q{GitHub emoji スロット.}
|
12
|
+
spec.homepage = "https://github.com/blockgiven/ruboty-slot"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
end
|
data/screenshot.png
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-slot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- block_given?
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- block_given@outlook.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/ruboty/actions/slot.rb
|
54
|
+
- lib/ruboty/handlers/slot.rb
|
55
|
+
- lib/ruboty/slot.rb
|
56
|
+
- lib/ruboty/slot/gum_fruit.rb
|
57
|
+
- lib/ruboty/slot/reel.rb
|
58
|
+
- lib/ruboty/slot/slot_machine.rb
|
59
|
+
- lib/ruboty/slot/version.rb
|
60
|
+
- ruboty-slot.gemspec
|
61
|
+
- screenshot.png
|
62
|
+
homepage: https://github.com/blockgiven/ruboty-slot
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.2.2
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: GitHub emoji スロット.
|
86
|
+
test_files: []
|