class Smite::Game

Attributes

client[R]

Public Class Methods

active(name_or_id)
Alias for: device
actives() click to toggle source
# File lib/smite/game.rb, line 86
def actives
  @actives ||= devices.select(&:active?)
end
authenticate!(dev_id, auth_key, format = 'json', lang = 1) click to toggle source
# 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
consumable(name_or_id)
Alias for: device
consumables() click to toggle source
# File lib/smite/game.rb, line 82
def consumables
  @consumables ||= devices.select(&:consumable?)
end
device(name_or_id) click to toggle source
# 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
Also aliased as: item, consumable, active
devices() click to toggle source
# File lib/smite/game.rb, line 74
def devices
  @devices ||= client.items.map(&Item.method(:new))
end
god(name_or_id) click to toggle source
# 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
gods() click to toggle source
# File lib/smite/game.rb, line 62
def gods
  @gods ||= client.gods.map(&God.method(:new))
end
item(name_or_id)
Alias for: device
item_effects() click to toggle source
# File lib/smite/game.rb, line 90
def item_effects
  @effects ||= devices.map(&:active_effects).flatten.map(&:attribute).uniq
end
items() click to toggle source
# File lib/smite/game.rb, line 78
def items
  @items ||= devices.select(&:item?)
end
match(match_id) click to toggle source
# 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() click to toggle source
# File lib/smite/game.rb, line 40
def motd_list
  @motds ||= client.motd.map(&MOTD.method(:new))
end
motd_now() click to toggle source
# File lib/smite/game.rb, line 36
def motd_now
  motd_list[0]
end
pantheons() click to toggle source
# File lib/smite/game.rb, line 70
def pantheons
  @pantheons ||= gods.map(&:pantheon).uniq
end
player(player_name_or_id) click to toggle source
# 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() click to toggle source
# File lib/smite/game.rb, line 44
def queues
  @queues ||= Smite::Queue::QUEUES.map(&Queue.method(:new))
end
roles() click to toggle source
# File lib/smite/game.rb, line 66
def roles
  @roles ||= gods.map { |g| g.roles.strip }.uniq
end

Private Class Methods

device_hash() click to toggle source
# File lib/smite/game.rb, line 96
def device_hash
  @device_hash ||= (0...devices.count).each_with_object({}) do |idx, hash|
    name_key = devices[idx].name.downcase.gsub(/[^\w]/,'')

    hash[devices[idx].item_id.to_s] = idx
    hash[name_key]                  = idx
  end
end
god_hash() click to toggle source
# File lib/smite/game.rb, line 105
def god_hash
  @god_hash ||= (0...gods.count).each_with_object({}) do |idx, hash|
    name_key = gods[idx].name.downcase.gsub(/[^\w]/,'')
    hash[gods[idx].id.to_s] = idx
    hash[name_key]          = idx
  end
end