The Sigil of Execution
Encapsulate an arcane request as a standalone object, ready for delayed casting.
β§ GANG OF FOUR LINEAGE & ARCANUM β§
GOF DESIGN PATTERN: Command
ARCANUM SCHOOL: Evocation // Runesmithing
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// DART PATTERN //
abstract class Command {
void execute();
void undo();
}
class FireballSpell {
void ignite() => print('Fireball bursts!');
void extinguish() => print('Flames drawn back into the void.');
}
class CastFireballCommand implements Command {
final FireballSpell _spell;
CastFireballCommand(this._spell);
@override
void execute() => _spell.ignite();
@override
void undo() => _spell.extinguish();
}
class Wand {
final List<Command> _history = [];
void invoke(Command command) {
command.execute();
_history.add(command);
}
void rewind() {
if (_history.isNotEmpty) {
_history.removeLast().undo();
}
}
}
void main() {
final wand = Wand();
final fireball = CastFireballCommand(FireballSpell());
wand.invoke(fireball);
wand.rewind(); // Time magic undo
}
A spell isnβt just an action; it can be etched into a Sigil. The Command pattern wraps an action into an object, allowing you to queue spells, pass them to asynchronous isolates, or invoke forbidden chronomancy to undo() them.
Runic Tags:
#dart
#command
#undo-redo
#evocation