lita-destiny 0.2.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99ea47e27f80fe3f59b2066e75e90241ca8732de
4
- data.tar.gz: c444142a09b63132d63148454f7287fdae3ade2f
3
+ metadata.gz: c0c9ea265299377f1f240610fad0221fbe49751e
4
+ data.tar.gz: 517d8c99a7357800806fb72339d38f04b4826b85
5
5
  SHA512:
6
- metadata.gz: 6548499bef7ecc6ecdcd4ccecc5acfbd9e135bc04a2a3f18b930f760e5493b6c973ac933bff13e6baf937656cbf4d2cb41c9f3dc74d295c2c41666daa404f8d0
7
- data.tar.gz: 318e1177eecb42d1d07b5aae43eb517b819790dc4a0b5c04bcc04622d6c9ebc8dfa811d7e087d47ca3278e0490c26ae0830508b57888e1680b19ac0fc44744be
6
+ metadata.gz: 70d9beb976b5084e80e66b9ea0e5151b26f72dcffacc1e31d8f94e99e470ea33ea95acbd1bd4b108dc9428e98a6b79291c09765ea14faad2dcf4000b432c1b0d
7
+ data.tar.gz: 69e64caaf95ceeb4e131739ec4d3a8044688771e99b32a892829accd5c2b93b46214ca5237e577bd834b619a814f54f34be007c085707baa94c7dee7d6157b61
data/README.md CHANGED
@@ -19,9 +19,5 @@ gem "lita-destiny"
19
19
 
20
20
  Add the config to your lita config file with your Bungie API key:
21
21
  ``` ruby
22
- config.handlers.destiny.api_key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
22
+ config.handlers.destiny_handler.api_key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
23
23
  ```
