🐍 PYTHON SCRIPT DIFFICULTY: Adept Structural

The Bridge

Decouple the spell's abstraction from its elemental implementation.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Bridge
ARCANUM SCHOOL: Evocation // Metamagic
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// EXECUTABLE PYTHON PATTERN //
from abc import ABC, abstractmethod

class Element(ABC):
    @abstractmethod
    def apply(self) -> str: pass

class Fire(Element):
    def apply(self) -> str: return "wreathed in flames"

class Void(Element):
    def apply(self) -> str: return "infused with abyssal energy"

class Spell(ABC):
    def __init__(self, element: Element):
        self.element = element

    @abstractmethod
    def cast(self) -> str: pass

class Strike(Spell):
    def cast(self) -> str:
        return f"A kinetic strike, {self.element.apply()}!"

class Ward(Spell):
    def cast(self) -> str:
        return f"A protective ward, {self.element.apply()}!"

# fire_strike = Strike(Fire())
# void_ward = Ward(Void())
# print(fire_strike.cast())

The Bridge pattern weaves the spell’s form (Strike or Ward) independently from its substance (Fire or Void). This dimensional decoupling prevents the catastrophic exponential explosion of creating separate classes for FireStrike, VoidStrike, FireWard, and VoidWard. Metamagic at its finest.

Runic Tags: #structural #python #evocation