playlyfe_client 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 170a7ef3d15bd9bb481d9e1ba25913fec61f3f3a
4
- data.tar.gz: ed8b757df181b7e8379e12c4ff6830df4ee0be88
3
+ metadata.gz: f60f5a03a4b845f9fa638d24b10d74fde2e4b3e2
4
+ data.tar.gz: 9704cd30d13338af3b5627a91536968e94c4ca7b
5
5
  SHA512:
6
- metadata.gz: 525d488f25edd8ecf245c541acaa90dca294cdca4064ebd70fef8e118ccdda60572e80f6b9c0ed3b8b7a571c99295b5fb43728ea71e0978293668938a672e569
7
- data.tar.gz: 91ba1e4b33d306f0a5732bc18e89d23baea470ddf307e5d2a8788f7336f9884d7db759f4a19b99e24aab1fe8700b5484c26e03a8def8d156163e9b6bd9096295
6
+ metadata.gz: 46decdb377e1314c6b3f3142bc239fc5c79d8ca9cf8df771a5a578efa58abdfee4d97abca2cdfe66ecd592fc61a4202910b00b77f76d9c13fd7ee81e2ccf1e77
7
+ data.tar.gz: 7004a254a84bb638da2ecc8edda3ff07562d363e035b143d95da01c3ad4bdfc8aca22809810a5362b19f805e8dd1933d6b28833808856402cc259cb8e42fba06
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- playlyfe_client (1.1.0)
4
+ playlyfe_client (1.1.1)
5
5
  json
6
6
  jwt
7
7
  rest-client
@@ -4,7 +4,7 @@ module PlaylyfeClient
4
4
  class Base < PlaylyfeClient::V2::Event
5
5
  attr_reader :actor_id, :actor_alias #who trigger event (player or admin)
6
6
  attr_reader :player_id, :player_alias #who receive results of event (player)
7
- attr_reader :rule , :process, :action #what triggers event
7
+ attr_reader :rule_id , :rule_name, :process_id, :process_name, :action_id, :action_name #what triggers event
8
8
  attr_reader :count #The count with which the action was played.
9
9
  attr_reader :changes
10
10
 
@@ -12,6 +12,19 @@ module PlaylyfeClient
12
12
  game.players.find(player_id)
13
13
  end
14
14
 
15
+ def rule
16
+ rule_id #todo
17
+ end
18
+
19
+ def process
20
+ process_id #todo
21
+ end
22
+
23
+ def action
24
+ return nil if action_id.nil?
25
+ game.actions.find(action_id)
26
+ end
27
+
15
28
  private
16
29
 
17
30
  def initialize(ev_hash,game,player=nil)
@@ -30,9 +43,14 @@ module PlaylyfeClient
30
43
  end
31
44
  end
32
45
 
33
- @rule= @ev_hash["rule"]["id"] unless @ev_hash["rule"].nil?
34
- @process= @ev_hash["process"]["id"] unless @ev_hash["process"].nil?
35
- @action= @ev_hash["action"]["id"] unless @ev_hash["action"].nil?
46
+ ["action", "rule", "process"].each do |att|
47
+ unless @ev_hash[att].nil?
48
+ instance_variable_set("@#{att}_id", @ev_hash[att]["id"])
49
+ instance_variable_set("@#{att}_name", @ev_hash[att]["name"])
50
+ end
51
+ end
52
+
53
+
36
54
  @count= @ev_hash["count"] || 0
37
55
 
38
56
  @player_id=@actor_id
@@ -49,9 +49,14 @@ module PlaylyfeClient
49
49
  data=connection.get_game_image_data
50
50
  puts(data)
51
51
  end
52
-
53
- def events
54
- @events ||= PlaylyfeClient::V2::EventCollection.new(self)
52
+
53
+ #results are cached if start_time is nil (events for last 24 hours), otherwise direct call to Playlyfe is made
54
+ def events(start_time=nil,end_time=nil)
55
+ if start_time.nil?
56
+ @events ||= PlaylyfeClient::V2::EventCollection.new(self)
57
+ else
58
+ PlaylyfeClient::V2::EventCollection.new(self, self.connection.get_game_events_array(start_time, end_time))
59
+ end
55
60
  end
56
61
 
57
62
  private
@@ -36,8 +36,11 @@ module PlaylyfeClient
36
36
  end
37
37
  end
38
38
 
39
- def scores
40
- @scores||=fill_scores
39
+ def scores(force_refill=false)
40
+ if (!defined?(@scores) || force_refill)
41
+ @scores=fill_scores
42
+ end
43
+ @scores
41
44
  end
42
45
 
43
46
  def roles_in_team(team)
@@ -56,8 +59,13 @@ module PlaylyfeClient
56
59
  game.leaderboards.for_players
57
60
  end
58
61
 
62
+ #results are cached if start_time is nil, otherwise, direct call to Playlyfe is made
59
63
  def events(start_time=nil,end_time=nil)
60
- @events ||= PlaylyfeClient::V2::EventCollection.new(game, game.connection.get_player_events_array(self.id,start_time, end_time), self)
64
+ if start_time.nil?
65
+ @events ||= PlaylyfeClient::V2::EventCollection.new(game, game.connection.get_player_events_array(self.id), self)
66
+ else
67
+ PlaylyfeClient::V2::EventCollection.new(game, game.connection.get_player_events_array(self.id, start_time, end_time), self)
68
+ end
61
69
  end
62
70
 
63
71
  private
@@ -13,9 +13,14 @@ module PlaylyfeClient
13
13
  def leaderboards
14
14
  @game.leaderboards.for_teams
15
15
  end
16
-
16
+
17
+ #results are cached if start_time is nil (events for last 24 hours), otherwise direct call to Playlyfe is made
17
18
  def events(start_time=nil,end_time=nil)
18
- @events ||= PlaylyfeClient::V2::EventCollection.new(game, game.connection.get_team_events_array(self.id,start_time, end_time), self)
19
+ if start_time.nil?
20
+ @events ||= PlaylyfeClient::V2::EventCollection.new(game, game.connection.get_team_events_array(self.id), self)
21
+ else
22
+ PlaylyfeClient::V2::EventCollection.new(game, game.connection.get_team_events_array(self.id,start_time, end_time), self)
23
+ end
19
24
  end
20
25
 
21
26
  private
@@ -1,3 +1,3 @@
1
1
  module PlaylyfeClient
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playlyfe_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-27 00:00:00.000000000 Z
11
+ date: 2016-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json