✨ ARCANUM RUNE DIFFICULTY: Adept Behavioral

The Mediator

Centralizing complex communication between disparate arcane subroutines.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Mediator
ARCANUM SCHOOL: Enchantment // Synchronization
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
interface NexusMediator {
  notify(sender: object, event: string): void;
}

class ManaPool {
  constructor(private mediator: NexusMediator) {}
  drain() { this.mediator.notify(this, 'Drained'); }
}

class ShieldGenerator {
  constructor(private mediator: NexusMediator) {}
  collapse() { this.mediator.notify(this, 'Collapsed'); }
}

class BattleNexus implements NexusMediator {
  public manaPool!: ManaPool;
  public shield!: ShieldGenerator;
  
  notify(sender: object, event: string) {
    if (event === 'Drained' && sender === this.manaPool) {
      console.log("Mana depleted. Shield collapsing automatically.");
      this.shield.collapse();
    }
  }
}

The Mediator pattern defines an object that encapsulates how a set of objects interact. It promotes loose coupling by keeping the Mana Pool and Shield Generator from referring to each other directly; instead, they route all state changes through the Battle Nexus for centralized logic processing.

Runic Tags: #behavioral #typescript #mediator