Class: Smite::Game
- Inherits:
-
Object
- Object
- Smite::Game
- Defined in:
- lib/smite/game.rb
Class Attribute Summary collapse
-
.client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
- .actives ⇒ Object
- .authenticate!(dev_id, auth_key, format = 'json', lang = 1) ⇒ Object
- .consumables ⇒ Object
- .device(name_or_id) ⇒ Object (also: item, consumable, active)
- .devices ⇒ Object
- .god(name_or_id) ⇒ Object
- .god_recommended_items(name_or_id) ⇒ Object
- .gods ⇒ Object
- .items ⇒ Object
- .match(match_id) ⇒ Object
- .motd_list ⇒ Object
- .motd_now ⇒ Object
- .player(player_name) ⇒ Object
- .queues ⇒ Object
Class Attribute Details
.client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'lib/smite/game.rb', line 4 def client @client end |
Class Method Details
.actives ⇒ Object
75 76 77 |
# File 'lib/smite/game.rb', line 75 def actives @actives ||= devices.select(&:active?) end |
.authenticate!(dev_id, auth_key, format = 'json', lang = 1) ⇒ Object
6 7 8 9 |
# File 'lib/smite/game.rb', line 6 def authenticate!(dev_id, auth_key, format = 'json', lang = 1) @client = Smite::Client.new(dev_id, auth_key, lang) !client.session_id.nil? end |
.consumables ⇒ Object
71 72 73 |
# File 'lib/smite/game.rb', line 71 def consumables @consumables ||= devices.select(&:consumable?) end |
.device(name_or_id) ⇒ Object Also known as: item, consumable, active
11 12 13 14 |
# File 'lib/smite/game.rb', line 11 def device(name_or_id) idx = device_hash[name_or_id.to_s.downcase] idx.nil? ? nil : devices[idx] end |
.devices ⇒ Object
63 64 65 |
# File 'lib/smite/game.rb', line 63 def devices @devices ||= client.items.map(&Item.method(:new)) end |
.god(name_or_id) ⇒ Object
19 20 21 22 |
# File 'lib/smite/game.rb', line 19 def god(name_or_id) idx = god_hash[name_or_id.to_s.downcase] idx.nil? ? nil : gods[idx] end |
.god_recommended_items(name_or_id) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/smite/game.rb', line 45 def god_recommended_items(name_or_id) god = god(name_or_id) @rec_items ||= {} return @rec_items[god.id] unless @rec_items[god.id].nil? @rec_items[god.id] = [] recommended = client.god_recommended_items(god.id) recommended.group_by { |r| r['Role'] }.each do |role, items| @rec_items[god.id] << Smite::RecommendedItems.new(god.name, items, role) end @rec_items[god.id] end |
.gods ⇒ Object
59 60 61 |
# File 'lib/smite/game.rb', line 59 def gods @gods ||= client.gods.map(&God.method(:new)) end |
.items ⇒ Object
67 68 69 |
# File 'lib/smite/game.rb', line 67 def items @items ||= devices.select(&:item?) end |
.match(match_id) ⇒ Object
24 25 26 27 |
# File 'lib/smite/game.rb', line 24 def match(match_id) @matches ||= {} @matches[match_id] ||= Match.new(client.match_details(match_id)) end |
.motd_list ⇒ Object
37 38 39 |
# File 'lib/smite/game.rb', line 37 def motd_list @motds ||= client.motd.map(&MOTD.method(:new)) end |
.motd_now ⇒ Object
33 34 35 |
# File 'lib/smite/game.rb', line 33 def motd_now motd_list[0] end |