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) ⇒ void
constructor
Initializes a Wound representing a single injury, bleeder, parasite, or lodged item.
-
#internal? ⇒ Boolean
Checks whether this wound is internal.
-
#location ⇒ String
Returns the wound location as "internal" or "external".
-
#lodged? ⇒ Boolean
Checks whether this wound represents a lodged item.
-
#parasite? ⇒ Boolean
Checks whether this wound represents a parasite infestation.
-
#scar? ⇒ Boolean
Checks whether this wound is a scar.
-
#tendable? ⇒ Boolean
Checks whether this wound can be safely tended.
-
#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 as "scar" or "wound".
Constructor Details
#initialize(body_part: nil, severity: nil, bleeding_rate: nil, is_internal: false, is_scar: false, is_parasite: false, is_lodged_item: false) ⇒ void
Initializes a Wound representing a single injury, bleeder, parasite, or lodged item.
All boolean flags default to false. Body part and bleeding rate are downcased.
523 524 525 526 527 528 529 530 531 532 533 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 523 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.
509 510 511 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 509 def bleeding_rate @bleeding_rate end |
#body_part ⇒ Object (readonly)
Returns the value of attribute body_part.
509 510 511 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 509 def body_part @body_part end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
509 510 511 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 509 def severity @severity end |
Instance Method Details
#bleeding? ⇒ Boolean
Checks whether this wound is actively bleeding.
A wound is bleeding if it has a non-empty bleeding rate that is not the sentinel value "(tended)".
541 542 543 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 541 def bleeding? !@bleeding_rate.nil? && !@bleeding_rate.empty? && @bleeding_rate != '(tended)' end |
#internal? ⇒ Boolean
Checks whether this wound is internal.
548 549 550 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 548 def internal? @internal end |
#location ⇒ String
Returns the wound location as "internal" or "external".
593 594 595 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 593 def location internal? ? 'internal' : 'external' end |
#lodged? ⇒ Boolean
Checks whether this wound represents a lodged item.
569 570 571 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 569 def lodged? @lodged_item end |
#parasite? ⇒ Boolean
Checks whether this wound represents a parasite infestation.
562 563 564 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 562 def parasite? @parasite end |
#scar? ⇒ Boolean
Checks whether this wound is a scar.
555 556 557 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 555 def scar? @scar end |
#tendable? ⇒ Boolean
Checks whether this wound can be safely tended.
Parasites and lodged items are always tendable. Wounds on the skin are never tendable. Bleeder wounds must be actively bleeding and not yet tended or clotted, and the character must have sufficient First Aid skill for the bleeding rate.
580 581 582 583 584 585 586 587 588 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 580 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.
607 608 609 610 611 612 613 614 615 616 617 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 607 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.
622 623 624 625 626 627 628 629 630 631 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 622 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 as "scar" or "wound".
600 601 602 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 600 def type scar? ? 'scar' : 'wound' end |