🦊 FOXPRO APPARITION DIFFICULTY: Adept Behavioral

The State of the Cursed Lycanthrope

Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: State
ARCANUM SCHOOL: Transmutation // Shapeshifting
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// FOXPRO PATTERN //
DEFINE CLASS Lycanthrope AS Custom
    oState = .NULL.

    PROCEDURE Init
        THIS.oState = CREATEOBJECT("HumanState")
    ENDPROC

    PROCEDURE SetState(oNewState)
        THIS.oState = oNewState
    ENDPROC

    PROCEDURE ReactToMoon()
        THIS.oState.Handle(THIS)
    ENDPROC
ENDDEFINE

DEFINE CLASS HumanState AS Custom
    PROCEDURE Handle(oContext)
        ? "The man looks up at the full moon and screams!"
        oContext.SetState(CREATEOBJECT("WolfState"))
    ENDPROC
ENDDEFINE

DEFINE CLASS WolfState AS Custom
    PROCEDURE Handle(oContext)
        ? "The beast howls and hunts for blood!"
        * Might revert back on new moon
    ENDPROC
ENDDEFINE

As the moon cycles, the Lycanthrope’s very essence alters. The State pattern prevents monstrous DO CASE blocks, letting the entity simply swap its internal soul-core to change its behavior dynamically at runtime.

Runic Tags: #behavioral #state #fsm #polymorphism