✨ ARCANUM RUNE DIFFICULTY: Apprentice Structural

The Decorator of Enchanted Wands

Attach additional responsibilities to objects dynamically by wrapping resources in Move.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Enchantment // Artifice
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
module arcane::decorator {
    struct BaseWand has store, drop { power: u64 }
    
    struct EnchantedWand has store, drop {
        wand: BaseWand,
        bonus_power: u64,
    }

    public fun enchant(wand: BaseWand, bonus: u64): EnchantedWand {
        EnchantedWand { wand, bonus_power: bonus }
    }

    public fun total_power(ew: &EnchantedWand): u64 {
        ew.wand.power + ew.bonus_power
    }
}
Runic Tags: #structural #decorator #move #enchantment