Class: DdbRuby::FifthEdition::Character
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::Character
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4526 def self.from_dynamic!(d) d = Types::Hash[d] new( id: d.fetch("id"), user_id: d.fetch("userId"), username: d.fetch("username"), is_assigned_to_player: d.fetch("isAssignedToPlayer"), readonly_url: d.fetch("readonlyUrl"), decorations: Decorations.from_dynamic!(d.fetch("decorations")), character_name: d.fetch("name"), social_name: d.fetch("socialName"), gender: d.fetch("gender"), faith: d.fetch("faith"), age: d.fetch("age"), hair: d.fetch("hair"), eyes: d.fetch("eyes"), skin: d.fetch("skin"), height: d.fetch("height"), weight: d.fetch("weight"), inspiration: d.fetch("inspiration"), base_hit_points: d.fetch("baseHitPoints"), bonus_hit_points: d.fetch("bonusHitPoints"), override_hit_points: d.fetch("overrideHitPoints"), removed_hit_points: d.fetch("removedHitPoints"), temporary_hit_points: d.fetch("temporaryHitPoints"), current_xp: d.fetch("currentXp"), alignment_id: d.fetch("alignmentId"), lifestyle_id: d.fetch("lifestyleId"), stats: d.fetch("stats").map { |x| BonusStatElement.from_dynamic!(x) }, bonus_stats: d.fetch("bonusStats").map { |x| BonusStatElement.from_dynamic!(x) }, override_stats: d.fetch("overrideStats").map { |x| BonusStatElement.from_dynamic!(x) }, background: CharacterBackground.from_dynamic!(d.fetch("background")), race: d.fetch("race") ? Race.from_dynamic!(d.fetch("race")) : nil, race_definition_id: d.fetch("raceDefinitionId"), race_definition_type_id: d.fetch("raceDefinitionTypeId"), notes: Notes.from_dynamic!(d.fetch("notes")), traits: Traits.from_dynamic!(d.fetch("traits")), preferences: Preferences.from_dynamic!(d.fetch("preferences")), configuration: Configuration.from_dynamic!(d.fetch("configuration")), lifestyle: d.fetch("lifestyle"), inventory: d.fetch("inventory").map { |x| Inventory.from_dynamic!(x) }, currencies: Currencies.from_dynamic!(d.fetch("currencies")), classes: d.fetch("classes").map { |x| CharacterClass.from_dynamic!(x) }, feats: d.fetch("feats").map { |x| CharacterFeat.from_dynamic!(x) }, features: d.fetch("features"), custom_defense_adjustments: d.fetch("customDefenseAdjustments"), custom_senses: d.fetch("customSenses"), custom_speeds: d.fetch("customSpeeds"), custom_proficiencies: d.fetch("customProficiencies"), custom_actions: d.fetch("customActions"), character_values: d.fetch("characterValues").map { |x| CharacterValue.from_dynamic!(x) }, conditions: d.fetch("conditions"), death_saves: DeathSaves.from_dynamic!(d.fetch("deathSaves")), adjustment_xp: d.fetch("adjustmentXp"), spell_slots: d.fetch("spellSlots").map { |x| PactMagic.from_dynamic!(x) }, pact_magic: d.fetch("pactMagic").map { |x| PactMagic.from_dynamic!(x) }, active_source_categories: d.fetch("activeSourceCategories"), spells: Spells.from_dynamic!(d.fetch("spells")), character_options: Options.from_dynamic!(d.fetch("options")), choices: Choices.from_dynamic!(d.fetch("choices")), actions: Actions.from_dynamic!(d.fetch("actions")), modifiers: Modifiers.from_dynamic!(d.fetch("modifiers")), class_spells: d.fetch("classSpells").map { |x| ClassSpell.from_dynamic!(x) }, custom_items: d.fetch("customItems").map { |x| CustomItem.from_dynamic!(x) }, campaign: d.fetch("campaign") ? Campaign.from_dynamic!(d.fetch("campaign")) : nil, creatures: d.fetch("creatures").map { |x| Creature.from_dynamic!(x) }, optional_origins: d.fetch("optionalOrigins"), optional_class_features: d.fetch("optionalClassFeatures"), date_modified: d.fetch("dateModified"), provided_from: d.fetch("providedFrom"), can_edit: d.fetch("canEdit"), status: d.fetch("status"), status_slug: d.fetch("statusSlug"), campaign_setting: d.fetch("campaignSetting"), ) end |
.from_json!(json) ⇒ Object
4603 4604 4605 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4603 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4607 def to_dynamic { "id" => id, "userId" => user_id, "username" => username, "isAssignedToPlayer" => is_assigned_to_player, "readonlyUrl" => readonly_url, "decorations" => decorations.to_dynamic, "name" => character_name, "socialName" => , "gender" => gender, "faith" => faith, "age" => age, "hair" => hair, "eyes" => eyes, "skin" => skin, "height" => height, "weight" => weight, "inspiration" => inspiration, "baseHitPoints" => base_hit_points, "bonusHitPoints" => bonus_hit_points, "overrideHitPoints" => override_hit_points, "removedHitPoints" => removed_hit_points, "temporaryHitPoints" => temporary_hit_points, "currentXp" => current_xp, "alignmentId" => alignment_id, "lifestyleId" => lifestyle_id, "stats" => stats.map { |x| x.to_dynamic }, "bonusStats" => bonus_stats.map { |x| x.to_dynamic }, "overrideStats" => override_stats.map { |x| x.to_dynamic }, "background" => background.to_dynamic, "race" => race&.to_dynamic, "raceDefinitionId" => race_definition_id, "raceDefinitionTypeId" => race_definition_type_id, "notes" => notes.to_dynamic, "traits" => traits.to_dynamic, "preferences" => preferences.to_dynamic, "configuration" => configuration.to_dynamic, "lifestyle" => lifestyle, "inventory" => inventory.map { |x| x.to_dynamic }, "currencies" => currencies.to_dynamic, "classes" => classes.map { |x| x.to_dynamic }, "feats" => feats.map { |x| x.to_dynamic }, "features" => features, "customDefenseAdjustments" => custom_defense_adjustments, "customSenses" => custom_senses, "customSpeeds" => custom_speeds, "customProficiencies" => custom_proficiencies, "customActions" => custom_actions, "characterValues" => character_values.map { |x| x.to_dynamic }, "conditions" => conditions, "deathSaves" => death_saves.to_dynamic, "adjustmentXp" => adjustment_xp, "spellSlots" => spell_slots.map { |x| x.to_dynamic }, "pactMagic" => pact_magic.map { |x| x.to_dynamic }, "activeSourceCategories" => active_source_categories, "spells" => spells.to_dynamic, "options" => .to_dynamic, "choices" => choices.to_dynamic, "actions" => actions.to_dynamic, "modifiers" => modifiers.to_dynamic, "classSpells" => class_spells.map { |x| x.to_dynamic }, "customItems" => custom_items.map { |x| x.to_dynamic }, "campaign" => campaign&.to_dynamic, "creatures" => creatures.map { |x| x.to_dynamic }, "optionalOrigins" => optional_origins, "optionalClassFeatures" => optional_class_features, "dateModified" => date_modified, "providedFrom" => provided_from, "canEdit" => can_edit, "status" => status, "statusSlug" => status_slug, "campaignSetting" => campaign_setting, } end |
#to_json(options = nil) ⇒ Object
4683 4684 4685 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 4683 def to_json( = nil) JSON.generate(to_dynamic, ) end |