Class: PfrpgCore::Character
- Inherits:
-
Object
- Object
- PfrpgCore::Character
- Includes:
- Bonus, Derived::CombatBonuses, Derived::Magic, Derived::Misc
- Defined in:
- lib/pfrpg_core/character.rb
Instance Attribute Summary collapse
-
#alignment ⇒ Object
Returns the value of attribute alignment.
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#avatar ⇒ Object
Returns the value of attribute avatar.
-
#base_skills ⇒ Object
Returns the value of attribute base_skills.
-
#bonuses ⇒ Object
Returns the value of attribute bonuses.
-
#character_id ⇒ Object
Returns the value of attribute character_id.
-
#character_uuid ⇒ Object
Returns the value of attribute character_uuid.
-
#class_features ⇒ Object
Returns the value of attribute class_features.
-
#combat ⇒ Object
Returns the value of attribute combat.
-
#demographics ⇒ Object
Returns the value of attribute demographics.
-
#effects ⇒ Object
Returns the value of attribute effects.
-
#feats ⇒ Object
Returns the value of attribute feats.
-
#inventory ⇒ Object
Returns the value of attribute inventory.
-
#latest_levels ⇒ Object
Returns the value of attribute latest_levels.
-
#levels ⇒ Object
Returns the value of attribute levels.
-
#race ⇒ Object
Returns the value of attribute race.
-
#racial_bonuses ⇒ Object
Returns the value of attribute racial_bonuses.
-
#saves ⇒ Object
Returns the value of attribute saves.
-
#skills ⇒ Object
Returns the value of attribute skills.
-
#spellbooks ⇒ Object
Returns the value of attribute spellbooks.
-
#spells ⇒ Object
Returns the value of attribute spells.
Instance Method Summary collapse
- #apply_bonuses ⇒ Object
- #apply_effects(effects) ⇒ Object
- #as_json(options = {}) ⇒ Object
-
#initialize(params) ⇒ Character
constructor
A new instance of Character.
- #name ⇒ Object
- #prime_bonuses_with_racial_stats ⇒ Object
Methods included from Derived::Misc
#calc_speed, #explode_levels, #get_caster_level, #get_class_level, #gets_companion?, #gets_familiar?, #hit_dice, #hit_die, #hit_points, #initiative, #level_string, #misc_json, #parse_speed_bonuses, #size, #speed, #total_level
Methods included from Derived::Magic
#arcane_school, #bloodline, #can_arcane?, #can_divine?, #empty_spells, #filter, #filter_for_high_level, #filter_for_max_attribute, #gets_companion?, #gets_familiar?, #known_sorcerer_spells, #spells_per_level, #valid_spell?
Methods included from Derived::CombatBonuses
#armor_speed_penalty, #get_ac_penalty, #get_armor_modifier, #get_attack_filters, #get_damage_reduction, #get_deflection_modifier, #get_dodge_modifier, #get_highest_attack_bonus, #get_max_dex_bonus, #get_natural_armor, #get_size_modifier, #get_spell_resistance
Methods included from Bonus
Constructor Details
#initialize(params) ⇒ Character
Returns a new instance of Character.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pfrpg_core/character.rb', line 14 def initialize(params) @character_uuid = params[:uuid] @character_id = params[:id] # TODO: Refactor client to remove @character # computed by calling objects @character = params[:character] @avatar = params[:avatar] @demographics = params[:demographics] @race = params[:race][:race] @racial_bonuses = params[:race][:bonuses] prime_bonuses_with_racial_stats @attributes = PfrpgCore::Attributes.new(params[:attributes], @bonuses) @levels = params[:levels][:latest].map { |x| PfrpgCore::Level.new(x) } @latest_levels = params[:levels][:latest] @alignment = params[:alignment] @feats = params[:feats] @class_features = FeatureDuplicator.filter_duplicates(params[:features]) @inventory = params[:inventory] @base_skills = params[:base_skills] @spellbooks = params[:spellbooks] # uncomputable until bonuses are calculated apply_bonuses @attributes.set_bonuses(@bonuses) @attributes.max_dex = self.get_max_dex_bonus @saves = SavingThrows.new(params[:saves], @bonuses, @attributes) @combat = PfrpgCore::Combat.new(self) @skills = PfrpgCore::Skills.new(self) @spells = PfrpgCore::SpellBooks.new(self) end |
Instance Attribute Details
#alignment ⇒ Object
Returns the value of attribute alignment.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def alignment @alignment end |
#attributes ⇒ Object
Returns the value of attribute attributes.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def attributes @attributes end |
#avatar ⇒ Object
Returns the value of attribute avatar.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def avatar @avatar end |
#base_skills ⇒ Object
Returns the value of attribute base_skills.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def base_skills @base_skills end |
#bonuses ⇒ Object
Returns the value of attribute bonuses.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def bonuses @bonuses end |
#character_id ⇒ Object
Returns the value of attribute character_id.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def character_id @character_id end |
#character_uuid ⇒ Object
Returns the value of attribute character_uuid.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def character_uuid @character_uuid end |
#class_features ⇒ Object
Returns the value of attribute class_features.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def class_features @class_features end |
#combat ⇒ Object
Returns the value of attribute combat.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def combat @combat end |
#demographics ⇒ Object
Returns the value of attribute demographics.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def demographics @demographics end |
#effects ⇒ Object
Returns the value of attribute effects.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def effects @effects end |
#feats ⇒ Object
Returns the value of attribute feats.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def feats @feats end |
#inventory ⇒ Object
Returns the value of attribute inventory.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def inventory @inventory end |
#latest_levels ⇒ Object
Returns the value of attribute latest_levels.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def latest_levels @latest_levels end |
#levels ⇒ Object
Returns the value of attribute levels.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def levels @levels end |
#race ⇒ Object
Returns the value of attribute race.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def race @race end |
#racial_bonuses ⇒ Object
Returns the value of attribute racial_bonuses.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def racial_bonuses @racial_bonuses end |
#saves ⇒ Object
Returns the value of attribute saves.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def saves @saves end |
#skills ⇒ Object
Returns the value of attribute skills.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def skills @skills end |
#spellbooks ⇒ Object
Returns the value of attribute spellbooks.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def spellbooks @spellbooks end |
#spells ⇒ Object
Returns the value of attribute spells.
8 9 10 |
# File 'lib/pfrpg_core/character.rb', line 8 def spells @spells end |
Instance Method Details
#apply_bonuses ⇒ Object
49 50 51 |
# File 'lib/pfrpg_core/character.rb', line 49 def apply_bonuses apply_effects(PfrpgCore::EffectTotaler.new(self).effects) end |
#apply_effects(effects) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/pfrpg_core/character.rb', line 53 def apply_effects(effects) e = PfrpgCore::EffectProcessor.new(self, effects) e.process_effects.each do |effect| effect.apply(self) end end |
#as_json(options = {}) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/pfrpg_core/character.rb', line 64 def as_json(={}) p = { :id => @character_id, :uuid => @character_uuid, :character => @character, :demographics => @demographics, :attributes => @attributes, :combat => @combat, :saves => @saves, :misc => misc_json, :skills => @skills, :spells => @spells, :inventory => @inventory } p[:avatar] = AvatarURL.new(@avatar) if @avatar p end |
#name ⇒ Object
60 61 62 |
# File 'lib/pfrpg_core/character.rb', line 60 def name @demographics.character_name end |
#prime_bonuses_with_racial_stats ⇒ Object
44 45 46 47 |
# File 'lib/pfrpg_core/character.rb', line 44 def prime_bonuses_with_racial_stats @bonuses = PfrpgCore::Bonuses.new apply_effects(@racial_bonuses.map { |x| x.get_effects }.flatten) end |