smite_ruby 1.4.9 → 1.5.0
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 +4 -4
- data/lib/smite/client.rb +10 -1
- data/lib/smite/game.rb +11 -6
- data/lib/smite/god_stats.rb +29 -18
- data/lib/smite/item.rb +1 -1
- data/lib/smite/item_effect.rb +1 -1
- data/smite_ruby.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f9a4cc076631a270e034c469e8e3f22ce095373
|
4
|
+
data.tar.gz: 9f9839c006db93cb1df653ac77df88863f8a38dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00aa0449f24960adb8bb5f91234e52cfc5b295b684eaed8243ccf01ad9a5e70f6b0538093b63ce55f0423955338028350713719d6681580af9e317fd3d225b45
|
7
|
+
data.tar.gz: 1ed19147cd0c392b5fa8c9baea2dd797c662c113f72fd21b7d941c1d8c35df64153a9310a62578741057bd9caf0433f4b4d9210cb7572ea8335ca1cce9e6d7b4
|
data/lib/smite/client.rb
CHANGED
@@ -8,7 +8,7 @@ module Smite
|
|
8
8
|
@dev_id = dev_id
|
9
9
|
@auth_key = auth_key
|
10
10
|
@lang = [1,2,3,7,9,10,11,12,13].include?(lang) ? lang : 1
|
11
|
-
@created = Time.
|
11
|
+
@created = Time.new(0)
|
12
12
|
create_session
|
13
13
|
end
|
14
14
|
|
@@ -108,14 +108,23 @@ module Smite
|
|
108
108
|
return @session_id if valid_session?
|
109
109
|
|
110
110
|
response = api_call('createsession', [], false)
|
111
|
+
unless response && response['ret_msg'] == 'Approved'
|
112
|
+
return @session_id = nil
|
113
|
+
end
|
114
|
+
|
111
115
|
@session_id = response['session_id']
|
112
116
|
@created = Time.now
|
117
|
+
@session_id
|
113
118
|
end
|
114
119
|
|
115
120
|
def valid_session?
|
116
121
|
(created + (15 * 60)) > Time.now
|
117
122
|
end
|
118
123
|
|
124
|
+
def ping
|
125
|
+
self.class.get('/pingjson')
|
126
|
+
end
|
127
|
+
|
119
128
|
private
|
120
129
|
|
121
130
|
def api_call(method, params = [], session = true)
|
data/lib/smite/game.rb
CHANGED
@@ -9,7 +9,8 @@ module Smite
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def device(name_or_id)
|
12
|
-
|
12
|
+
key = name_or_id.to_s.downcase.gsub(/[^\w]/,'')
|
13
|
+
idx = device_hash[key]
|
13
14
|
idx.nil? ? nil : devices[idx]
|
14
15
|
end
|
15
16
|
alias_method :item, :device
|
@@ -17,7 +18,8 @@ module Smite
|
|
17
18
|
alias_method :active, :device
|
18
19
|
|
19
20
|
def god(name_or_id)
|
20
|
-
|
21
|
+
key = name_or_id.to_s.downcase.gsub(/[^\w]/,'')
|
22
|
+
idx = god_hash[key]
|
21
23
|
idx.nil? ? nil : gods[idx]
|
22
24
|
end
|
23
25
|
|
@@ -93,15 +95,18 @@ module Smite
|
|
93
95
|
|
94
96
|
def device_hash
|
95
97
|
@device_hash ||= (0...devices.count).each_with_object({}) do |idx, hash|
|
96
|
-
|
97
|
-
|
98
|
+
name_key = devices[idx].name.downcase.gsub(/[^\w]/,'')
|
99
|
+
|
100
|
+
hash[devices[idx].item_id.to_s] = idx
|
101
|
+
hash[name_key] = idx
|
98
102
|
end
|
99
103
|
end
|
100
104
|
|
101
105
|
def god_hash
|
102
106
|
@god_hash ||= (0...gods.count).each_with_object({}) do |idx, hash|
|
103
|
-
|
104
|
-
hash[gods[idx].
|
107
|
+
name_key = gods[idx].name.downcase.gsub(/[^\w]/,'')
|
108
|
+
hash[gods[idx].id.to_s] = idx
|
109
|
+
hash[name_key] = idx
|
105
110
|
end
|
106
111
|
end
|
107
112
|
end
|
data/lib/smite/god_stats.rb
CHANGED
@@ -4,26 +4,43 @@ module Smite
|
|
4
4
|
|
5
5
|
def initialize(god_name, data, params = { level: 0 })
|
6
6
|
super(data)
|
7
|
-
@name
|
7
|
+
@name = god_name
|
8
|
+
@items = params[:items] || []
|
9
|
+
|
10
|
+
# make sure level is between 0 and 20 (0 for base stats)
|
11
|
+
@level = [[params[:level].to_i, 20].min, 0].max
|
12
|
+
@stacks = params[:stacks] || {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def items
|
16
|
+
return @filtered_items unless @filtered_items.nil?
|
17
|
+
|
18
|
+
# only allow items
|
19
|
+
@items.select!(&:item?)
|
8
20
|
|
9
21
|
# make sure ratatoskr only has 1 acorn and items are unique
|
10
|
-
@items =
|
22
|
+
@items = @items.uniq do |a|
|
11
23
|
a.name =~ /acorn/i ? 'acorn' : a.name
|
12
24
|
end
|
13
25
|
|
14
|
-
# make sure only 6 items total
|
26
|
+
# make sure there are only 6 items total
|
15
27
|
@items = @items[0..5]
|
16
28
|
|
17
29
|
# make sure ratatoskr has at least 1 acorn
|
18
|
-
if
|
30
|
+
if @name.downcase == 'ratatoskr'
|
19
31
|
if !@items.any? { |i| i.name =~ /acorn/i }
|
20
32
|
@items[0] = Smite::Game.item('magic acorn')
|
21
33
|
end
|
34
|
+
else
|
35
|
+
# and that everyone else has none
|
36
|
+
@items.reject! { |item| item.name =~ /acorn/i }
|
22
37
|
end
|
23
38
|
|
24
|
-
#
|
25
|
-
|
26
|
-
@
|
39
|
+
# only accept physical items for physical gods and vice versa
|
40
|
+
physical = Smite::Game.god(@name).physical?
|
41
|
+
@filtered_items = @items.select do |item|
|
42
|
+
physical ? item.physical? : item.magic?
|
43
|
+
end
|
27
44
|
end
|
28
45
|
|
29
46
|
def at_level(new_level)
|
@@ -41,12 +58,6 @@ module Smite
|
|
41
58
|
@item_bonus = {}
|
42
59
|
@item_bonus[:flat] = default_bonus.dup
|
43
60
|
@item_bonus[:perc] = default_bonus.dup
|
44
|
-
|
45
|
-
# only accept physical items for physical gods and vice versa
|
46
|
-
physical = Smite::Game.god(@name).physical?
|
47
|
-
@items = @items.select do |item|
|
48
|
-
physical ? item.physical? : item.magic?
|
49
|
-
end
|
50
61
|
return @item_bonus if items.empty?
|
51
62
|
|
52
63
|
bonus_from_active_item_effects
|
@@ -167,11 +178,11 @@ module Smite
|
|
167
178
|
case name
|
168
179
|
when 'Scylla'
|
169
180
|
case level
|
170
|
-
when 0..
|
171
|
-
when
|
172
|
-
when
|
173
|
-
when
|
174
|
-
when
|
181
|
+
when 0..8 then 0
|
182
|
+
when 9..13 then 20
|
183
|
+
when 14..17 then 40
|
184
|
+
when 18..19 then 60
|
185
|
+
when 20 then 80
|
175
186
|
end
|
176
187
|
when 'Ares'
|
177
188
|
30 * items.count(&:aura?)
|
data/lib/smite/item.rb
CHANGED
@@ -12,7 +12,7 @@ module Smite
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.physical_item_trees
|
15
|
-
[7573, 7827, 7922, 8268, 9624, 9812, 9825, 9830, 9833, 10190, 10662, 11468, 12667, 12671]
|
15
|
+
[7573, 7827, 7922, 8268, 9624, 9812, 9825, 9830, 9833, 10190, 10662, 11122, 11468, 12667, 12671]
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.magical_item_trees
|
data/lib/smite/item_effect.rb
CHANGED
data/smite_ruby.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
$:.push File.expand_path("../lib", __FILE__)
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = 'smite_ruby'
|
4
|
-
s.version = '1.
|
5
|
-
s.date = '2016-02-
|
4
|
+
s.version = '1.5.0'
|
5
|
+
s.date = '2016-02-22'
|
6
6
|
s.summary = 'Ruby Smite API'
|
7
7
|
s.description = 'Ruby Client for consuming the Smite API'
|
8
8
|
s.authors = ['NcUltimate']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smite_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NcUltimate
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|