Class: Mission

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/mission.rb

Overview

This class describes a mission.

Instance Method Summary (collapse)

Instance Method Details

- (String) category_symbol_txt

Return the description of category symbol.

Returns:

  • (String)


32
33
34
# File 'app/models/mission.rb', line 32

def category_symbol_txt
  return I18n.t('activerecord.attributes.mission.' + category_symbol)
end

- (Object) end_houdd_time_is_earlier_than_start_houdd_time

Validate start_houdd_time is earlier than end_houdd_time.



17
18
19
20
21
22
# File 'app/models/mission.rb', line 17

def end_houdd_time_is_earlier_than_start_houdd_time
  return if start_houdd_time.blank? or end_houdd_time.blank?
  if end_houdd_time < start_houdd_time
    errors.add(:base, I18n.t('activerecord.errors.models.mission.attributes.end_houdd_time_is_earlier_than_start_houdd_time'))
  end
end

- (String) name

Return the name(mini_map.name + category_symbol_txt) of this mission.

Returns:

  • (String)


26
27
28
# File 'app/models/mission.rb', line 26

def name
  return mini_map.name + '(' + category_symbol_txt + ')'
end

- (String) squads_txt

Return the squad list which belongs to this mission.

Returns:

  • (String)

    Comma separated squad.name



44
45
46
47
48
49
50
51
52
53
54
# File 'app/models/mission.rb', line 44

def squads_txt
  squads_txt = ''
  squads.each do |squad|
    if not squad.blank?
      squads_txt += squad.name
      squads_txt += ','
    end
  end
  squads_txt.chop! if squads_txt.last == ','
  return squads_txt
end

- (String) status_symbol_txt

Return the description of status symbol.

Returns:

  • (String)


38
39
40
# File 'app/models/mission.rb', line 38

def status_symbol_txt
  return I18n.t('activerecord.attributes.mission.' + status_symbol)
end

- (Object) strategy

Return the mission strategy which belongs to this mission. eval_script is called when the mission strategy is not initialized.

Returns:

  • (Object)

    mission strategy



59
60
61
62
63
64
65
# File 'app/models/mission.rb', line 59

def strategy
  if @loaded_strategy.blank?
    mission_strategy.eval_script
    @loaded_strategy = mission_strategy
  end
  return mission_strategy
end