✨ ARCANUM RUNE DIFFICULTY: Adept Behavioral

The Chain of Responsibility

Passing a spell request along a chain of magical wards and handlers.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Chain of Responsibility
ARCANUM SCHOOL: Abjuration // Defense Grid
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
abstract class WardHandler {
  protected next: WardHandler | null = null;
  setNext(handler: WardHandler): WardHandler {
    this.next = handler;
    return handler;
  }
  abstract handle(attackPower: number): string | null;
}

class KineticWard extends WardHandler {
  handle(attackPower: number) {
    if (attackPower < 50) return "Kinetic Ward absorbed the blow.";
    return this.next ? this.next.handle(attackPower) : "Attack breached all wards!";
  }
}

class PlasmaShield extends WardHandler {
  handle(attackPower: number) {
    if (attackPower < 100) return "Plasma Shield dissipated the energy.";
    return this.next ? this.next.handle(attackPower) : "Attack breached all wards!";
  }
}

The Chain of Responsibility decouples the sender of a magical assault from its receivers. A cascade of wards processes an incoming attack one by one; if a ward cannot withstand the blow, it seamlessly passes the energy to the next layer in the defense grid.

Runic Tags: #behavioral #typescript #chain