示例#1
0
        static void Main(string[] args)
        {
            Console.Title = "ArenaFighter";

            string          key;
            Player          player = new Player();
            PlayerCharacter pc;

            Console.WriteLine("Please set a name for your character:");
            key = Console.ReadLine();
            pc  = new PlayerCharacter {
                Name = key
            };

            do
            {
                pc.RollAttributes();
                pc.Health = new Dice().RollDice() + 2;
                Console.WriteLine("Figher name:" + pc.Name);
                Console.WriteLine("Stats: \n"
                                  + "Health:" + pc.Health + "\n"
                                  + "Strenght:" + pc.Strenght + "\n"
                                  + "Defense: " + pc.Defense + "\n"
                                  + "Initiative:" + pc.Initiative);
                pc.MaxHealth = pc.Health;

                ConsoleKey response;
                do
                {
                    Console.Write("Use this character? (y/n)");
                    response = Console.ReadKey(false).Key;
                    if (response != ConsoleKey.Enter)
                    {
                        Console.WriteLine();
                    }
                } while (response != ConsoleKey.Y && response != ConsoleKey.N);

                charSelectConfirmed = response == ConsoleKey.Y;
            } while (!charSelectConfirmed);

            Console.ReadLine();
            Console.Clear();

            DoIntro();
            player.PlayerCharacter = pc;

            BattleLog battleLog = new BattleLog();
            Battle    battle    = new Battle(player, battleLog);

            battle.Play();

            if (battle.BattleEnded)
            {
                Console.WriteLine("A history of events:");
                battleLog.ShowLog();

                int totalScore = 0;
                totalScore += player.DefeatedOpponents;

                if (!player.PlayerCharacter.IsDefeated && player.DefeatedOpponents > 0)
                {
                    totalScore += 50;
                }

                Console.WriteLine($"\nFinal score: {totalScore}");
                Console.ReadLine();
            }
        }