❄️ COLDFUSION TAG DIFFICULTY: Apprentice Behavioral

The Strategy of the Battlemage

Define a family of arcane algorithms, encapsulate each one, and make them interchangeable.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Evocation // Tactics
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// COLDFUSION PATTERN //
interface name="IAttackStrategy" {
    public string executeAttack();
}

component name="FireballStrategy" implements="IAttackStrategy" {
    public string function executeAttack() { return "Casting massive fireball!"; }
}

component name="LightningStrategy" implements="IAttackStrategy" {
    public string function executeAttack() { return "Summoning chain lightning!"; }
}

component name="Battlemage" {
    variables.strategy = null;
    public void function setStrategy(IAttackStrategy s) { variables.strategy = s; }
    public void function attack() { writeOutput(variables.strategy.executeAttack()); }
}

A Battlemage cannot hardcode their response to an ambush. The Strategy pattern lets the alchemist load different tactical minds—Fireball or Lightning—into the mage’s consciousness at runtime, adapting seamlessly to the magical defenses of their foes.

Runic Tags: #strategy #coldfusion #battle-tactics #algorithms