Sha256: d06f40112da9b8d4dadf6be73f2dc579f3345046799d55b3f14c52266b22f510

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

require_relative "./errors.rb"

module PlaylyfeClient
  class Player 
    
    attr_reader :game

    def self.create(player_hash, game)
      nil
    end  

    def self.all(game)
      game.players
    end  

    def play(action)
      false
    end
    
    def scores
      {points: {} ,sets: {}, states: {}, compound: {}}
    end

    def items_from_sets
      items=[]
      self.scores[:sets].each_pair do | key, value |
        value.each do |item_h|
          items << item_h.merge({metric_id: key.to_s}) if item_h[:count] > 0
        end  
      end  
      items.sort! {|a,b| a[:name] <=> b[:name]}
      items
    end      

    def badges
      self.items_from_sets
    end

    def points
      points=[]
      self.scores[:points].each_pair do | key, value |
        points << {count: value, metric_id: key.to_s}
      end
      points 
    end 

    def states
      states=[]
      self.scores[:states].each_pair do | key, value |
        states << {name: value, metric_id: key.to_s}
      end
      states 
    end  

    def levels
      self.states
    end 

    def teams
      []
    end

    def players_leaderboards
      []
    end
    
    def teams_leaderboards  
      []
    end  

    def events(start_time=nil,end_time=nil)
      []
    end

    private 
      def initialize(game)
        @game=game
      end  
  end
end  

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
playlyfe_client-1.1.3 lib/playlyfe_client/player.rb
playlyfe_client-1.1.2 lib/playlyfe_client/player.rb
playlyfe_client-1.1.1 lib/playlyfe_client/player.rb
playlyfe_client-1.1.0 lib/playlyfe_client/player.rb