Class: Lich::DragonRealms::DRCH::HealthResult
- Inherits:
-
Object
- Object
- Lich::DragonRealms::DRCH::HealthResult
- 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
-
#bleeders ⇒ Object
readonly
Returns the value of attribute bleeders.
-
#captured ⇒ Object
readonly
Returns the value of attribute captured.
-
#dead ⇒ Object
readonly
Returns the value of attribute dead.
-
#diseased ⇒ Object
readonly
Returns the value of attribute diseased.
-
#lodged ⇒ Object
readonly
Returns the value of attribute lodged.
-
#parasites ⇒ Object
readonly
Returns the value of attribute parasites.
-
#poisoned ⇒ Object
readonly
Returns the value of attribute poisoned.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#vitality ⇒ Object
readonly
Returns the value of attribute vitality.
-
#wounds ⇒ Object
readonly
Returns the value of attribute wounds.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Backward compatibility for dr-scripts callers using health_data etc.
- #bleeding? ⇒ Boolean
-
#captured? ⇒ Boolean
True when the game reply was captured in full.
-
#has_tendable_bleeders? ⇒ Boolean
Checks whether the character has any bleeders that can be tended by the healer.
-
#initialize(wounds: {}, bleeders: {}, parasites: {}, lodged: {}, poisoned: false, diseased: false, score: 0, dead: false, vitality: 100, captured: true) ⇒ HealthResult
constructor
Initializes a HealthResult with wound, bleeding, parasite, and disease data.
-
#injured? ⇒ Boolean
Checks whether the character has any wounds.
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.
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
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.
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.
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.
506 507 508 |
# File 'documented/dragonrealms/commons/common-healing.rb', line 506 def injured? score > 0 end |