Class: MiniMapCell
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- MiniMapCell
- Defined in:
- app/models/mini_map_cell.rb
Overview
This class describes a cell of mini map.
Instance Method Summary (collapse)
-
- (Object) more_than_map_size
Validate x and y are not more than mini_map.size.
-
- (Object) not_allowed_terrain
Validate sp_resource and construction are allowed on located terrain.
-
- (Integer) rq_prod_point
Return construction.rq_prod_point.
Instance Method Details
- (Object) more_than_map_size
Validate x and y are not more than mini_map.size.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/mini_map_cell.rb', line 16 def more_than_map_size return if mini_map_id.blank? mini_map = MiniMap.find(mini_map_id) return if mini_map.blank? if x + 1 > mini_map.size errors.add(:x, I18n.t('activerecord.errors.models.mini_map_cell.attributes.more_than_map_size')) elsif y + 1 > mini_map.size errors.add(:y, I18n.t('activerecord.errors.models.mini_map_cell.attributes.more_than_map_size')) end end |
- (Object) not_allowed_terrain
Validate sp_resource and construction are allowed on located terrain.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/mini_map_cell.rb', line 29 def not_allowed_terrain return if terrain_id.blank? if not sp_resource_id.blank? sp_resource = SpResource.find(sp_resource_id) if not sp_resource.blank? and sp_resource.terrain_id != terrain_id errors.add(:sp_resource, I18n.t('activerecord.errors.models.mini_map_cell.attributes.not_allowed_terrain')) end end if not construction_id.blank? construction = Construction.find(construction_id) if not construction.blank? and construction.terrain_id != terrain_id errors.add(:construction, I18n.t('activerecord.errors.models.mini_map_cell.attributes.not_allowed_terrain')) end end 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.
50 51 52 |
# File 'app/models/mini_map_cell.rb', line 50 def rq_prod_point return construction.rq_prod_point end |