🌙 LUA GLYPH DIFFICULTY: Adept Behavioral

The Strategy of the Spellbook

Choosing the method of attack dynamically at runtime from an arsenal of spells.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Evocation // Tactics
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// LUA PATTERN //
local Strategies = {
  Fire = function() return "Casting a blistering fireball!" end,
  Ice = function() return "Unleashing a cone of frost!" end
}

local Wizard = {
  strategy = Strategies.Fire,
  cast = function(self) return self.strategy() end
}

print(Wizard:cast())
Wizard.strategy = Strategies.Ice
print(Wizard:cast())

Strategy

A master wizard does not lock themselves into a single invocation. The Strategy pattern stores different functions (spells) in a table. By swapping the active closure, the host engine can completely change the script’s approach without modifying the wizard’s core logic.

Runic Tags: #fae #strategy #tactics