Class: PlaylyfeClient::V2::CompoundMetric

Inherits:
Metric show all
Defined in:
lib/playlyfe_client/v2/metric/compound_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

#formulaObject (readonly)

Returns the value of attribute formula.



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

def formula
  @formula
end

Instance Method Details

#apply_reward(reward, scores) ⇒ Object



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

def apply_reward(reward, scores)
  metric_sym=self.id.to_sym
  case reward[:verb]
    when "add"
     scores[:compounds][metric_sym]+=reward[:value].to_i
    when "remove"
     scores[:compounds][metric_sym]-=reward[:value].to_i
    when "set"
     scores[:compounds][metric_sym]=reward[:value].to_i
  end
end