The Builder of Arcane Constructs
Construct complex magical resources step-by-step in Move without losing references.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Builder
ARCANUM SCHOOL: Transmutation // Artifice
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
module arcane::builder {
struct Golem has key, store {
head: u8,
body: u8,
arms: u8,
}
struct GolemBuilder has drop {
head: u8,
body: u8,
arms: u8,
}
public fun new_builder(): GolemBuilder {
GolemBuilder { head: 0, body: 0, arms: 0 }
}
public fun with_head(builder: GolemBuilder, head: u8): GolemBuilder {
builder.head = head;
builder
}
public fun with_body(builder: GolemBuilder, body: u8): GolemBuilder {
builder.body = body;
builder
}
public fun build(builder: GolemBuilder): Golem {
let GolemBuilder { head, body, arms } = builder;
Golem { head, body, arms }
}
}
Runic Tags:
#creational
#builder
#move
#constructs