Class: PlaylyfeClient::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/playlyfe_client/player.rb

Direct Known Subclasses

V2::Player

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gameObject (readonly)

Returns the value of attribute game.



6
7
8
# File 'lib/playlyfe_client/player.rb', line 6

def game
  @game
end

Class Method Details

.all(game) ⇒ Object



12
13
14
# File 'lib/playlyfe_client/player.rb', line 12

def self.all(game)
  game.players
end

.create(player_hash, game) ⇒ Object



8
9
10
# File 'lib/playlyfe_client/player.rb', line 8

def self.create(player_hash, game)
  nil
end

Instance Method Details

#badgesObject



39
40
41
# File 'lib/playlyfe_client/player.rb', line 39

def badges
  self.items_from_sets
end

#events(start_time = nil, end_time = nil) ⇒ Object



75
76
77
# File 'lib/playlyfe_client/player.rb', line 75

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

#items_from_setsObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/playlyfe_client/player.rb', line 28

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

#levelsObject



59
60
61
# File 'lib/playlyfe_client/player.rb', line 59

def levels
  self.states
end

#play(action) ⇒ Object



16
17
18
# File 'lib/playlyfe_client/player.rb', line 16

def play(action)
  false
end

#players_leaderboardsObject



67
68
69
# File 'lib/playlyfe_client/player.rb', line 67

def players_leaderboards
  []
end

#pointsObject



43
44
45
46
47
48
49
# File 'lib/playlyfe_client/player.rb', line 43

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

#reload!Object



20
21
22
# File 'lib/playlyfe_client/player.rb', line 20

def reload!
  nil
end

#scoresObject



24
25
26
# File 'lib/playlyfe_client/player.rb', line 24

def scores
  {points: {} ,sets: {}, states: {}, compound: {}}
end

#statesObject



51
52
53
54
55
56
57
# File 'lib/playlyfe_client/player.rb', line 51

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

#teamsObject



63
64
65
# File 'lib/playlyfe_client/player.rb', line 63

def teams
  []
end

#teams_leaderboardsObject



71
72
73
# File 'lib/playlyfe_client/player.rb', line 71

def teams_leaderboards  
  []
end