✨ ARCANUM RUNE DIFFICULTY: Apprentice Creational

The Monolith Spirit

Ensure that only one supreme automation entity controls the keyboard and mouse, preventing arcane interference.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Singleton
ARCANUM SCHOOL: Abjuration // Domain Control
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
class SupremePoltergeist {
    static instance := ""
    
    static GetInstance() {
        if (SupremePoltergeist.instance == "") {
            SupremePoltergeist.instance := SupremePoltergeist()
        }
        return SupremePoltergeist.instance
    }
    
    __New() {
        if (SupremePoltergeist.instance != "") {
            throw Error("Only one Supreme Poltergeist can exist!")
        }
        this.hauntings := 0
    }
    
    RecordHaunting() {
        this.hauntings += 1
        return this.hauntings
    }
}

spirit1 := SupremePoltergeist.GetInstance()
spirit2 := SupremePoltergeist.GetInstance()

spirit1.RecordHaunting()
MsgBox("Spirit 2 reads: " . spirit2.RecordHaunting()) ; 2
Runic Tags: #autohotkey #singleton #automation #poltergeist