The Prototype of the Hypertext Labyrinth
Clone existing archetypal state objects to populate the endless digital corridors.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Illusion // Duplication
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// TWINE PATTERN //
:: StoryInit
<<set $prototypes to {
basicDrone: { name: "Sector Drone", shield: 10, patrol: true },
eliteHunter: { name: "Hunter-Killer", shield: 50, track: true }
}>>
:: Encounter
<<set $currentEnemy to clone($prototypes.eliteHunter)>>
<<set $currentEnemy.name to "Defective Hunter-Killer">>
<<set $currentEnemy.shield to 20>>
You are facing a <<print $currentEnemy.name>> with <<print $currentEnemy.shield>> shield!
When the cost of crafting complex data objects from the void is too high, the Prototype pattern allows a Weaver to merely copy existing archetypes.
In Sugarcube, the holy clone() function is the lifeblood of this pattern. It deeply duplicates an archetype defined in your grimoire (StoryInit), allowing you to mutate the copy—lowering shields, corrupting names—without altering the pristine platonic ideal stored in the $prototypes registry.
Runic Tags:
#creational
#prototype
#cloning