lita-resistance 0.2.1 → 0.2.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e01368713992622db461d4cf9e9f401754e2fa40
4
- data.tar.gz: 93708f06b073f98346f90318a4c4c93c5a097d69
3
+ metadata.gz: e185d4c35a4675f50a74b0dc7cb6bcc1c5904777
4
+ data.tar.gz: 2722685943a3e76e24046df7b5963487264aa044
5
5
  SHA512:
6
- metadata.gz: bc04e890e9a9aa6674f28baf91e80e26c284a7089e96cbda06f3fe36af7b96ea14687f2bda593b9a4f29808667b63555355666e640d1f8c8f7d9fdfc7f32681b
7
- data.tar.gz: bd50d1ed8d33ab0f6c1c9ddb106dbb2d818051b426bb0ad29264761a7d542c0bc0d8531fbc0e47ed87c04e40f117c426c8c93587cecb033e1641277910292a18
6
+ metadata.gz: 3aa2752e5bad07a5813181ed3d758d1f0de9b6c1d4417b3163e159af928c8948a8994babb273fca6e1acc7acc4e20277a28d552a8b5a4e049dd2511d69d4fca4
7
+ data.tar.gz: c89c5153407acdd28053ce8365788aac102d2b66629bba256e38d054c3a631e23377733bf3a63f19af83f2bb24d79641cfe65bfc49488af59cce8b843d778969
@@ -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.png?branch=master)](https://travis-ci.org/DeonHua/lita-resistance)
4
- [![Coverage Status](https://coveralls.io/repos/DeonHua/lita-resistance/badge.png)](https://coveralls.io/r/DeonHua/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
-
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
- response.reply("Roles have been assigned to the selected people! This is game ID ##{gameId}")
65
- end
66
-
67
- Lita.register_handler(self)
68
- end
69
- end
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
@@ -1,26 +1,26 @@
1
- Gem::Specification.new do |spec|
2
- spec.name = "lita-resistance"
3
- spec.version = "0.2.1"
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.1
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-03 00:00:00.000000000 Z
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.5.1
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.