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

Parameters:

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

    the affected body part (e.g., "right arm")

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

    wound severity (1-9 or higher)

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

    bleeding rate description (e.g., "heavily", "tended")

  • is_internal (Boolean) (defaults to: false)

    whether the wound is internal

  • is_scar (Boolean) (defaults to: false)

    whether this is a scar rather than a fresh wound

  • is_parasite (Boolean) (defaults to: false)

    whether this is a parasite infestation

  • is_lodged_item (Boolean) (defaults to: false)

    whether this is a lodged item



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_rateObject (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_partObject (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

#severityObject (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)".

Returns:

  • (Boolean)

    true if the wound is actively bleeding



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.

Returns:

  • (Boolean)

    true if the wound is internal rather than external



548
549
550
# File 'documented/dragonrealms/commons/common-healing.rb', line 548

def internal?
  @internal
end

#locationString

Returns the wound location as "internal" or "external".

Returns:

  • (String)

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

Returns:

  • (Boolean)

    true if this is 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.

Returns:

  • (Boolean)

    true if this is a parasite



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.

Returns:

  • (Boolean)

    true if this is a scar rather than a fresh wound



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.

Returns:

  • (Boolean)

    true if the wound is safe to tend



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_hHash

Converts the wound to a hash representation.

Returns:

  • (Hash)

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



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_sString

Returns a human-readable string representation of the wound.

Returns:

  • (String)

    formatted string like "Wound(right arm, severity:5, bleeding:heavily, external, 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

#typeString

Returns the wound type as "scar" or "wound".

Returns:

  • (String)

    "scar" or "wound"



600
601
602
# File 'documented/dragonrealms/commons/common-healing.rb', line 600

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