The Factory Method: Homunculus Generation
Delegate the exact aetheric composition of your spawn to subclassed arcane chambers.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Transmutation // Homunculus Generation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// BLAZING-FAST ZIG ALCHEMY //
const std = @import("std");
pub const Familiar = struct {
speak: *const fn () void,
};
pub const FamiliarChamber = struct {
vtable: *const VTable,
pub const VTable = struct {
spawn: *const fn (self: *FamiliarChamber, alloc: std.mem.Allocator) !*Familiar,
};
pub fn spawn(self: *FamiliarChamber, alloc: std.mem.Allocator) !*Familiar {
return self.vtable.spawn(self, alloc);
}
};
When the exact parameters of a bound familiar are unknown until the moment of summoning, the Factory Method offers a polymorphic sigil. By trusting the local FamiliarChamber implementation, the sorcerer avoids hardcoding the summon, relying instead on explicit memory allocations to pull the entity through the veil.
Runic Tags:
#factory-method
#creational
#zig
#homunculus