Example #1
0
        public static void Main()
        {
            Player player = new Player();
            Heigan heigan = new Heigan();

            double heiganDamage = double.Parse(Console.ReadLine());
            string spell        = string.Empty;

            while (true)
            {
                if (player.IsHit)
                {
                    player.Points -= 3500;
                    player.IsHit   = false;
                }

                heigan.Damage(heiganDamage);

                if (HasWinner(player, heigan, spell))
                {
                    break;
                }

                string[] inputParts = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                                      .ToArray();
                spell = inputParts[0];
                int spellRow = int.Parse(inputParts[1]);
                int spellCol = int.Parse(inputParts[2]);

                if (MovePlayer(player.Row, player.Col, spellRow, spellCol) && IsDamaged(spellRow, spellCol, player))
                {
                    switch (spell)
                    {
                    case "Cloud":
                        player.Points -= 3500;
                        player.IsHit   = true;
                        break;

                    case "Eruption":
                        player.Points -= 6000;
                        break;
                    }
                }

                if (HasWinner(player, heigan, spell))
                {
                    break;
                }
            }
        }
Example #2
0
        private static bool HasWinner(Player player, Heigan heigan, string spell)
        {
            if (player.Points <= 0 || heigan.Points <= 0)
            {
                if (spell == "Cloud")
                {
                    spell = "Plague Cloud";
                }

                Console.WriteLine(heigan.Points > 0 ? $"Heigan: {heigan.Points:F2}" : $"Heigan: Defeated!");
                Console.WriteLine(player.Points > 0 ? $"Player: {player.Points}" : $"Player: Killed by {spell}");
                Console.WriteLine($"Final position: {player.Row}, {player.Col}");

                return(true);
            }
            return(false);
        }