🎞️ ACTIONSCRIPT WARD DIFFICULTY: Apprentice Structural

The Composite

Treating a tree of display objects as a single eldritch entity.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Composite
ARCANUM SCHOOL: Conjuration // Hierarchical Horror
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// ACTIONSCRIPT PATTERN //
package arcana.composite {

    public interface IDisplayEntity {
        function renderTorment():void;
    }

    public class CursedLimb implements IDisplayEntity {
        private var name:String;

        public function CursedLimb(name:String) {
            this.name = name;
        }

        public function renderTorment():void {
            trace("Twitching limb: " + name);
        }
    }

    public class Amalgamation implements IDisplayEntity {
        private var name:String;
        private var children:Vector.<IDisplayEntity>;

        public function Amalgamation(name:String) {
            this.name = name;
            this.children = new Vector.<IDisplayEntity>();
        }

        public function absorb(entity:IDisplayEntity):void {
            children.push(entity);
        }

        public function renderTorment():void {
            trace("The amalgamation " + name + " groans. Its parts move:");
            for each (var child:IDisplayEntity in children) {
                child.renderTorment();
            }
        }
    }
}
Runic Tags: #composite #actionscript #flash #tree-structure