Class: Smite::Game

Inherits:
Object
  • Object
show all
Defined in:
lib/smite/game.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.clientObject (readonly)

Returns the value of attribute client.



4
5
6
# File 'lib/smite/game.rb', line 4

def client
  @client
end

Class Method Details

.activesObject



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

.consumablesObject



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

.devicesObject



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


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

.godsObject



59
60
61
# File 'lib/smite/game.rb', line 59

def gods
  @gods ||= client.gods.map(&God.method(:new))
end

.itemsObject



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_listObject



37
38
39
# File 'lib/smite/game.rb', line 37

def motd_list
  @motds ||= client.motd.map(&MOTD.method(:new))
end

.motd_nowObject



33
34
35
# File 'lib/smite/game.rb', line 33

def motd_now
  motd_list[0]
end

.player(player_name) ⇒ Object



29
30
31
# File 'lib/smite/game.rb', line 29

def player(player_name)
  Player.new(player_name)
end

.queuesObject



41
42
43
# File 'lib/smite/game.rb', line 41

def queues
  @queues ||= Smite::Queue::QUEUES.map(&Queue.method(:new))
end