✨ ARCANUM RUNE DIFFICULTY: Apprentice Behavioral

The Strategy Stance

Defines a family of combat spells, encapsulating each one, and making them interchangeable.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Evocation // Combat
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
alias combat-strategy = (int) -> int

val aggressive : combat-strategy = fn(damage) damage * 2
val defensive : combat-strategy = fn(damage) damage / 2

fun execute-strike(base-dmg: int, strat: combat-strategy) : int
  strat(base-dmg)

pub fun main()
  println("Aggressive strike: " ++ execute-strike(10, aggressive).show)
  println("Defensive strike: " ++ execute-strike(10, defensive).show)
Runic Tags: #koka #strategy #higher-order-functions