Class: Lich::DragonRealms::DRCH::Wound

Inherits:
Object
  • Object
show all
Defined in:
documented/dragonrealms/commons/common-healing.rb

Overview

Represents a single wound, bleeder, parasite, or lodged item.

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • body_part (String, nil) (defaults to: nil) —

    the wounded location, normalized to lowercase

  • severity (Integer, nil) (defaults to: nil) —

    wound severity level (higher = worse)

  • bleeding_rate (String, nil) (defaults to: nil) —

    rate of bleeding, e.g. "slowed", "heavy", "clotted", normalized to lowercase

  • is_internal (Boolean) (defaults to: false) —

    true if the wound is internal (default: false)

  • is_scar (Boolean) (defaults to: false) —

    true if this is a scar, not a fresh wound (default: false)

  • is_parasite (Boolean) (defaults to: false) —

    true if this wound represents a parasite (default: false)

  • is_lodged_item (Boolean) (defaults to: false) —

    true if this wound represents a lodged item (default: false)



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)".

Returns:

  • (Boolean) —

    true if bleeding rate is set, non-empty, and 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.

Returns:

  • (Boolean)


561
562
563
# File 'documented/dragonrealms/commons/common-healing.rb', line 561

def internal?
  @internal
end

#location ⇒ String

Returns the wound location category.

Returns:

  • (String) —

    "internal" or "external"



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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean) —

    true if the wound can be safely tended by the current character



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.

Returns:

  • (Hash) —

    hash with keys: body_part, severity, bleeding_rate, internal, scar, parasite, lodged_item



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.

Returns:

  • (String) —

    formatted string, e.g. "Wound(head, severity:3, bleeding:heavy, external, 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.

Returns:

  • (String) —

    "scar" if is_scar, otherwise "wound"



613
614
615
# File 'documented/dragonrealms/commons/common-healing.rb', line 613

def type
  scar? ? 'scar' : 'wound'
end