lita-resistance 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -8
- data/README.md +31 -31
- data/lib/lita/handlers/resistance.rb +71 -70
- data/lita-resistance.gemspec +26 -26
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e185d4c35a4675f50a74b0dc7cb6bcc1c5904777
|
4
|
+
data.tar.gz: 2722685943a3e76e24046df7b5963487264aa044
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3aa2752e5bad07a5813181ed3d758d1f0de9b6c1d4417b3163e159af928c8948a8994babb273fca6e1acc7acc4e20277a28d552a8b5a4e049dd2511d69d4fca4
|
7
|
+
data.tar.gz: c89c5153407acdd28053ce8365788aac102d2b66629bba256e38d054c3a631e23377733bf3a63f19af83f2bb24d79641cfe65bfc49488af59cce8b843d778969
|
data/.travis.yml
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.2.3
|
4
|
-
script: bundle exec rake
|
5
|
-
before_install:
|
6
|
-
- gem update --system 2.4.8
|
7
|
-
services:
|
8
|
-
- redis-server
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.2.3
|
4
|
+
script: bundle exec rake
|
5
|
+
before_install:
|
6
|
+
- gem update --system 2.4.8
|
7
|
+
services:
|
8
|
+
- redis-server
|
data/README.md
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
# lita-resistance
|
2
|
-
|
3
|
-
[![Build Status](https://travis-ci.org/DeonHua/lita-resistance.
|
4
|
-
[![
|
5
|
-
|
6
|
-
Plays a game of resistance by assigning roles to users you mention in chat.
|
7
|
-
|
8
|
-
## Installation
|
9
|
-
|
10
|
-
Add lita-resistance to your Lita instance's Gemfile:
|
11
|
-
|
12
|
-
``` ruby
|
13
|
-
gem "lita-resistance"
|
14
|
-
```
|
15
|
-
|
16
|
-
## Usage
|
17
|
-
|
18
|
-
`lita resistance [users]` - Assigns the roles of spy/resistance to users you mention.
|
19
|
-
|
20
|
-
### Examples
|
21
|
-
|
22
|
-
`lita resistance @player1 @player2 @player3 @player4 @player5`
|
23
|
-
|
24
|
-
You don't need to include the `@` symbol:
|
25
|
-
|
26
|
-
`lita resistance player1 player2 player3 player4 player5`
|
27
|
-
|
28
|
-
You can also do a combination of both:
|
29
|
-
|
30
|
-
`lita resistance @player1 @player2 player3 player4 player5`
|
31
|
-
|
1
|
+
# lita-resistance
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/DeonHua/lita-resistance.svg?branch=master)](https://travis-ci.org/DeonHua/lita-resistance)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/lita-resistance.svg)](https://badge.fury.io/rb/lita-resistance)
|
5
|
+
|
6
|
+
Plays a game of resistance by assigning roles to users you mention in chat.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add lita-resistance to your Lita instance's Gemfile:
|
11
|
+
|
12
|
+
``` ruby
|
13
|
+
gem "lita-resistance"
|
14
|
+
```
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
`lita resistance [users]` - Assigns the roles of spy/resistance to users you mention.
|
19
|
+
|
20
|
+
### Examples
|
21
|
+
|
22
|
+
`lita resistance @player1 @player2 @player3 @player4 @player5`
|
23
|
+
|
24
|
+
You don't need to include the `@` symbol:
|
25
|
+
|
26
|
+
`lita resistance player1 player2 player3 player4 player5`
|
27
|
+
|
28
|
+
You can also do a combination of both:
|
29
|
+
|
30
|
+
`lita resistance @player1 @player2 player3 player4 player5`
|
31
|
+
|
32
32
|
[![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](http://forthebadge.com)
|
@@ -1,70 +1,71 @@
|
|
1
|
-
module Lita
|
2
|
-
module Handlers
|
3
|
-
class Resistance < Handler
|
4
|
-
|
5
|
-
route(/resistance .+/, :play, command: true, help: {'resistance [users]' => 'Starts a game of resistance with the people you mention.'})
|
6
|
-
def play(response)
|
7
|
-
all_users = response.args.uniq
|
8
|
-
|
9
|
-
if all_users.length < 5
|
10
|
-
response.reply('You need at least 5 players for Resistance.')
|
11
|
-
return
|
12
|
-
elsif all_users.length > 10
|
13
|
-
response.reply('You cannot play a game of Resistance with more than 10 players.')
|
14
|
-
return
|
15
|
-
end
|
16
|
-
|
17
|
-
# Remove any "@" from usernames
|
18
|
-
all_users.map! {|username|
|
19
|
-
if username[0] == '@'
|
20
|
-
username = username[1, username.length-1]
|
21
|
-
else
|
22
|
-
username = username
|
23
|
-
end
|
24
|
-
}
|
25
|
-
|
26
|
-
# Ensure all people are users.
|
27
|
-
unknown_users = []
|
28
|
-
all_users.each do |username|
|
29
|
-
user = Lita::User.find_by_mention_name(username)
|
30
|
-
unknown_users.push(username) unless user
|
31
|
-
end
|
32
|
-
|
33
|
-
if unknown_users.any?
|
34
|
-
response.reply('The following are not users. Please check your spelling and try again.')
|
35
|
-
unknown_users.each do |user|
|
36
|
-
response.reply(user)
|
37
|
-
end and return
|
38
|
-
end
|
39
|
-
|
40
|
-
gameId = rand(999999)
|
41
|
-
|
42
|
-
# Form teams
|
43
|
-
spies = all_users.sample((all_users.length+2)/3)
|
44
|
-
resistance = all_users - spies
|
45
|
-
|
46
|
-
spies.each do |member|
|
47
|
-
user = Lita::User.find_by_mention_name(member)
|
48
|
-
current_user = Source.new(user: user)
|
49
|
-
robot.send_message(current_user,"@#{response.user.mention_name} has started game ID ##{gameId} of Resistance. You are a member of the spies.")
|
50
|
-
other_spies = spies.dup
|
51
|
-
other_spies.delete_at(other_spies.find_index(member))
|
52
|
-
if other_spies.length > 1
|
53
|
-
robot.send_message(current_user, "The other spies are: @#{other_spies.join(' @')}")
|
54
|
-
else
|
55
|
-
robot.send_message(current_user, "The other spy is: @#{other_spies[0]}")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
resistance.each do |member|
|
60
|
-
user = Lita::User.find_by_mention_name(member)
|
61
|
-
robot.send_message(Source.new(user: user), "@#{response.user.mention_name} has started game ID ##{gameId} of Resistance. You are a member of the resistance.")
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
1
|
+
module Lita
|
2
|
+
module Handlers
|
3
|
+
class Resistance < Handler
|
4
|
+
|
5
|
+
route(/resistance .+/, :play, command: true, help: {'resistance [users]' => 'Starts a game of resistance with the people you mention.'})
|
6
|
+
def play(response)
|
7
|
+
all_users = response.args.uniq
|
8
|
+
|
9
|
+
if all_users.length < 5
|
10
|
+
response.reply('You need at least 5 players for Resistance.')
|
11
|
+
return
|
12
|
+
elsif all_users.length > 10
|
13
|
+
response.reply('You cannot play a game of Resistance with more than 10 players.')
|
14
|
+
return
|
15
|
+
end
|
16
|
+
|
17
|
+
# Remove any "@" from usernames
|
18
|
+
all_users.map! {|username|
|
19
|
+
if username[0] == '@'
|
20
|
+
username = username[1, username.length-1]
|
21
|
+
else
|
22
|
+
username = username
|
23
|
+
end
|
24
|
+
}
|
25
|
+
|
26
|
+
# Ensure all people are users.
|
27
|
+
unknown_users = []
|
28
|
+
all_users.each do |username|
|
29
|
+
user = Lita::User.find_by_mention_name(username)
|
30
|
+
unknown_users.push(username) unless user
|
31
|
+
end
|
32
|
+
|
33
|
+
if unknown_users.any?
|
34
|
+
response.reply('The following are not users. Please check your spelling and try again.')
|
35
|
+
unknown_users.each do |user|
|
36
|
+
response.reply(user)
|
37
|
+
end and return
|
38
|
+
end
|
39
|
+
|
40
|
+
gameId = rand(999999)
|
41
|
+
|
42
|
+
# Form teams
|
43
|
+
spies = all_users.sample((all_users.length+2)/3)
|
44
|
+
resistance = all_users - spies
|
45
|
+
|
46
|
+
spies.each do |member|
|
47
|
+
user = Lita::User.find_by_mention_name(member)
|
48
|
+
current_user = Source.new(user: user)
|
49
|
+
robot.send_message(current_user,"@#{response.user.mention_name} has started game ID ##{gameId} of Resistance. You are a member of the spies.")
|
50
|
+
other_spies = spies.dup
|
51
|
+
other_spies.delete_at(other_spies.find_index(member))
|
52
|
+
if other_spies.length > 1
|
53
|
+
robot.send_message(current_user, "The other spies are: @#{other_spies.join(' @')}")
|
54
|
+
else
|
55
|
+
robot.send_message(current_user, "The other spy is: @#{other_spies[0]}")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
resistance.each do |member|
|
60
|
+
user = Lita::User.find_by_mention_name(member)
|
61
|
+
robot.send_message(Source.new(user: user), "@#{response.user.mention_name} has started game ID ##{gameId} of Resistance. You are a member of the resistance.")
|
62
|
+
end
|
63
|
+
|
64
|
+
leader = all_users.sample(1)[0] # Randomly pick a leader for the first round
|
65
|
+
response.reply("Roles have been assigned to the selected people! This is game ID ##{gameId}. @#{leader} will be leading off the first round.")
|
66
|
+
end
|
67
|
+
|
68
|
+
Lita.register_handler(self)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lita-resistance.gemspec
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
Gem::Specification.new do |spec|
|
2
|
-
spec.name = "lita-resistance"
|
3
|
-
spec.version = "0.2.
|
4
|
-
spec.authors = ["Deon Hua", "Yu Chen Hou"]
|
5
|
-
spec.email = ["deonhbci@gmail.com", "me@yuchen.io"]
|
6
|
-
spec.description = "Plays a game of resistance by assigning roles to users you mention in chat."
|
7
|
-
spec.summary = "Plays a game of resistance by assigning roles to users you mention in chat."
|
8
|
-
spec.homepage = "http://github.com/DeonHua/lita-resistance"
|
9
|
-
spec.license = "MIT"
|
10
|
-
spec.metadata = { "lita_plugin_type" => "handler" }
|
11
|
-
|
12
|
-
spec.files = `git ls-files`.split($/)
|
13
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
-
spec.require_paths = ["lib"]
|
16
|
-
|
17
|
-
spec.add_runtime_dependency "lita", ">= 4.6"
|
18
|
-
|
19
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
-
spec.add_development_dependency "pry-byebug"
|
21
|
-
spec.add_development_dependency "rake"
|
22
|
-
spec.add_development_dependency "rack-test"
|
23
|
-
spec.add_development_dependency "rspec", ">= 3.0.0"
|
24
|
-
spec.add_development_dependency "simplecov"
|
25
|
-
spec.add_development_dependency "coveralls"
|
26
|
-
end
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-resistance"
|
3
|
+
spec.version = "0.2.2"
|
4
|
+
spec.authors = ["Deon Hua", "Yu Chen Hou"]
|
5
|
+
spec.email = ["deonhbci@gmail.com", "me@yuchen.io"]
|
6
|
+
spec.description = "Plays a game of resistance by assigning roles to users you mention in chat."
|
7
|
+
spec.summary = "Plays a game of resistance by assigning roles to users you mention in chat."
|
8
|
+
spec.homepage = "http://github.com/DeonHua/lita-resistance"
|
9
|
+
spec.license = "MIT"
|
10
|
+
spec.metadata = { "lita_plugin_type" => "handler" }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
13
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_runtime_dependency "lita", ">= 4.6"
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "pry-byebug"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "rack-test"
|
23
|
+
spec.add_development_dependency "rspec", ">= 3.0.0"
|
24
|
+
spec.add_development_dependency "simplecov"
|
25
|
+
spec.add_development_dependency "coveralls"
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-resistance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Deon Hua
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-01-
|
12
|
+
date: 2016-01-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: lita
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
167
|
rubyforge_project:
|
168
|
-
rubygems_version: 2.4.
|
168
|
+
rubygems_version: 2.4.6
|
169
169
|
signing_key:
|
170
170
|
specification_version: 4
|
171
171
|
summary: Plays a game of resistance by assigning roles to users you mention in chat.
|