The Command of Runes
Encapsulating spell invocations as data structures to be executed or delayed.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Command
ARCANUM SCHOOL: Evocation // Runecraft
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
interface RuneCommand
exposes [Command, executeCommands]
imports []
Command : [
Strike { damage : U64 },
Heal { amount : U64 },
Shield { duration : U64 }
]
State : { health : I64, armor : U64 }
applyCommand : State, Command -> State
applyCommand = \state, cmd ->
when cmd is
Strike { damage } -> { state & health: state.health - Num.toI64 damage }
Heal { amount } -> { state & health: state.health + Num.toI64 amount }
Shield { duration } -> { state & armor: state.armor + duration }
executeCommands : State, List Command -> State
executeCommands = \initialState, commands ->
List.walk commands initialState applyCommand
Runic Tags:
#fast-functional-wards
#roc
#command