The State Incantation
Allowing a summoned entity to alter its behavior when its internal elemental alignment changes.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: State
ARCANUM SCHOOL: Transmutation // Metamorphosis
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// MATHEMATICA PATTERN //
(* The States *)
SolidState[entity_] := Print[entity, " is solid. It blocks attacks."];
LiquidState[entity_] := Print[entity, " is liquid. Attacks pass through it."];
GaseousState[entity_] := Print[entity, " is gaseous. It floats away."];
(* The Context *)
ClearAll[CreateElemental];
CreateElemental[name_] := Module[{currentState = SolidState},
<|
"Name" -> name,
"React" :> currentState[name],
"SetState" -> Function[newState,
currentState = newState;
Print[name, " shifted its form."]
]
|>
];
(* Usage *)
golem = CreateElemental["Morphor"];
golem["React"];
golem["SetState"][LiquidState];
golem["React"];
golem["SetState"][GaseousState];
golem["React"];
Runic Tags:
#state
#behavioral
#metamorphosis
#dynamic-typing