λ SCHEME RUNE DIFFICULTY: Adept Structural

The Decorator

Layering magical enhancements seamlessly over existing artifacts.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Abjuration // Warding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// SCHEME PATTERN //
(define (base-shield damage)
  (max 0 (- damage 10)))

(define (with-fire-resistance shield-fn)
  (lambda (damage type)
    (if (eq? type 'fire)
        (shield-fn (quotient damage 2))
        (shield-fn damage))))

(define (with-reflect shield-fn)
  (lambda (damage type)
    (let ((net-damage (shield-fn damage type)))
      (display "Reflecting ") (display (- damage net-damage)) (newline)
      net-damage)))

(define mystic-shield (with-reflect (with-fire-resistance base-shield)))

Function composition serves as the perfect rune for stacking magical wards, each layer wrapping the core in a new protective shell.

Runic Tags: #structural #scheme #function-composition