✨ ARCANUM RUNE DIFFICULTY: Apprentice Behavioral

The Command Pattern of Magic Actions

Encapsulate a request as an object, thereby letting you parameterize clients with different requests in Move.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Command
ARCANUM SCHOOL: Evocation // Invocation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
module arcane::command {
    struct Command has store, drop {
        action_type: u8, // 0 for heal, 1 for attack
        target: address,
        value: u64,
    }

    public fun create_heal_command(target: address, amount: u64): Command {
        Command { action_type: 0, target, value: amount }
    }

    public fun execute(cmd: Command) {
        let Command { action_type, target: _, value: _ } = cmd;
        if (action_type == 0) {
            // Execute heal logic
        } else if (action_type == 1) {
            // Execute attack logic
        }
    }
}
Runic Tags: #behavioral #command #move #actions