✨ ARCANUM RUNE DIFFICULTY: Apprentice Creational

The Factory Method of Magical Artifacts

Define an interface for creating resources, but let subclasses decide which class to instantiate in Move.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Runesmithing
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
module arcane::factory_method {
    struct Artifact has key, store {
        magic_level: u64,
    }

    const ELEVEL_TOO_LOW: u64 = 0;

    // The factory method enforces resource-safe creation rules
    public fun create_artifact(level: u64): Artifact {
        assert!(level > 0, ELEVEL_TOO_LOW);
        Artifact { magic_level: level }
    }
}
Runic Tags: #creational #factory-method #move #artifacts