The Observer
Subscribing to dimensional shifts via event streams
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Observer
ARCANUM SCHOOL: Divination // Scrying
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// HAXE PATTERN //
interface IObserver {
public function update(manaLevel:Int):Void;
}
class MoonWell {
private var observers:Array<IObserver> = [];
private var mana:Int = 0;
public function new() {}
public function attach(o:IObserver):Void {
observers.push(o);
}
public function setMana(level:Int):Void {
this.mana = level;
notifyAll();
}
private function notifyAll():Void {
for (obs in observers) obs.update(this.mana);
}
}
class ElvenMage implements IObserver {
private var name:String;
public function new(name:String) { this.name = name; }
public function update(manaLevel:Int):Void {
trace('$name senses the well mana shifting to $manaLevel');
}
}
The Observer is the quintessential scrying mechanism. Instead of constantly polling the dimensional well for updates, interested mages simply register their signature. When the well surges, it pulses the data to all registered entities simultaneously.
Runic Tags:
#divination
#observer
#haxe