Class: Lich::DragonRealms::DRCTH::CommuneSenseResult

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

Overview

Data class for commune_sense results. Replaces raw hash return. Supports [] for backward compat with callers using result.

captured is false when the COMMUNE SENSE reply was not captured in full: no reply arrived (a timeout), or the reply was cut off before its Roundtime line. commune_ready is then false so the result never reads as ready; treat it as "unknown". After a timeout the lists are empty; after a cut-off reply they hold what arrived, which may not be everything. captured true means a complete reply was read; it does not prove the reply was sent in answer to this call (the tail of a reply that arrives after an earlier call timed out can still be read by the next call, since COMMUNE_SENSE_START also matches lines from the middle of a reply).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(active_communes: [], recent_communes: [], commune_ready: true, captured: true) ⇒ CommuneSenseResult

Initializes a CommuneSenseResult with commune status data.

Parameters:

  • active_communes (Array<String>) (defaults to: []) —

    god names from currently active communes (e.g., ["Tamsine", "Kertigen"])

  • recent_communes (Array<String>) (defaults to: []) —

    god names from recently completed communes

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

    true if the character may open another divine conduit now

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

    true if the full COMMUNE SENSE reply was captured; false if timeout or cut off



76
77
78
79
80
81
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 76

def initialize(active_communes: [], recent_communes: [], commune_ready: true, captured: true)
  @active_communes = active_communes.freeze
  @recent_communes = recent_communes.freeze
  @commune_ready = commune_ready
  @captured = captured
end

Instance Attribute Details

#active_communes ⇒ Object (readonly)

Returns the value of attribute active_communes.



68
69
70
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 68

def active_communes
  @active_communes
end

#captured ⇒ Object (readonly)

Returns the value of attribute captured.



68
69
70
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 68

def captured
  @captured
end

#commune_ready ⇒ Object (readonly)

Returns the value of attribute commune_ready.



68
69
70
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 68

def commune_ready
  @commune_ready
end

#recent_communes ⇒ Object (readonly)

Returns the value of attribute recent_communes.



68
69
70
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 68

def recent_communes
  @recent_communes
end

Instance Method Details

#[](key) ⇒ Array<String>, Boolean

Hash-style accessor for backward compatibility with older calling code.

Allows code that expects a Hash to call result or result.

Examples:

result = commune_sense
result["active_communes"] #=> ["Tamsine"]

Parameters:

  • key (String, Symbol) —

    the attribute name (e.g., "active_communes", :commune_ready)

Returns:

  • (Array<String>, Boolean) —

    the value of the requested attribute



104
105
106
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 104

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

#captured? ⇒ Boolean

Returns true when the COMMUNE SENSE reply was captured.

Returns:

  • (Boolean) —

    true when the COMMUNE SENSE reply was captured



91
92
93
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 91

def captured?
  @captured
end

#commune_ready? ⇒ Boolean

Returns true if the character is ready to open another divine conduit.

Returns:

  • (Boolean) —

    false when COMMUNE SENSE output indicates a cooldown is active; true otherwise



86
87
88
# File 'documented/dragonrealms/commons/common-theurgy.rb', line 86

def commune_ready?
  @commune_ready
end