🕊️ SWIFT ENCHANTMENTS DIFFICULTY: Adept Behavioral

The Mediator Pattern

Centralizing complex communication between magical entities.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Mediator
ARCANUM SCHOOL: Enchantment // Orchestration
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// SWIFT PATTERN //
protocol Mediator {
    func notify(sender: Colleague, event: String)
}
class Colleague {
    var mediator: Mediator?
}
class Familiar: Colleague {
    func spotEnemy() { mediator?.notify(sender: self, event: "EnemySpotted") }
}
class Sorcerer: Mediator {
    func notify(sender: Colleague, event: String) {
        if event == "EnemySpotted" { print("Preparing defense spells") }
    }
}

The Mediator: The Sorcerer’s Command

The Mediator centralizes communication. The Sorcerer listens to their Familiar, preventing a chaotic web of direct entity-to-entity bindings.

Runic Tags: #swift #design-pattern #behavioral