Module: Lich::DragonRealms::Creature

Extended by:
Common::CreatureFacade
Defined in:
documented/dragonrealms/creature.rb

Overview

Public Creature API for DragonRealms runtime creature tracking.

The registry/roster/query surface shared with Lich::Gemstone::Creature comes from Common::CreatureFacade, delegating to CreatureInstance (which carries the shared Common::CreatureBase class methods). DragonRealms adds the two feed entry points the XML parser uses: Creature.sync (id-first ) and Creature.feed_assess.

Class Method Summary collapse

Methods included from Common::CreatureFacade

[], all, cleanup_old, clear, clear_room, configure, debug_on, in_room, register, stats, targets

Class Method Details

.feed_assess(entry) ⇒ CreatureInstance?

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:



395
396
397
398
399
400
401
402
403
404
# File 'documented/dragonrealms/creature.rb', line 395

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

.sync(id, flags) ⇒ CreatureInstance?

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 room-objs name is applied separately via Lich::DragonRealms::CreatureInstance#apply_room_name, either from the linked creature (Saga-identity dialect, registered before this batch arrives) or, in the legacy dialect, 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:



382
383
384
385
386
387
388
# File 'documented/dragonrealms/creature.rb', line 382

def self.sync(id, flags)
  instance = CreatureInstance.register(nil, id)
  return nil unless instance

  instance.sync_crtr_status(flags)
  instance
end