Class: Lich::DragonRealms::DRCH::Wound
- Inherits:
-
Object
- Object
- Lich::DragonRealms::DRCH::Wound
- Defined in:
- documented/dragonrealms/commons/common-healing.rb
Overview
Represents a wound on a character's body.
Instance Attribute Summary collapse
-
#bleeding_rate ⇒ Object
readonly
Returns the value of attribute bleeding_rate.
-
#body_part ⇒ Object
readonly
Returns the value of attribute body_part.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
- #bleeding? ⇒ Boolean
-
#initialize(body_part: nil, severity: nil, bleeding_rate: nil, is_internal: false, is_scar: false, is_parasite: false, is_lodged_item: false) ⇒ Wound
constructor
A new instance of Wound.
- #internal? ⇒ Boolean
- #location ⇒ Object
- #lodged? ⇒ Boolean
- #parasite? ⇒ Boolean
- #scar? ⇒ Boolean
- #tendable? ⇒ Boolean
- #to_h ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(body_part: nil, severity: nil, bleeding_rate: nil, is_internal: false, is_scar: false, is_parasite: false, is_lodged_item: false) ⇒ Wound
Returns a new instance of Wound.
486 487 488 489 490 491 492 493 494 495 496 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 486 def initialize(body_part: nil, severity: nil, bleeding_rate: nil, is_internal: false, is_scar: false, is_parasite: false, is_lodged_item: false) @body_part = body_part&.downcase @severity = severity @bleeding_rate = bleeding_rate&.downcase @internal = !!is_internal @scar = !!is_scar @parasite = !!is_parasite @lodged_item = !!is_lodged_item end |
Instance Attribute Details
#bleeding_rate ⇒ Object (readonly)
Returns the value of attribute bleeding_rate.
484 485 486 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 484 def bleeding_rate @bleeding_rate end |
#body_part ⇒ Object (readonly)
Returns the value of attribute body_part.
484 485 486 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 484 def body_part @body_part end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
484 485 486 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 484 def severity @severity end |
Instance Method Details
#bleeding? ⇒ Boolean
498 499 500 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 498 def bleeding? !@bleeding_rate.nil? && !@bleeding_rate.empty? && @bleeding_rate != '(tended)' end |
#internal? ⇒ Boolean
502 503 504 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 502 def internal? @internal end |
#location ⇒ Object
528 529 530 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 528 def location internal? ? 'internal' : 'external' end |
#lodged? ⇒ Boolean
514 515 516 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 514 def lodged? @lodged_item end |
#parasite? ⇒ Boolean
510 511 512 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 510 def parasite? @parasite end |
#scar? ⇒ Boolean
506 507 508 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 506 def scar? @scar end |
#tendable? ⇒ Boolean
518 519 520 521 522 523 524 525 526 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 518 def tendable? return true if parasite? return true if lodged? return false if @body_part =~ /skin/ return false unless bleeding? return false if @bleeding_rate =~ /tended|clotted/ DRCH.skilled_to_tend_wound?(@bleeding_rate, internal?) end |
#to_h ⇒ Object
536 537 538 539 540 541 542 543 544 545 546 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 536 def to_h { body_part: @body_part, severity: @severity, bleeding_rate: @bleeding_rate, internal: @internal, scar: @scar, parasite: @parasite, lodged_item: @lodged_item } end |
#to_s ⇒ Object
548 549 550 551 552 553 554 555 556 557 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 548 def to_s parts = [@body_part || 'unknown'] parts << "severity:#{@severity}" if @severity parts << "bleeding:#{@bleeding_rate}" if @bleeding_rate parts << location parts << type parts << 'parasite' if parasite? parts << 'lodged' if lodged? "Wound(#{parts.join(', ')})" end |
#type ⇒ Object
532 533 534 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 532 def type scar? ? 'scar' : 'wound' end |