Class: Arkaan::Campaigns::Character
- Inherits:
-
Object
- Object
- Arkaan::Campaigns::Character
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/arkaan/campaigns/character.rb
Overview
A character sheet represents a character played by a player in a campaign.
Instance Attribute Summary collapse
-
#data ⇒ Hash
The heart of the Arkaan::Campaigns::Character class, the polymorphic data representing all the fields of a character sheet are validated using the validator of the associated plugin, and created/updated with the corresponding form.
-
#invitation ⇒ Arkaan::Campaigns::Invitation
The invitation of the player playing this character.
-
#selected ⇒ Boolean
TRUE if the sheet is currently selected by the player, FALSE otherwise.
Instance Method Summary collapse
- #campaign ⇒ Object
-
#player ⇒ Arkaan::Account
Returns the player linked to this character.
-
#select! ⇒ Object
Puts the selected flag to TRUE for this character and to FALSE for all the other characters for the same player in the same campaign.
Instance Attribute Details
#data ⇒ Hash
Returns the heart of the Arkaan::Campaigns::Character class, the polymorphic data representing all the fields of a character sheet are validated using the validator of the associated plugin, and created/updated with the corresponding form.
17 |
# File 'lib/arkaan/campaigns/character.rb', line 17 field :data, type: Hash, default: {} |
#invitation ⇒ Arkaan::Campaigns::Invitation
Returns the invitation of the player playing this character.
21 |
# File 'lib/arkaan/campaigns/character.rb', line 21 belongs_to :invitation, class_name: 'Arkaan::Campaigns::Invitation', inverse_of: :characters |
#selected ⇒ Boolean
Returns TRUE if the sheet is currently selected by the player, FALSE otherwise.
11 |
# File 'lib/arkaan/campaigns/character.rb', line 11 field :selected, type: Boolean, default: false |
Instance Method Details
#campaign ⇒ Object
29 30 31 |
# File 'lib/arkaan/campaigns/character.rb', line 29 def campaign invitation.campaign end |
#player ⇒ Arkaan::Account
Returns the player linked to this character.
25 26 27 |
# File 'lib/arkaan/campaigns/character.rb', line 25 def player invitation.account end |
#select! ⇒ Object
Puts the selected flag to TRUE for this character and to FALSE for all the other characters for the same player in the same campaign.
35 36 37 38 39 40 41 42 |
# File 'lib/arkaan/campaigns/character.rb', line 35 def select! invitation.characters.each do |character| character.update_attribute(:selected, false) character.save! end update_attribute(:selected, true) save! end |