Class: PlaylyfeClient::V2::SetMetric

Inherits:
Metric show all
Defined in:
lib/playlyfe_client/v2/metric/set_metric.rb

Instance Attribute Summary collapse

Attributes inherited from Metric

#description, #id, #name, #type

Attributes inherited from Metric

#game

Instance Method Summary collapse

Methods inherited from Metric

create_from

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



6
7
8
# File 'lib/playlyfe_client/v2/metric/set_metric.rb', line 6

def items
  @items
end

Instance Method Details

#apply_reward(reward, scores) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/playlyfe_client/v2/metric/set_metric.rb', line 8

def apply_reward(reward, scores)
  reward[:value].each do |rwd_item|
    score_item=scores[:sets][self.id.to_sym].detect { |i| i[:name] == rwd_item[:name] }
    case reward[:verb]
      when "add"
       score_item[:count]+=rwd_item[:count].to_i
      when "remove"
       score_item[:count]-=rwd_item[:count].to_i
      when "set"
       score_item[:count]=rwd_item[:count].to_i
    end
  end  
end