Class: Lich::DragonRealms::DRCH::HealthResult

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

Overview

Structured result from check_health or perceive_health. Supports backward-compatible string-key access via [] for dr-scripts callers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wounds: {}, bleeders: {}, parasites: {}, lodged: {}, poisoned: false, diseased: false, score: 0, dead: false, vitality: 100) ⇒ void

Initializes a HealthResult with health diagnostic data.

Parameters:

  • wounds (Hash) (defaults to: {})

    hash of severity => [Wound] for regular wounds

  • bleeders (Hash) (defaults to: {})

    hash of severity => [Wound] for active bleeders

  • parasites (Hash) (defaults to: {})

    hash of severity => [Wound] for parasites

  • lodged (Hash) (defaults to: {})

    hash of severity => [Wound] for lodged items

  • poisoned (Boolean) (defaults to: false)

    whether the character is poisoned

  • diseased (Boolean) (defaults to: false)

    whether the character is diseased

  • score (Integer) (defaults to: 0)

    weighted health score (0 for healthy)

  • dead (Boolean) (defaults to: false)

    whether the character is dead

  • vitality (Integer) (defaults to: 100)

    percentage vitality remaining (0-100)



466
467
468
469
470
471
472
473
474
475
476
477
478
# File 'documented/dragonrealms/commons/common-healing.rb', line 466

def initialize(wounds: {}, bleeders: {}, parasites: {}, lodged: {},
               poisoned: false, diseased: false, score: 0, dead: false,
               vitality: 100)
  @wounds = wounds
  @bleeders = bleeders
  @parasites = parasites
  @lodged = lodged
  @poisoned = poisoned
  @diseased = diseased
  @score = score
  @dead = dead
  @vitality = vitality
end

Instance Attribute Details

#bleedersObject (readonly)

Returns the value of attribute bleeders.



451
452
453
# File 'documented/dragonrealms/commons/common-healing.rb', line 451

def bleeders
  @bleeders
end

#deadObject (readonly)

Returns the value of attribute dead.



451
452
453
# File 'documented/dragonrealms/commons/common-healing.rb', line 451

def dead
  @dead
end

#diseasedObject (readonly)

Returns the value of attribute diseased.



451
452
453
# File 'documented/dragonrealms/commons/common-healing.rb', line 451

def diseased
  @diseased
end

#lodgedObject (readonly)

Returns the value of attribute lodged.



451
452
453
# File 'documented/dragonrealms/commons/common-healing.rb', line 451

def lodged
  @lodged
end

#parasitesObject (readonly)

Returns the value of attribute parasites.



451
452
453
# File 'documented/dragonrealms/commons/common-healing.rb', line 451

def parasites
  @parasites
end

#poisonedObject (readonly)

Returns the value of attribute poisoned.



451
452
453
# File 'documented/dragonrealms/commons/common-healing.rb', line 451

def poisoned
  @poisoned
end

#scoreObject (readonly)

Returns the value of attribute score.



451
452
453
# File 'documented/dragonrealms/commons/common-healing.rb', line 451

def score
  @score
end

#vitalityObject (readonly)

Returns the value of attribute vitality.



451
452
453
# File 'documented/dragonrealms/commons/common-healing.rb', line 451

def vitality
  @vitality
end

#woundsObject (readonly)

Returns the value of attribute wounds.



451
452
453
# File 'documented/dragonrealms/commons/common-healing.rb', line 451

def wounds
  @wounds
end

Instance Method Details

#[](key) ⇒ Object

Backward compatibility for dr-scripts callers using health_data etc.



481
482
483
# File 'documented/dragonrealms/commons/common-healing.rb', line 481

def [](key)
  send(key.to_sym)
end

#bleeding?Boolean

Returns:

  • (Boolean)


492
493
494
# File 'documented/dragonrealms/commons/common-healing.rb', line 492

def bleeding?
  bleeders.values.flatten.any?(&:bleeding?)
end

#has_tendable_bleeders?Boolean

Checks whether the character has bleeders that can be tended.

A bleeder is tendable if the character has sufficient First Aid skill or if it is a parasite or lodged item.

Returns:

  • (Boolean)

    true if at least one bleeder is tendable



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

def has_tendable_bleeders?
  bleeders.values.flatten.any?(&:tendable?)
end

#injured?Boolean

Checks whether the character has any injuries.

Returns:

  • (Boolean)

    true if the health score is greater than 0



488
489
490
# File 'documented/dragonrealms/commons/common-healing.rb', line 488

def injured?
  score > 0
end