✨ ARCANUM RUNE DIFFICULTY: Apprentice Behavioral

The Strategy of Magical Combat

Swapping out combat algorithms dynamically based on enemy weaknesses.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Evocation // Combat
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
module Strategy

type enemy = { is_weak_to_fire: bool }
type attack_strategy = enemy -> nat

let fire_attack : attack_strategy = fun e ->
  if e.is_weak_to_fire then 100 else 10
  
let physical_attack : attack_strategy = fun e ->
  50
  
let execute_attack (strat: attack_strategy) (e: enemy) : nat =
  strat e

Higher-order functions inherently provide the Strategy pattern. Combat strategies are simply functions swapped at will.

Runic Tags: #strategy #algorithms #combat