Class: Lich::DragonRealms::DRCH::Wound
- Inherits:
-
Object
- Object
- Lich::DragonRealms::DRCH::Wound
- Defined in:
- documented/dragonrealms/commons/common-healing.rb
Overview
Represents a single wound, bleeder, parasite, or lodged item.
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
Checks whether this wound is actively bleeding.
-
#initialize(body_part: nil, severity: nil, bleeding_rate: nil, is_internal: false, is_scar: false, is_parasite: false, is_lodged_item: false) ⇒ Wound
constructor
Initializes a Wound representing a wound, bleeder, parasite, or lodged item.
-
#internal? ⇒ Boolean
Checks whether this wound is internal.
-
#location ⇒ String
Returns the wound location category.
-
#lodged? ⇒ Boolean
Checks whether this wound represents a lodged item.
-
#parasite? ⇒ Boolean
Checks whether this wound represents a parasite.
-
#scar? ⇒ Boolean
Checks whether this wound is a scar.
-
#tendable? ⇒ Boolean
Checks whether the healer has sufficient First Aid skill to safely tend this wound.
-
#to_h ⇒ Hash
Converts the wound to a hash representation.
-
#to_s ⇒ String
Returns a human-readable string representation of the wound.
-
#type ⇒ String
Returns the wound type.
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
Initializes a Wound representing a wound, bleeder, parasite, or lodged item.
537 538 539 540 541 542 543 544 545 546 547 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 537 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.
526 527 528 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 526 def bleeding_rate @bleeding_rate end |
#body_part ⇒ Object (readonly)
Returns the value of attribute body_part.
526 527 528 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 526 def body_part @body_part end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
526 527 528 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 526 def severity @severity end |
Instance Method Details
#bleeding? ⇒ Boolean
Checks whether this wound is actively bleeding.
A wound bleeds if it has a bleeding_rate and the rate is not "(tended)".
554 555 556 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 554 def bleeding? !@bleeding_rate.nil? && !@bleeding_rate.empty? && @bleeding_rate != '(tended)' end |
#internal? ⇒ Boolean
Checks whether this wound is internal.
561 562 563 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 561 def internal? @internal end |
#location ⇒ String
Returns the wound location category.
606 607 608 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 606 def location internal? ? 'internal' : 'external' end |
#lodged? ⇒ Boolean
Checks whether this wound represents a lodged item.
582 583 584 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 582 def lodged? @lodged_item end |
#parasite? ⇒ Boolean
Checks whether this wound represents a parasite.
575 576 577 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 575 def parasite? @parasite end |
#scar? ⇒ Boolean
Checks whether this wound is a scar.
568 569 570 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 568 def scar? @scar end |
#tendable? ⇒ Boolean
Checks whether the healer has sufficient First Aid skill to safely tend this wound.
Parasites and lodged items are always tendable. Skin bleeds are never tendable. Other bleeds are tendable only if the bleeding rate is active (not tended/clotted) and the healer's First Aid rank meets the minimum for that rate and location.
593 594 595 596 597 598 599 600 601 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 593 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 ⇒ Hash
Converts the wound to a hash representation.
620 621 622 623 624 625 626 627 628 629 630 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 620 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 ⇒ String
Returns a human-readable string representation of the wound.
635 636 637 638 639 640 641 642 643 644 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 635 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 ⇒ String
Returns the wound type.
613 614 615 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 613 def type scar? ? 'scar' : 'wound' end |