Esempio n. 1
0
        static void Main(string[] args)
        {
            king = new King(Console.ReadLine());

            attackHandlers = Console.ReadLine()
                             .Split()
                             .Select(InitializeHandler <RoyalGuard>)
                             .Concat(Console.ReadLine()
                                     .Split()
                                     .Select(InitializeHandler <Footman>))
                             .ToDictionary(k => ((IEntity)k).Name, v => v);

            var input = "";

            while ((input = Console.ReadLine()) != "End")
            {
                if (input == "Attack King")
                {
                    king.Attack();
                }

                else if (input.StartsWith("Kill"))
                {
                    var targetName = input.Split()[1];

                    var target = attackHandlers[targetName] as MortalEntity;
                    target.Kill();
                }
            }
        }
Esempio n. 2
0
        static void Main()
        {
            string kingName = Console.ReadLine();
            King   king     = new King(kingName);
            string guards   = Console.ReadLine();

            king.RegisterRoyalGuards(guards);
            string footmen = Console.ReadLine();

            king.RegisterFootmen(footmen);
            king.KingUnderFire += King_Attacked_RoyalGuardsAction;
            king.KingUnderFire += King_Attacked_Footmen_Action;

            string[] command = Console.ReadLine().Split();
            while (command[0] != "End")
            {
                switch (command[0].ToLower())
                {
                case "attack": king.Attack(); break;

                case "kill":
                {
                    string targetName = command[1];
                    king.Kill(targetName);
                    break;
                }
                }
                command = Console.ReadLine().Split();
            }
        }
Esempio n. 3
0
        private static void Run()
        {
            while (true)
            {
                string line = Console.ReadLine();

                if (line == "End")
                {
                    break;
                }

                string[] args = line.Split();

                switch (args[0])
                {
                case "Attack":
                    king.Attack();
                    break;

                case "Kill":
                    Soldier toRemove = soldiers.First(n => n.Name == args[1]);
                    king.KingAttacked -= toRemove.ProtectKing;
                    soldiers.Remove(toRemove);
                    break;
                }
            }
        }
Esempio n. 4
0
    public static void Main()
    {
        string kingName = Console.ReadLine();
        var    king     = new King(kingName);

        AddPlayer(king);

        string input;

        while ((input = Console.ReadLine()) != "End")
        {
            var    args    = input.Split();
            string command = args[0];

            if (command == "Attack")
            {
                king.Attack();
            }

            if (command == "Kill")
            {
                string name = args[1];
                king.Kill(name);
            }
        }
    }