Sha256: 35d2b65a1673ec4175222f4275e3bd25e8a7aad740e35a505af79224066a0cd7

Contents?: true

Size: 870 Bytes

Versions: 2

Compression:

Stored size: 870 Bytes

Contents

module Skyhook
  class Game < Skyhook::Core

    attr_reader :appid, :user, :game_name, :achievements, :stats

    def initialize( appid, steamid = nil )
      @appid = appid
      if steamid == nil
        # If steamid is not set a game should contain global data
        set_global_attributes
      else
        if steamid.is_a? Skyhook::User
          @user = steamid
        else
          @user = Skyhook::User.new steamid
        end

        set_user_attributes Skyhook::Core::ISteamUserStats.player_stats( appid, @user.steamid )
      end
    end

    def set_user_attributes( response )
      @game_name = response['gameName']

      @achievements = response['achievements']
      @stats = response['stats']
      @user.games= self
    end

    def set_global_attributes
      #Will return a games global stats
      raise NotImplementedError
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
skyhook-0.7.0 lib/skyhook/game.rb
skyhook-0.6.0 lib/skyhook/game.rb