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
- .item_effects ⇒ Object
- .items ⇒ Object
- .match(match_id) ⇒ Object
- .motd_list ⇒ Object
- .motd_now ⇒ Object
- .pantheons ⇒ Object
- .player(player_name_or_id) ⇒ Object
- .queues ⇒ Object
- .roles ⇒ 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
86 87 88 |
# File 'lib/smite/game.rb', line 86 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
82 83 84 |
# File 'lib/smite/game.rb', line 82 def consumables @consumables ||= devices.select(&:consumable?) end |
.device(name_or_id) ⇒ Object Also known as: item, consumable, active
11 12 13 14 15 |
# File 'lib/smite/game.rb', line 11 def device(name_or_id) key = name_or_id.to_s.downcase.gsub(/[^\w]/,'') idx = device_hash[key] idx.nil? ? nil : devices[idx] end |
.devices ⇒ Object
74 75 76 |
# File 'lib/smite/game.rb', line 74 def devices @devices ||= client.items.map(&Item.method(:new)) end |
.god(name_or_id) ⇒ Object
20 21 22 23 24 |
# File 'lib/smite/game.rb', line 20 def god(name_or_id) key = name_or_id.to_s.downcase.gsub(/[^\w]/,'') idx = god_hash[key] idx.nil? ? nil : gods[idx] end |
.god_recommended_items(name_or_id) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/smite/game.rb', line 48 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
62 63 64 |
# File 'lib/smite/game.rb', line 62 def gods @gods ||= client.gods.map(&God.method(:new)) end |
.item_effects ⇒ Object
90 91 92 |
# File 'lib/smite/game.rb', line 90 def item_effects @effects ||= devices.map(&:active_effects).flatten.map(&:attribute).uniq end |
.items ⇒ Object
78 79 80 |
# File 'lib/smite/game.rb', line 78 def items @items ||= devices.select(&:item?) end |
.match(match_id) ⇒ Object
26 27 28 29 |
# File 'lib/smite/game.rb', line 26 def match(match_id) match_data = client.match_details(match_id) match_data.empty? ? nil : FullMatch.new(match_data) end |
.motd_list ⇒ Object
40 41 42 |
# File 'lib/smite/game.rb', line 40 def motd_list @motds ||= client.motd.map(&MOTD.method(:new)) end |
.motd_now ⇒ Object
36 37 38 |
# File 'lib/smite/game.rb', line 36 def motd_now motd_list[0] end |
.pantheons ⇒ Object
70 71 72 |
# File 'lib/smite/game.rb', line 70 def pantheons @pantheons ||= gods.map(&:pantheon).uniq end |
.player(player_name_or_id) ⇒ Object
31 32 33 34 |
# File 'lib/smite/game.rb', line 31 def player(player_name_or_id) player_data = client.player(player_name_or_id) player_data.empty? ? nil : Player.new(player_data[0]) end |
.queues ⇒ Object
44 45 46 |
# File 'lib/smite/game.rb', line 44 def queues @queues ||= Smite::Queue::QUEUES.map(&Queue.method(:new)) end |
.roles ⇒ Object
66 67 68 |
# File 'lib/smite/game.rb', line 66 def roles @roles ||= gods.map { |g| g.roles.strip }.uniq end |