The Chain of Responsibility: Arcane Tribunal
Pass a request along a chain of mystical handlers until one resolves it.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Chain of Responsibility
ARCANUM SCHOOL: Enchantment // Tribunal
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// BLAZING-FAST ZIG ALCHEMY //
const std = @import("std");
pub const TribunalNode = struct {
next: ?*TribunalNode = null,
vtable: *const VTable,
pub const VTable = struct {
handle: *const fn (self: *TribunalNode, power_level: u32) bool,
};
pub fn handle(self: *TribunalNode, power_level: u32) bool {
if (self.vtable.handle(self, power_level)) return true;
if (self.next) |n| return n.handle(power_level);
return false;
}
};
When a magical anomaly occurs, it must be judged. The Arcane Tribunal strings together a sequence of wardens. Each node intercepts the event; if its threshold is sufficient, it dispels the anomaly. Otherwise, the threat propagates up the chain to a higher authority. An elegant decoupling of sender and receiver.
Runic Tags:
#chain-of-responsibility
#behavioral
#zig
#tribunal