✨ ARCANUM RUNE DIFFICULTY: Archmage Structural

The Decorator Ward

Dynamically adds defensive wards to an existing spell using nested effect handlers.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Abjuration // Warding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
effect castable
  ctl cast-base() : string

fun empower-ward(action: () -> <castable|e> a) : <castable|e> a
  with handler
    ctl cast-base() resume("Empowered " ++ cast-base())
  action()

fun echo-ward(action: () -> <castable|e> a) : <castable|e> a
  with handler
    ctl cast-base() { val res = cast-base(); resume(res ++ " (echo: " ++ res ++ ")") }
  action()

pub fun main()
  with handler
    ctl cast-base() resume("Magic Missile")
  with echo-ward
  with empower-ward
  println(cast-base())
Runic Tags: #koka #decorator #effect-nesting