Class: DdbRuby::FifthEdition::WeaponBehavior
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DdbRuby::FifthEdition::WeaponBehavior
- Defined in:
- lib/ddb_ruby/fifth_edition/structs.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3349 def self.from_dynamic!(d) d = Types::Hash[d] new( base_item_id: d.fetch("baseItemId"), base_type_id: d.fetch("baseTypeId"), weapon_behavior_type: d.fetch("type"), attack_type: d.fetch("attackType"), category_id: d.fetch("categoryId"), properties: d.fetch("properties").map { |x| Organization.from_dynamic!(x) }, damage: HitPointDice.from_dynamic!(d.fetch("damage")), damage_type: d.fetch("damageType"), range: d.fetch("range"), long_range: d.fetch("longRange"), is_monk_weapon: d.fetch("isMonkWeapon"), ) end |
.from_json!(json) ⇒ Object
3366 3367 3368 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3366 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3370 def to_dynamic { "baseItemId" => base_item_id, "baseTypeId" => base_type_id, "type" => weapon_behavior_type, "attackType" => attack_type, "categoryId" => category_id, "properties" => properties.map { |x| x.to_dynamic }, "damage" => damage.to_dynamic, "damageType" => damage_type, "range" => range, "longRange" => long_range, "isMonkWeapon" => is_monk_weapon, } end |
#to_json(options = nil) ⇒ Object
3386 3387 3388 |
# File 'lib/ddb_ruby/fifth_edition/structs.rb', line 3386 def to_json( = nil) JSON.generate(to_dynamic, ) end |