The Command of Encapsulated Runes
Encapsulate a matrix operation as an object, allowing for undoable spellcasts.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Command
ARCANUM SCHOOL: Divination // Execution
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// MATLAB PATTERN //
classdef (Abstract) SpellCommand < handle
methods (Abstract)
execute(obj)
undo(obj)
end
end
classdef InvertMatrixCommand < SpellCommand
properties
Target
PreviousState
end
methods
function obj = InvertMatrixCommand(target)
obj.Target = target;
end
function execute(obj)
obj.PreviousState = obj.Target.Data;
obj.Target.Data = inv(obj.Target.Data);
end
function undo(obj)
obj.Target.Data = obj.PreviousState;
end
end
end
Command
Capture the intent of a spell in a crystalline command, perfectly preserving the ability to reverse time.
Runic Tags:
#command
#execution
#undo