Пример #1
0
        static void RunChainOfResponsibilityWithMediator()
        {
            ChainOfResponsibility.Game      game   = new ChainOfResponsibility.Game();
            ChainOfResponsibility.Creature2 goblin = new ChainOfResponsibility.Creature2(game, "Strong Goblin", 3, 3);

            Console.WriteLine(goblin);
            using (new ChainOfResponsibility.DoubleAttackModifier2(game, goblin))
            {
                Console.WriteLine(goblin);
                using (new ChainOfResponsibility.IncreaseDefenseModifier2(game, goblin))
                {
                    Console.WriteLine(goblin);
                }
                Console.WriteLine(goblin);
            }

            Console.WriteLine(goblin);
        }
 public IncreaseDefenseModifier2(Game game, Creature2 creature) : base(game, creature)
 {
 }
 public DoubleAttackModifier2(Game game, Creature2 creature) : base(game, creature)
 {
 }
 /// <summary>
 /// the abstract handle method of this class get's assigned to the game Queries event
 /// </summary>
 /// <param name="game"></param>
 /// <param name="creature"></param>
 protected CreatureModifier2(Game game, Creature2 creature)
 {
     this.game     = game ?? throw new ArgumentNullException(nameof(game));
     Creature      = creature ?? throw new ArgumentNullException(nameof(creature));
     game.Queries += Handle;
 }