Visitor for Sprite Enchantment
Execute external operations upon an array of heterogeneous enchanted sprites without altering their essence.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Visitor
ARCANUM SCHOOL: Necromancy // Sprite Enchantment
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
function CurseVisitor() constructor {
static visit_fire_sprite = function(_fire_sprite) { _fire_sprite.extinguish(); };
static visit_ice_sprite = function(_ice_sprite) { _ice_sprite.shatter(); };
}
function FireSprite() constructor {
static accept = function(_visitor) { _visitor.visit_fire_sprite(self); };
static extinguish = function() { /* lose magic */ };
}
function IceSprite() constructor {
static accept = function(_visitor) { _visitor.visit_ice_sprite(self); };
static shatter = function() { /* explode */ };
}
The Visitor is a specter moving through an army. Instead of cluttering the clean classes of Fire and Ice Sprites with a ‘curse’ method, a CurseVisitor object sweeps through them. They merely accept the visitor, allowing the external entity to harvest their essence contextually.
Runic Tags:
#gml
#behavioral
#visitor