🎞️ ACTIONSCRIPT WARD DIFFICULTY: Apprentice Behavioral

The Chain of Responsibility

Passing a cursed artifact along a hierarchy of dark priests until one can bear its weight.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Chain of Responsibility
ARCANUM SCHOOL: Enchantment // Command Delegation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// ACTIONSCRIPT PATTERN //
package arcana.chain {

    public class CursedArtifact {
        public var maliceLevel:int;
        public function CursedArtifact(malice:int) {
            this.maliceLevel = malice;
        }
    }

    public class Priest {
        private var nextPriest:Priest;
        private var tolerance:int;
        private var title:String;

        public function Priest(title:String, tolerance:int) {
            this.title = title;
            this.tolerance = tolerance;
        }

        public function setNext(priest:Priest):void {
            this.nextPriest = priest;
        }

        public function handleArtifact(artifact:CursedArtifact):void {
            if (artifact.maliceLevel <= tolerance) {
                trace(title + " successfully contains the artifact.");
            } else if (nextPriest != null) {
                trace(title + " cannot bear it. Passing to next...");
                nextPriest.handleArtifact(artifact);
            } else {
                trace("No priest could contain it. The artifact destroys the order.");
            }
        }
    }
}
Runic Tags: #chain-of-responsibility #actionscript #flash #handlers