Console.WriteLine(" -------------------");
GameLoop();
Console.WriteLine(" -------------------");
Console.ReadKey();
}
private static void GameLoop()
{
Random random
= new Random
(); int monsterHealth = 16, heroHealth = 16, fate = 0;
while (( heroHealth > 0 ) && ( monsterHealth > 0 ))
{
fate = random.Next(1, 11);
monsterHealth -= fate;
Console.WriteLine($"Monster was damaged and lost {fate} health " +
$"and now has {monsterHealth} health.");
if (monsterHealth <= 0)
{
Console.WriteLine("Monster suffers a horrible death !! ");
continue;
}
fate = random.Next(1, 11);
heroHealth -= fate;
Console.WriteLine($"Hero was wounded and lost {fate} health " +
$"and now has {heroHealth} health.");
if (heroHealth <= 0) { Console.WriteLine("Hero achieves a heroic martyrdom !! "); }
}
}