The State Polymorph
Altering an entity's behavior when its internal form changes.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: State
ARCANUM SCHOOL: Transmutation // Polymorphism
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// EIFFEL PATTERN //
deferred class
SHAPESHIFTER_STATE
feature
attack
deferred
end
end
class
WEREWOLF_STATE
inherit
SHAPESHIFTER_STATE
feature
attack
do
-- claw strike
end
end
class
DRUID
feature
form: SHAPESHIFTER_STATE
strike
require
form_exists: form /= Void
do
form.attack
end
end
The State pattern dictates that an entity acts based on its current polymorphed form, seamlessly shifting tactics without messy conditionals.
Runic Tags:
#behavioral
#state
#eiffel