当第一个战士的生命值为0时,我如何摆脱循环。目前当战士的生命值低于0时,他们仍然会击中对手。请找附上我的照片。
public void StrikeOpponent(Warrior one, Warrior two)
{
while (one.Health > 0 && two.Health > 0)
{
two.Strike = rnd.Next(1, 100);
one.Health = one.Health - two.Strike;
Console.WriteLine("{0} dealt {1} damage", one.Name, two.Strike);
Console.WriteLine("{0}s health is {1}", one.Name, one.Health);
one.Strike = rnd.Next(1, 100);
two.Health = two.Health - one.Strike;
Console.WriteLine("{0} dealt {1} damage", two.Name, one.Strike);
Console.WriteLine("{0}s health is {1}", two.Name, two.Health);
}
}