⚡ ZIG ALCHEMY DIFFICULTY: Adept Structural

The Proxy: Ward of Access

Provide a surrogate or placeholder for another artifact to control access to it.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Proxy
ARCANUM SCHOOL: Abjuration // Warding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// BLAZING-FAST ZIG ALCHEMY //
const std = @import("std");

pub const ForbiddenTome = struct {
    pub fn readSecrets() void {
        std.debug.print("Secrets revealed.\n", .{});
    }
};

pub const TomeProxy = struct {
    real_tome: ?*ForbiddenTome = null,
    clearance_level: u8,

    pub fn readSecrets(self: *TomeProxy, alloc: std.mem.Allocator) !void {
        if (self.clearance_level < 5) return error.AccessDenied;

        if (self.real_tome == null) {
            self.real_tome = try alloc.create(ForbiddenTome);
        }
        self.real_tome.?.readSecrets();
    }
};

Not all knowledge should be instantly accessible. The Ward of Access creates a Proxy shielding the Forbidden Tome. It delays the expensive materialization of the tome until absolutely necessary (lazy initialization) and intercepts all invocations to verify the caster’s clearance level.

Runic Tags: #proxy #structural #zig #wards