私はシニア RAP プロジェクトのゲームに取り組んでおり、最近までこのループが機能していました。プレイヤーまたは敵のいずれかのヘルスが 0 になったときにこれを繰り返す方法が必要です。これらの例の両方がそうであるように、両方を 0 にしたくありません。これをいくつかの方法で書き直そうとしましたが、うまくいきませんでした。これを手伝ってくれたすべての人に感謝します。
while (!(enemyHealth == 0 || playerHealth == 0)
{ //START WHILE
Console.WriteLine("[System:] Here are the list of moves that you can do:\n1)Punch\n2)Kick\n3)Round House Kick");
Console.WriteLine();
decision = Console.ReadLine();
Console.WriteLine();
decisionNumber = int.Parse(decision);
if (decisionNumber < 1 || decisionNumber > 3)
{ //STARTS IF
throw new Exception();
} //ENDS IF
else
{ //STARTS ELSE
enemyHealth = enemyHealth - attackNumber;
playerHealth = playerHealth - enemyAttackNumber;
Console.WriteLine();
Console.WriteLine("[System:] Enemy Health: " + enemyHealth + "\nYour Health: " + playerHealth);
} //ENDS ELSE
} //ENDS WHILE
while (enemyHealth > 0 || playerHealth > 0)
{ //START WHILE
Console.WriteLine("[System:] Here are the list of moves that you can do:\n1)Punch\n2)Kick\n3)Round House Kick");
Console.WriteLine();
decision = Console.ReadLine();
Console.WriteLine();
decisionNumber = int.Parse(decision);
if (decisionNumber < 1 || decisionNumber > 3)
{ //STARTS IF
throw new Exception();
} //ENDS IF
else
{ //STARTS ELSE
enemyHealth = enemyHealth - attackNumber;
playerHealth = playerHealth - enemyAttackNumber;
Console.WriteLine();
Console.WriteLine("[System:] Enemy Health: " + enemyHealth + "\nYour Health: " + playerHealth);
} //ENDS ELSE
} //ENDS WHILE
私はそれに大きな問題を抱えているので、誰でもこれを理解できますか。