public static void Attempts(int cpuRange, int cpuAttempts) { string[] answer = new string[cpuAttempts]; var minRange = GameLogic.MinUsrAnsw; for (var i = 0; i < cpuAttempts; i++) { var cpuAnswerNum = GameLogic.Randomize(minRange, cpuRange); Print($"{texts[(int)Str.I_Think_Num_Is]} {cpuAnswerNum}"); answer[i] = Console.ReadLine(); bool errorInputAnswer = answer[i] != texts[(int)Str.More_Than] && answer[i] != texts[(int)Str.Less_Than] && answer[i] != texts[(int)Str.Equals]; if (answer[i] == texts[(int)Str.More_Than]) { minRange = cpuAnswerNum + 1; continue; } if (answer[i] == texts[(int)Str.Less_Than]) { cpuRange = cpuAnswerNum - 1; continue; } if (answer[i] == texts[(int)Str.Equals]) { correctAnswer = true; break; } if (errorInputAnswer) { Print(texts[(int)Str.Bad_Help]); i--; } } }
public static void GameInProgress() { var numIHadInMind = GameLogic.Randomize(0, GameLogic.InputRange); var numOfAttempts = GameLogic.NumOfAttempts(numIHadInMind); Print(texts[(int)Str.CPU_Conceive_The_Number]); Print($"{texts[(int)Str.Input_The_Nunmber]} {numOfAttempts}"); Attempts(numOfAttempts, numIHadInMind); if (correctAnswer) { Print(texts[(int)Str.You_Win]); } if (!correctAnswer) { Print(texts[(int)Str.You_Lose]); } EndGame(); }