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

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.

Parameters:

  • id (Integer, String)

    server creature id.

Returns:



341
342
343
# File 'documented/dragonrealms/creature.rb', line 341

def self.[](id)
  CreatureInstance[id]
end

.allArray<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.

Returns:



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.

Parameters:

  • max_age_seconds (Integer) (defaults to: 600)

    age cutoff in seconds.

Returns:

  • (Integer)

    number of instances removed.



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

.clearvoid

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_roomvoid

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(**options)
  CreatureInstance.configure(**options)
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.

Parameters:

  • level (Boolean, Symbol) (defaults to: :changes)

    false disables debug output; true or :changes reports changes only; :all reports every <crtrStatus> flag; :active reports only active <crtrStatus> flags.

Returns:

  • (Boolean, Symbol)

    the configured debug value.



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.

Parameters:

  • entry (Hash)

    a creature entry from XMLData.parse_assess_line.

Returns:



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.

Parameters:

  • filters (Array<String, Symbol>)

    optional ANDed status/classification filters.

Returns:



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.

Parameters:

  • name (String, nil)

    display name (may be nil for an id-first feed).

  • id (Integer, String)

    server creature id.

  • noun (String, nil) (defaults to: nil)

    noun, when available.

Returns:



374
375
376
# File 'documented/dragonrealms/creature.rb', line 374

def self.register(name, id, noun = nil)
  CreatureInstance.register(name, id, noun)
end

.statsHash

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.

Returns:

  • (Hash)

    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.

Parameters:

  • id (Integer, String)

    server creature id (the tag's exist).

  • flags (Hash{String=>String})

    tag attributes excluding exist.

Returns:



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.

Parameters:

  • filters (Array<String, Symbol>)

    optional ANDed status/classification filters.

Returns:



349
350
351
# File 'documented/dragonrealms/creature.rb', line 349

def self.targets(*filters)
  CreatureInstance.targets(*filters)
end