🐎 PONY WARD DIFFICULTY: Adept Structural

The Composite Ward

Structuring nested magical topologies.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Composite
ARCANUM SCHOOL: Transmutation // Hierarchy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// PONY PATTERN //
trait val SpellComponent
  fun power(): U32

class val SpellMatrix is SpellComponent
  let _nodes: Array[SpellComponent val] val
  new create(n: Array[SpellComponent val] val) => _nodes = n
  fun power(): U32 =>
    var sum: U32 = 0
    for node in _nodes.values() do sum = sum + node.power() end
    sum

The Composite Ward

Immutable trees constructed from val arrays enable lock-free traversal of complex spell matrices.

Runic Tags: #pony #composite