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

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

Overview

Represents a wound on a character’s body. This class encapsulates details about the wound such as body part, severity, and bleeding rate.

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

The part of the body that’s wounded, like ‘left hand’ or ‘abdomen’. At this time, at what rate is the wound bleeding, like ‘light’ or ‘moderate(tended)’. Initializes a new Wound object.

Examples:

wound = Wound.new(body_part: "left arm", severity: 2)

Parameters:

  • body_part (String) (defaults to: nil)

    The part of the body that’s wounded

  • severity (Integer) (defaults to: nil)

    The severity of the wound

  • bleeding_rate (String) (defaults to: nil)

    The rate at which the wound is bleeding

  • is_internal (Boolean) (defaults to: false)

    Whether the wound is internal

  • is_scar (Boolean) (defaults to: false)

    Whether the wound is a scar

  • is_parasite (Boolean) (defaults to: false)

    Whether the wound is caused by a parasite

  • is_lodged_item (Boolean) (defaults to: false)

    Whether the wound is caused by a lodged item



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
# File 'documented/dragonrealms/commons/common-healing.rb', line 476

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.nil? ? nil : body_part.downcase
  @severity = severity
  @bleeding_rate = bleeding_rate.nil? ? nil : bleeding_rate.downcase
  @is_internal = !!is_internal
  @is_scar = !!is_scar
  @is_parasite = !!is_parasite
  @is_lodged_item = !!is_lodged_item
end

Instance Attribute Details

#bleeding_rateObject

Returns the value of attribute bleeding_rate.



461
462
463
# File 'documented/dragonrealms/commons/common-healing.rb', line 461

def bleeding_rate
  @bleeding_rate
end

#body_partObject

Returns the value of attribute body_part.



461
462
463
# File 'documented/dragonrealms/commons/common-healing.rb', line 461

def body_part
  @body_part
end

#severityObject

Returns the value of attribute severity.



461
462
463
# File 'documented/dragonrealms/commons/common-healing.rb', line 461

def severity
  @severity
end

Instance Method Details

#bleeding?Boolean

Checks if the wound is currently bleeding.

Returns:

  • (Boolean)

    true if the wound is bleeding, false otherwise



497
498
499
# File 'documented/dragonrealms/commons/common-healing.rb', line 497

def bleeding?
  return !@bleeding_rate.nil? && !@bleeding_rate.empty? && @bleeding_rate != '(tended)'
end

#internal?Boolean

Checks if the wound is internal.

Returns:

  • (Boolean)

    true if the wound is internal, false otherwise



503
504
505
# File 'documented/dragonrealms/commons/common-healing.rb', line 503

def internal?
  return @is_internal
end

#locationString

Returns the location type of the wound.

Returns:

  • (String)

    ‘internal’ if the wound is internal, ‘external’ otherwise



539
540
541
# File 'documented/dragonrealms/commons/common-healing.rb', line 539

def location
  internal? ? 'internal' : 'external'
end

#lodged?Boolean

Checks if the wound is caused by a lodged item.

Returns:

  • (Boolean)

    true if the wound is caused by a lodged item, false otherwise



521
522
523
# File 'documented/dragonrealms/commons/common-healing.rb', line 521

def lodged?
  return @is_lodged_item
end

#parasite?Boolean

Checks if the wound is caused by a parasite.

Returns:

  • (Boolean)

    true if the wound is caused by a parasite, false otherwise



515
516
517
# File 'documented/dragonrealms/commons/common-healing.rb', line 515

def parasite?
  return @is_parasite
end

#scar?Boolean

Checks if the wound is a scar.

Returns:

  • (Boolean)

    true if the wound is a scar, false otherwise



509
510
511
# File 'documented/dragonrealms/commons/common-healing.rb', line 509

def scar?
  return @is_scar
end

#tendable?Boolean

Checks if the wound can be tended to.

Returns:

  • (Boolean)

    true if the wound is tendable, false otherwise



527
528
529
530
531
532
533
534
535
# File 'documented/dragonrealms/commons/common-healing.rb', line 527

def tendable?
  return true if parasite?
  return true if lodged?
  return false if @body_part =~ /skin/
  return false if !bleeding?
  return false if @bleeding_rate =~ /tended|clotted/

  return DRCH.skilled_to_tend_wound?(@bleeding_rate, internal?)
end

#typeString

Returns the type of the wound.

Returns:

  • (String)

    ‘scar’ if the wound is a scar, ‘wound’ otherwise



545
546
547
# File 'documented/dragonrealms/commons/common-healing.rb', line 545

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