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.

captured is false when the game reply was not captured in full (a timeout). The other fields then hold defaults or partial data and do not mean "healthy": callers should treat the result as unknown and check again. captured true means a complete reply was read; it does not prove the reply was sent in answer to this call (a reply that arrives after an earlier call timed out can still be read by the next call).

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, captured: true) ⇒ HealthResult

Initializes a HealthResult with wound, bleeding, parasite, and disease data.

Parameters:

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

    wounds keyed by severity with arrays of Wound objects

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

    bleeding wounds keyed by severity with arrays of Wound objects

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

    parasites keyed by severity (typically 1) with arrays of Wound objects

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

    lodged items keyed by severity with arrays of Wound objects

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

    true if the character is poisoned (default: false)

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

    true if the character has an infection or disease (default: false)

  • score (Integer) (defaults to: 0) —

    weighted health score, higher = worse (default: 0)

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

    true if the character is dead (default: false)

  • vitality (Integer) (defaults to: 100) —

    perceived vitality percentage, 0-100 (default: 100)

  • captured (Boolean) (defaults to: true) —

    true if the game reply was captured in full (default: true)



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

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

Instance Attribute Details

#bleeders ⇒ Object (readonly)

Returns the value of attribute bleeders.



463
464
465
# File 'documented/dragonrealms/commons/common-healing.rb', line 463

def bleeders
  @bleeders
end

#captured ⇒ Object (readonly)

Returns the value of attribute captured.



463
464
465
# File 'documented/dragonrealms/commons/common-healing.rb', line 463

def captured
  @captured
end

#dead ⇒ Object (readonly)

Returns the value of attribute dead.



463
464
465
# File 'documented/dragonrealms/commons/common-healing.rb', line 463

def dead
  @dead
end

#diseased ⇒ Object (readonly)

Returns the value of attribute diseased.



463
464
465
# File 'documented/dragonrealms/commons/common-healing.rb', line 463

def diseased
  @diseased
end

#lodged ⇒ Object (readonly)

Returns the value of attribute lodged.



463
464
465
# File 'documented/dragonrealms/commons/common-healing.rb', line 463

def lodged
  @lodged
end

#parasites ⇒ Object (readonly)

Returns the value of attribute parasites.



463
464
465
# File 'documented/dragonrealms/commons/common-healing.rb', line 463

def parasites
  @parasites
end

#poisoned ⇒ Object (readonly)

Returns the value of attribute poisoned.



463
464
465
# File 'documented/dragonrealms/commons/common-healing.rb', line 463

def poisoned
  @poisoned
end

#score ⇒ Object (readonly)

Returns the value of attribute score.



463
464
465
# File 'documented/dragonrealms/commons/common-healing.rb', line 463

def score
  @score
end

#vitality ⇒ Object (readonly)

Returns the value of attribute vitality.



463
464
465
# File 'documented/dragonrealms/commons/common-healing.rb', line 463

def vitality
  @vitality
end

#wounds ⇒ Object (readonly)

Returns the value of attribute wounds.



463
464
465
# File 'documented/dragonrealms/commons/common-healing.rb', line 463

def wounds
  @wounds
end

Instance Method Details

#[](key) ⇒ Object

Backward compatibility for dr-scripts callers using health_data etc.



499
500
501
# File 'documented/dragonrealms/commons/common-healing.rb', line 499

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

#bleeding? ⇒ Boolean

Returns:

  • (Boolean)


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

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

#captured? ⇒ Boolean

Returns true when the game reply was captured in full.

Returns:

  • (Boolean) —

    true when the game reply was captured in full



494
495
496
# File 'documented/dragonrealms/commons/common-healing.rb', line 494

def captured?
  @captured
end

#has_tendable_bleeders? ⇒ Boolean

Checks whether the character has any bleeders that can be tended by the healer.

Considers skill, location, and bleeding rate to determine tendability.

Returns:

  • (Boolean) —

    true if any bleeder passes the tendable? check



519
520
521
# File 'documented/dragonrealms/commons/common-healing.rb', line 519

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

#injured? ⇒ Boolean

Checks whether the character has any wounds.

Returns:

  • (Boolean) —

    true if the score is greater than 0



506
507
508
# File 'documented/dragonrealms/commons/common-healing.rb', line 506

def injured?
  score > 0
end