Class: Studio::Group::CustomCondition

Inherits:
Object
  • Object
show all
Defined in:
scripts/00800 Studio/00001 Data/00011 Group.rb

Overview

Data class describing a custom group condition

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#relation_with_previous_conditionSymbol (readonly)

Relation of the condition (:AND, :OR)

Returns:

  • (Symbol)


52
53
54
# File 'scripts/00800 Studio/00001 Data/00011 Group.rb', line 52

def relation_with_previous_condition
  @relation_with_previous_condition
end

#typeSymbol (readonly)

Type of the custom condition (:enabled_switch or :map_id)

Returns:

  • (Symbol)


44
45
46
# File 'scripts/00800 Studio/00001 Data/00011 Group.rb', line 44

def type
  @type
end

#valueInteger (readonly)

Value of the condition

Returns:



48
49
50
# File 'scripts/00800 Studio/00001 Data/00011 Group.rb', line 48

def value
  @value
end

Instance Method Details

#evaluate

Evaluate the condition



65
66
67
68
69
70
71
72
73
74
# File 'scripts/00800 Studio/00001 Data/00011 Group.rb', line 65

def evaluate
  case @type
  when :enabled_switch
    return PFM.game_state.game_switches[@value]
  when :map_id
    return PFM.game_state.game_map.map_id == @value
  else
    return false
  end
end

#reduce_evaluate(previous) ⇒ Boolean

Evaluate the condition in a reduce context

Parameters:

  • previous (Boolean)

    result of the previous condition

Returns:

  • (Boolean)


57
58
59
60
61
62
# File 'scripts/00800 Studio/00001 Data/00011 Group.rb', line 57

def reduce_evaluate(previous)
  return false if @relation_with_previous_condition == :AND && !previous
  return true if @relation_with_previous_condition == :OR && previous

  return evaluate
end