The Memento Chronosphere
Captures and restores an object's internal state without violating encapsulation, rewinding time.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Memento
ARCANUM SCHOOL: Transmutation // Chronomancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
struct chronosphere( state: int )
effect time-magic
ctl save-state(s: int) : chronosphere
ctl restore-state(m: chronosphere) : int
fun chronomancer(action: () -> <time-magic|e> a) : e a
with handler
ctl save-state(s) resume(chronosphere(s))
ctl restore-state(m) resume(m.state)
action()
pub fun main()
with chronomancer
var hp := 100
println("HP: " ++ hp.show)
val snapshot = save-state(hp)
hp = 10
println("Took damage. HP: " ++ hp.show)
hp = restore-state(snapshot)
println("Time rewound. HP: " ++ hp.show)
Runic Tags:
#koka
#memento
#chronomancy