24
-
25
- ## Usage
26
-
27
- This gem adds several methods for chat routes.
data/lib/lita-destiny.rb CHANGED
@@ -10,7 +10,7 @@ Lita.load_locales Dir[File.expand_path(
10
10
  require "lita/handlers/destiny"
11
11
 
12
12
  # Require response templates
13
- Lita::Handlers::Destiny.template_root File.expand_path(
13
+ Lita::Handlers::DestinyHandler.template_root File.expand_path(
14
14
  File.join("..", "..", "templates"),
15
15
  __FILE__
16
16
  )
@@ -1,6 +1,6 @@
1
1
  module Lita
2
2
  module Handlers
3
- class Destiny < Handler
3
+ class DestinyHandler < Handler
4
4
  # Required configuration attribute
5
5
  config :api_key, type: String, required: true do
6
6
  # Do validation against provided api_key, MUST be 32 chars.
@@ -9,114 +9,172 @@ module Lita
9
9
  "must be 32 characters" unless value.respond_to?(:size) && value.size == 32
10
10
  end
11
11
  end
12
-
13
- # Bring in DestinyAPI module
14
- include DestinyAPI
12
+
13
+ # Bring in Destiny module
14
+ include Destiny
15
15
 
16
16
  # Nightfall Route
17
17
  route(/^!(nightfall)/i, :nightfall , help: { "!nightfall" => "Get this weeks nightfall description and skulls" })
18
-
18
+
19
19
  # Weekly Strike Route
20
20
  route(/^!(weekly)/i, :weekly , help: { "!weekly" => "Get this weeks nightfall description and skulls" })
21
-
21
+
22
22
  # Xur Route
23
23
  route(/^!(xur)/i, :xur , help: { "!xur" => "Get Xur's inventory when availible" })
24
-
24
+
25
+ route(/^!(poe32)/i, :poe_32, help: { "!32" => "Get this weeks level 32 Prison of Elders information." })
26
+
27
+ route(/^!(poe34)/i, :poe_34, help: { "!34" => "Get this weeks level 34 Prison of Elders information." })
28
+
29
+ route(/^!(poe35)/i, :poe_35, help: { "!35" => "Get this weeks level 35 Prison of Elders information." })
30
+
25
31
  # Nightfall Activity Method
26
- #
32
+ #
27
33
  # Calls #build_activity_message(activity)
28
34
  # where activity would be nightfall.
29
- #
35
+ #
30
36
  def nightfall(response)
31
37
  # Set up our client
32
- destiny_client = DestinyAPI::Base.new(api_key)
38
+ destiny_client = Destiny::Client.new(api_key)
33
39
  # Build the activity message with nightfall info
34
40
  build_activity_message(destiny_client.nightfall, response)
35
41
  end
36
-
42
+
37
43
  # Weekly Strike Activity Method
38
- #
44
+ #
39
45
  # Calls #build_activity_message(activity)
40
46
  # where activity would be the weekly strike.
41
- #
47
+ #
42
48
  def weekly(response)
43
49
  # Set up our client
44
- destiny_client = DestinyAPI::Base.new(api_key)
50
+ destiny_client = Destiny::Client.new(api_key)
45
51
  # Build the activity message with weekly info
46
52
  build_activity_message(destiny_client.weekly_strike, response)
47
53
  end
48
-
54
+
49
55
  # Xur Items Method
50
- #
56
+ #
51
57
  # Calls #build_xur_message()
52
- # Returns Xur inventory when availible.
53
- #
58
+ # Returns Xur inventory when availible.
59
+ #
54
60
  def xur(response)
55
61
  build_xur_message(response)
56
62
  end
57
-
63
+
64
+ def poe_32(response)
65
+ build_poe_message(32, response)
66
+ end
67
+
68
+ def poe_34(response)
69
+ build_poe_message(34, response)
70
+ end
71
+
72
+ def poe_35(response)
73
+ build_poe_message(35, response)
74
+ end
75
+
58
76
  # Begin private methods
59
- #
77
+ #
60
78
  private
61
-
79
+
62
80
  # Set our api_key for calling in route methods.
63
- #
81
+ #
64
82
  def api_key
65
83
  config.api_key
66
84
  end
67
-
85
+
68
86
  # Generalized Response Method
69
- #
87
+ #
70
88
  # Used by activity methods to bring concise activity info
71
89
  # into the chat.
72
- #
90
+ #
73
91
  def build_activity_message(activity, response)
74
92
  # Set activity
75
93
  activity_hash = activity
76
- # Send response based on adapter
77
- case robot.config.robot.adapter
78
- when :slack
79
- # Send response
80
- response.reply("*#{activity_hash[:activityName]}*\n#{activity_hash[:activityDescription]}\n*Skulls:* #{activity_hash[:skulls].join(', ')}")
81
- else
82
- # Send response
83
- response.reply("#{activity_hash[:activityName]}\n#{activity_hash[:activityDescription]}\nSkulls: #{activity_hash[:skulls].join(', ')}")
84
- end
94
+ response.reply("*#{activity_hash[:activityName]}*\n#{activity_hash[:activityDescription]}\n*Skulls:* #{activity_hash[:skulls].join(', ')}")
85
95
  end
86
96
 
87
97
  # Xur Response Method
88
- #
98
+ #
89
99
  # Builds response to bring Xur items into chat.
90
- #
100
+ #
101
+ # TODO: Is slow due to each item having to be polled from Bungies server.
91
102
  def build_xur_message(response)
92
103
  # Set up our client
93
- destiny_client = DestinyAPI::Base.new(api_key)
104
+ destiny_client = Destiny::Client.new(api_key)
94
105
  # Set xur to our clients xur method
95
106
  xur = destiny_client.xur
96
107
 
97
- items = []
98
- xur.each do |key, value|
99
- value.each do |key, value|
100
- item_name = destiny_client.get_manifest_item(6, key[:item_hash])['itemName']
101
- item_cost = key[:item_cost]
102
- item_cost_name = destiny_client.get_manifest_item(6, key[:item_cost_hash])['itemName']
103
- constructed_item = "#{item_name}, #{item_cost} #{item_cost_name}"
104
- items << constructed_item
105
- end
106
- end
107
-
108
108
  # Check vendorDetails to see if anything is availible.
109
109
  if xur.nil?
110
- # If nothing, send to chat that he isn't there.
111
- response.reply "Xur isn't in game right now."
110
+ # If nil, send to chat that he isn't there.
111
+ response.reply "Xur isn't in the game world right now."
112
112
  else
113
- #If something, send to chat what he is selling.
113
+ # If not nil, cycle over items and build our items array.
114
+ items = []
115
+ xur.each do |key, value|
116
+ value.each do |key, value|
117
+ item_name = destiny_client.get_manifest_item(6, key[:item_hash])['itemName']
118
+ item_cost = key[:item_cost]
119
+ item_cost_name = destiny_client.get_manifest_item(6, key[:item_cost_hash])['itemName']
120
+ constructed_item = "#{item_name}, #{item_cost} #{item_cost_name}"
121
+ items << constructed_item
122
+ end
123
+ end
124
+ # Once parsed, send completed message to chat.
114
125
  response.reply "*Xur is selling:*\n#{items.join("\n")}"
115
126
  end
116
127
  end
128
+
129
+ def build_poe_message(level, response)
130
+ # Set up our client
131
+ destiny_client = Destiny::Client.new(api_key)
132
+ # Returns:
133
+ # {"activityHash"=>3508129769, "iconPath"=>"/img/destiny_content/arena/32_challenge.v2.png",
134
+ # "rounds"=>[{"enemyRaceHash"=>711470098, "skulls"=>[4]}, {"enemyRaceHash"=>3265589059, "skulls"=>[2]},
135
+ # {"enemyRaceHash"=>711470098, "skulls"=>[11]}, {"enemyRaceHash"=>3265589059, "skulls"=>[12]},
136
+ # {"enemyRaceHash"=>3265589059, "skulls"=>[3]}],
137
+ # "bossFight"=>false, "bossSkulls"=>[], "activeRewardIndexes"=>[0], "isCompleted"=>false}
138
+ arena = destiny_client.arena(level)
139
+ arena_hash = arena['activityHash']
140
+ arena_rounds = arena['rounds']
141
+ arena_name = destiny_client.activity_search(arena_hash)[:activityName]
142
+ arena_description = destiny_client.activity_search(arena_hash)[:activityDescription]
143
+
144
+ # For 32 & 34. Only goes to Round 5
145
+ parsed_rounds = []
146
+ arena_rounds.each_with_index do |round, index|
147
+ enemy = destiny_client.enemy_race(round['enemyRaceHash']).capitalize
148
+ raw_skulls = round['skulls']
149
+ skulls = []
150
+ raw_skulls.each do |skull|
151
+ parsed_skulls = destiny_client.skulls(skull).capitalize
152
+ skulls << parsed_skulls
153
+ end
154
+ parsed_round = "Round #{index+1}: #{enemy}-- #{skulls.join(", ")}"
155
+ parsed_rounds << parsed_round
156
+ end
157
+
158
+ # For 35, final skolas round.
159
+ if arena['bossFight'] == true
160
+ skulls = []
161
+ raw_skulls = arena['bossSkulls']
162
+ raw_skulls.each do |skull|
163
+ parsed_skulls = destiny_client.skulls(skull).capitalize
164
+ skulls << parsed_skulls
165
+ end
166
+ parsed_round = "Round 6: Skolas-- #{skulls.join(", ")}"
167
+ parsed_rounds << parsed_round
168
+ end
169
+
170
+ response.reply "*Level #{level} Prison of Elders*\n#{arena_name}\n#{arena_description}\n#{parsed_rounds.join("\n")}"
171
+
172
+
173
+
174
+ end
117
175
  end
118
-
176
+
119
177
  # Register the handler
120
- Lita.register_handler(Destiny)
178
+ Lita.register_handler(DestinyHandler)
121
179
  end
122
- end
180
+ end
data/lita-destiny.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-destiny"
3
- spec.version = "0.2.0"
3
+ spec.version = "0.2.1"
4
4
  spec.authors = ["PDaily"]
5
5
  spec.email = ["pat.irwin4@gmail.com"]
6
6
  spec.description = "Small lita.io handler for interacting with the Destiny API"
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.require_paths = ["lib"]
16
16
 
17
17
  spec.add_runtime_dependency "lita", "~> 4.3"
18
- spec.add_runtime_dependency "destiny_rb", "~> 0.1"
18
+ spec.add_runtime_dependency "destiny_rb", "~> 0.1" , ">= 0.1.2"
19
19
 
20
20
  spec.add_development_dependency "bundler", "~> 1.3"
21
21
  spec.add_development_dependency "pry-byebug", "~> 3.1", ">= 3.1.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-destiny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PDaily
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-30 00:00:00.000000000 Z
11
+ date: 2015-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -31,6 +31,9 @@ dependencies:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.1'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.1.2
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -38,6 +41,9 @@ dependencies:
38
41
  - - "~>"
39
42
  - !ruby/object:Gem::Version
40
43
  version: '0.1'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.1.2
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement