🟨 JAVASCRIPT PATTERN DIFFICULTY: Adept Creational

The Doppelganger Prototype

Create new entities by cloning an archetypical instance, bypassing costly rituals.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Illusion // Duplication
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// JAVASCRIPT IDIOMATIC PATTERN //
class Doppelganger {
  constructor(form, memory) {
    this.form = form;
    this.memory = memory;
  }
  clone() {
    // Deep copy if necessary, but shallow works for basic illusions
    return new Doppelganger(this.form, [...this.memory]);
  }
  manifest() {
    console.log(`Manifesting as ${this.form} with memories: ${this.memory}`);
  }
}

const original = new Doppelganger("Town Guard", ["Guard duty at gate", "Loves pastries"]);
const clone = original.clone();
clone.memory.push("Met a suspicious wizard");

original.manifest();
clone.manifest();

The Doppelganger Prototype

When summoning a completely new entity is too taxing on your mana reserves, take an existing template and duplicate it. The Prototype pattern is the core secret behind an army of illusions.

Runic Tags: #cloning #illusion #memory