Module: Lich::DragonRealms::Creature Private
- Defined in:
- documented/dragonrealms/creature.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Public Creature API for DragonRealms runtime creature tracking.
Mirrors Lich::Gemstone::Creature: registry/roster/query operations
delegate to CreatureInstance (which carries the shared
Common::CreatureBase class methods), plus the two DragonRealms feed
entry points Creature.sync and Creature.feed_assess used by the XML parser.
Class Method Summary collapse
-
.[](id) ⇒ CreatureInstance?
private
Lookup creature instance by id.
-
.all ⇒ Array<CreatureInstance>
private
Every registered instance.
-
.cleanup_old(max_age_seconds = 600) ⇒ Integer
private
Removes creatures older than the given age (in seconds).
-
.clear ⇒ void
private
Clears every instance and the room roster.
-
.clear_room ⇒ void
private
Empties the current room roster.
-
.configure(**options) ⇒ void
private
Configures the registry.
-
.debug_on(level = :changes) ⇒ Boolean, Symbol
private
Toggles live echo of status, flag, and registration changes.
-
.feed_assess(entry) ⇒ CreatureInstance?
private
Backfills a creature from a parsed
assessentry, registering it if the id has not been seen yet. -
.in_room(*filters) ⇒ Array<CreatureInstance>
private
Returns all tracked creatures currently in the room.
-
.register(name, id, noun = nil) ⇒ CreatureInstance?
private
Registers a creature.
-
.stats ⇒ Hash
private
Registry statistics.
-
.sync(id, flags) ⇒ CreatureInstance?
private
Applies a
<crtrStatus>snapshot, registering the creature id-first if it has not been seen yet. -
.targets(*filters) ⇒ Array<CreatureInstance>
private
Returns attackable hostile creatures currently in the room.
Class Method Details
.[](id) ⇒ CreatureInstance?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Lookup creature instance by id.
341 342 343 |
# File 'documented/dragonrealms/creature.rb', line 341 def self.[](id) CreatureInstance[id] end |
.all ⇒ Array<CreatureInstance>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns every registered instance.
414 415 416 |
# File 'documented/dragonrealms/creature.rb', line 414 def self.all CreatureInstance.all end |
.cleanup_old(max_age_seconds = 600) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes creatures older than the given age (in seconds).
Positional to match CreatureInstance#cleanup_old (supplied by Common::CreatureBase); a keyword-only signature would raise ArgumentError against the positional base method.
409 410 411 |
# File 'documented/dragonrealms/creature.rb', line 409 def self.cleanup_old(max_age_seconds = 600) CreatureInstance.cleanup_old(max_age_seconds) end |
.clear ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Clears every instance and the room roster.
397 398 399 |
# File 'documented/dragonrealms/creature.rb', line 397 def self.clear CreatureInstance.clear end |
.clear_room ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Empties the current room roster.
364 365 366 |
# File 'documented/dragonrealms/creature.rb', line 364 def self.clear_room CreatureInstance.clear_room end |
.configure(**options) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Configures the registry.
381 382 383 |
# File 'documented/dragonrealms/creature.rb', line 381 def self.configure(**) CreatureInstance.configure(**) end |
.debug_on(level = :changes) ⇒ Boolean, Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Toggles live echo of status, flag, and registration changes.
295 296 297 |
# File 'documented/dragonrealms/creature.rb', line 295 def self.debug_on(level = :changes) $creature_debug = level end |
.feed_assess(entry) ⇒ CreatureInstance?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Backfills a creature from a parsed assess entry, registering it if the
id has not been seen yet.
326 327 328 329 330 331 332 333 334 335 |
# File 'documented/dragonrealms/creature.rb', line 326 def self.feed_assess(entry) id = entry[:id] return nil unless id instance = CreatureInstance.register(entry[:name], id) return nil unless instance instance.feed_assess(entry) instance end |
.in_room(*filters) ⇒ Array<CreatureInstance>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns all tracked creatures currently in the room.
357 358 359 |
# File 'documented/dragonrealms/creature.rb', line 357 def self.in_room(*filters) CreatureInstance.in_room(*filters) end |
.register(name, id, noun = nil) ⇒ CreatureInstance?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Registers a creature.
374 375 376 |
# File 'documented/dragonrealms/creature.rb', line 374 def self.register(name, id, noun = nil) CreatureInstance.register(name, id, noun) end |
.stats ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns registry statistics.
386 387 388 389 390 391 392 |
# File 'documented/dragonrealms/creature.rb', line 386 def self.stats { instances: CreatureInstance.size, max_size: CreatureInstance.max_size, auto_register: CreatureInstance.auto_register? } end |
.sync(id, flags) ⇒ CreatureInstance?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Applies a <crtrStatus> snapshot, registering the creature id-first if
it has not been seen yet.
This is the automatic, name-less DragonRealms feed: it produces an
id-keyed hostile roster with flags before any assess has run.
Name-less on purpose: the stream-order room-objs name is applied separately via Lich::DragonRealms::CreatureInstance#apply_room_name, batched at the prompt once the parser has confirmed the bold-name and crtrStatus counts match (see lib/common/xmlparser.rb). assess later backfills authoritatively.
313 314 315 316 317 318 319 |
# File 'documented/dragonrealms/creature.rb', line 313 def self.sync(id, flags) instance = CreatureInstance.register(nil, id) return nil unless instance instance.sync_crtr_status(flags) instance end |
.targets(*filters) ⇒ Array<CreatureInstance>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns attackable hostile creatures currently in the room.
349 350 351 |
# File 'documented/dragonrealms/creature.rb', line 349 def self.targets(*filters) CreatureInstance.targets(*filters) end |