Class: PlaylyfeClient::V2::Player
- Inherits:
-
Player
- Object
- Player
- PlaylyfeClient::V2::Player
show all
- Defined in:
- lib/playlyfe_client/v2/player.rb
Instance Attribute Summary collapse
Attributes inherited from Player
#game
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Player
all, #badges, #items_from_sets, #levels, #points, #states
Instance Attribute Details
#alias ⇒ Object
Returns the value of attribute alias.
7
8
9
|
# File 'lib/playlyfe_client/v2/player.rb', line 7
def alias
@alias
end
|
#enabled ⇒ Object
Returns the value of attribute enabled.
7
8
9
|
# File 'lib/playlyfe_client/v2/player.rb', line 7
def enabled
@enabled
end
|
#id ⇒ Object
Returns the value of attribute id.
7
8
9
|
# File 'lib/playlyfe_client/v2/player.rb', line 7
def id
@id
end
|
Class Method Details
.create(pl_hash, game) ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/playlyfe_client/v2/player.rb', line 9
def self.create(pl_hash, game)
unless pl_hash.has_key?(:id) && pl_hash.has_key?(:alias)
fail PlaylyfeClient::PlayerError.new("{\"error\": \"keys missing\", \"error_description\": \"Player's hash is missing values for keys :id and :alias!\"}")
end
p=self.new( game.connection.post_create_player( pl_hash.select { |key, value| [:id, :alias].include?(key) } ), game )
game.players.add(p)
p
end
|
Instance Method Details
#enabled? ⇒ Boolean
23
24
25
|
# File 'lib/playlyfe_client/v2/player.rb', line 23
def enabled?
enabled
end
|
#events(start_time = nil, end_time = nil) ⇒ Object
results are cached if start_time is nil, otherwise, direct call to Playlyfe is made
61
62
63
64
65
66
67
|
# File 'lib/playlyfe_client/v2/player.rb', line 61
def events(start_time=nil,end_time=nil)
if start_time.nil?
@events ||= PlaylyfeClient::V2::EventCollection.new(game, game.connection.get_player_events_array(self.id), self)
else
PlaylyfeClient::V2::EventCollection.new(game, game.connection.get_player_events_array(self.id, start_time, end_time), self)
end
end
|
#name ⇒ Object
19
20
21
|
# File 'lib/playlyfe_client/v2/player.rb', line 19
def name
@alias
end
|
#play(action, variables = {}) ⇒ Object
27
28
29
30
|
# File 'lib/playlyfe_client/v2/player.rb', line 27
def play(action, variables={})
action.play_by(self, variables)
reload!
end
|
#players_leaderboards ⇒ Object
56
57
58
|
# File 'lib/playlyfe_client/v2/player.rb', line 56
def players_leaderboards
game.leaderboards.for_players
end
|
#reload! ⇒ Object
32
33
34
35
|
# File 'lib/playlyfe_client/v2/player.rb', line 32
def reload!
@profile_hash= game.connection.get_full_player_profile_hash(self.id)
@scores=fill_scores
end
|
#roles_in_team(team) ⇒ Object
44
45
46
|
# File 'lib/playlyfe_client/v2/player.rb', line 44
def roles_in_team(team)
teams.empty? ? [] : (@teams_roles[team.id].nil? ? [] : @teams_roles[team.id])
end
|
#scores(force_refill = false) ⇒ Object
37
38
39
40
41
42
|
# File 'lib/playlyfe_client/v2/player.rb', line 37
def scores(force_refill=false)
if (!defined?(@scores) || force_refill)
@scores=fill_scores
end
@scores
end
|
#teams ⇒ Object
48
49
50
|
# File 'lib/playlyfe_client/v2/player.rb', line 48
def teams
@teams||= fill_teams
end
|
#teams_leaderboards ⇒ Object
52
53
54
|
# File 'lib/playlyfe_client/v2/player.rb', line 52
def teams_leaderboards
game.leaderboards.for_teams
end
|