Ejemplo n.º 1
0
        static void RunChainOfResponsibility()
        {
            CORCreature goblin = new CORCreature("goblin", 2, 2);

            Console.WriteLine(goblin);


            CORCreatureModifier root = new CORCreatureModifier(goblin);

            CORNoBonusesModifier noBonusesModifier = new CORNoBonusesModifier(goblin);

            root.Add(noBonusesModifier);

            CORDoubleAttackModifier doubleAttackModifier = new CORDoubleAttackModifier(goblin);



            root.Add(doubleAttackModifier);

            CORIncreaseDefenseModifier increaseDefenseModifier = new CORIncreaseDefenseModifier(goblin);

            root.Add(increaseDefenseModifier);


            root.Handle();

            Console.WriteLine(goblin);
        }
 public void Add(CreatureModifier creatureModifier)
 {
     if (next != null)
     {
         next.Add(creatureModifier);
     }
     else
     {
         next = creatureModifier;
     }
 }