Class: Core::Models::Campaigns::TokenPosition
- Inherits:
-
Object
- Object
- Core::Models::Campaigns::TokenPosition
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/core/models/campaigns/token_position.rb
Overview
This is the instanciation of a token in one of the map of the campaign
Instance Attribute Summary collapse
-
#map ⇒ Core::Models::Campaigns::Map
The map where this token is instanciated.
-
#token ⇒ Core::Models::Campaigns::Token
The source of the token, used to determine its appearance.
-
#x ⇒ Integer
The number of cells from the left before this token.
-
#y ⇒ Integer
The number of cells from the top before this token.
Instance Method Summary collapse
-
#coordinates_bounds ⇒ Object
Validates that the coordinates of the token position are in the map bounds.
Instance Attribute Details
#map ⇒ Core::Models::Campaigns::Map
Returns the map where this token is instanciated.
23 |
# File 'lib/core/models/campaigns/token_position.rb', line 23 :map, class_name: 'Core::Models::Campaigns::Map', inverse_of: :positions |
#token ⇒ Core::Models::Campaigns::Token
Returns the source of the token, used to determine its appearance.
27 |
# File 'lib/core/models/campaigns/token_position.rb', line 27 belongs_to :token, class_name: 'Core::Models::Campaigns::Token', inverse_of: :positions |
#x ⇒ Integer
Returns the number of cells from the left before this token.
16 |
# File 'lib/core/models/campaigns/token_position.rb', line 16 field :x, type: Integer, default: 0 |
#y ⇒ Integer
Returns the number of cells from the top before this token.
19 |
# File 'lib/core/models/campaigns/token_position.rb', line 19 field :y, type: Integer, default: 0 |
Instance Method Details
#coordinates_bounds ⇒ Object
Validates that the coordinates of the token position are in the map bounds.
32 33 34 35 |
# File 'lib/core/models/campaigns/token_position.rb', line 32 def coordinates_bounds errors.add(:x, 'bounds') if map.nil? or x < 0 or x >= map.width errors.add(:y, 'bounds') if map.nil? or y < 0 or y >= map.height end |