⚙️ C++ SPELL DIFFICULTY: Adept Behavioral

The State

Altering an entity's behavior when its internal elemental alignment changes.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: State
ARCANUM SCHOOL: Transmutation // Polymorph
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// EXECUTABLE C++ PATTERN //
#include <memory>
class Entity;
class Alignment {
public: virtual ~Alignment() = default; virtual void Attack(Entity* e) = 0;
};
class Entity {
    std::unique_ptr<Alignment> state;
public:
    void SetAlignment(std::unique_ptr<Alignment> s) { state = std::move(s); }
    void Attack() { if(state) state->Attack(this); }
};
class FireAlignment : public Alignment {
public: void Attack(Entity* e) override {}
};
Runic Tags: #behavioral #state #cpp