✨ ARCANUM RUNE DIFFICULTY: Adept Behavioral

Chain of Responsibility for Sprite Enchantment

Pass a magical request along a chain of potential enchanting wards.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Chain of Responsibility
ARCANUM SCHOOL: Abjuration // Sprite Enchantment
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
function EnchantmentHandler() constructor {
    next_handler = undefined;
    
    static set_next = function(_handler) {
        next_handler = _handler;
        return _handler;
    };
    
    static handle_spell = function(_spell_type, _sprite) {
        if (next_handler != undefined) {
            next_handler.handle_spell(_spell_type, _sprite);
        }
    };
}

function FireWard() : EnchantmentHandler() constructor {
    static handle_spell = function(_spell_type, _sprite) {
        if (_spell_type == "fire") {
            _sprite.color = c_red;
        } else if (next_handler != undefined) {
            next_handler.handle_spell(_spell_type, _sprite);
        }
    };
}

Through the Chain of Responsibility, an incoming enchantment cascades through a sequence of wards. If a ward resonates with the incoming energy (like a FireWard detecting fire), it alters the sprite; otherwise, it defers to the next mystical node in the chain.

Runic Tags: #gml #behavioral #chain-of-responsibility