Class: MiniMapRoad
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- MiniMapRoad
- Defined in:
- app/models/mini_map_road.rb
Overview
This class describes a road of mini map.
Instance Method Summary (collapse)
-
- (Boolean) constructing?
Return true or false by whether level up is already registered to production_queue or not.
-
- (Boolean) destroying?
Return true or false by whether destroy is already registered to production_queue or not.
-
- (Integer) rq_prod_point
Return construction.rq_prod_point.
-
- (Object) same_start_and_end
Validate start_mini_map_id and end_mini_map_id are different.
-
- (String) status_txt
Return the description of status.
Instance Method Details
- (Boolean) constructing?
Return true or false by whether level up is already registered to production_queue or not.
21 22 23 24 25 |
# File 'app/models/mini_map_road.rb', line 21 def constructing? constructing_queue = ProductionQueue.find_by_symbol_and_queue_id_and_destroy_flg(:mini_map_road.to_s, id, false) return true unless constructing_queue.blank? return false end |
- (Boolean) destroying?
Return true or false by whether destroy is already registered to production_queue or not.
29 30 31 32 33 |
# File 'app/models/mini_map_road.rb', line 29 def = ProductionQueue.find_by_symbol_and_queue_id_and_destroy_flg(:mini_map_road.to_s, id, true) return true unless .blank? return false end |
- (Integer) rq_prod_point
Return construction.rq_prod_point. This function is provided to keep same interface among mini_map_cell, mini_map_road and item.
53 54 55 |
# File 'app/models/mini_map_road.rb', line 53 def rq_prod_point return (level + 1) * Params::ROAD_BUILD_COST_BASE end |
- (Object) same_start_and_end
Validate start_mini_map_id and end_mini_map_id are different.
13 14 15 16 17 |
# File 'app/models/mini_map_road.rb', line 13 def same_start_and_end if start_mini_map_id == end_mini_map_id errors.add(:base, I18n.t('activerecord.errors.models.mini_map_road.attributes.same_start_and_end')) end end |
- (String) status_txt
Return the description of status. It could be 'level_up', 'destroying', 'active' and 'disable'.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/models/mini_map_road.rb', line 38 def status_txt if constructing? return I18n.t('activerecord.attributes.mini_map_road.construct') elsif return I18n.t('activerecord.attributes.mini_map_road.destroy') elsif active_flg return I18n.t('activerecord.attributes.mini_map_road.active') else return I18n.t('activerecord.attributes.mini_map_road.disable') end end |