public static string GetHint() { string stringOutput = ""; if ((!EndGame.DoubleEndGame() || !EndGame.SingleEndGame()) && Globals.hintsLeft > 0) { char[] phrase = Globals.phrase.ToLower().ToCharArray(); Array.Reverse(phrase); char[] alphabet = string.Join("", Globals.alphabet).ToLower().ToCharArray(); bool output = true; for (int i = 0; i < phrase.Length; i++) { for (int j = 0; j < alphabet.Length && output; j++) { if (phrase[i] == alphabet[j] && Globals.marker[j] != "¯") { stringOutput = Globals.alphabet[j]; output = false; } } } Globals.hintsLeft--; return(stringOutput); } else { Console.WriteLine(" No hints left"); return(stringOutput); }; }
public static void SingleGameLoop() { while (!EndGame.SingleEndGame()) { Draw.DrawSingleGame(); UserInput.userInput(); CheckLetter.checkLetter(); if (EndGame.wonGame()) { gameOutcome(0, " The man lives!", "", Draw.DrawSingleGame); } if (EndGame.lostGame()) { gameOutcome(-1, " You let the man hang...", " The phrase was: " + Globals.phrase, Draw.DrawSingleGame); } } }
public static void DrawSingleGame() { Console.Clear(); Console.WriteLine("╔══════════════════════════════════════════════════════════════════════════════╗"); Console.WriteLine("║ " + string.Join(" ", Globals.alphabet) + " ║"); Console.WriteLine("║ " + string.Join(" ", Globals.marker) + " ║"); Console.WriteLine("║ " + Globals.image[Globals.triesLeft][0] + " ║"); Console.WriteLine("║ " + Globals.image[Globals.triesLeft][1] + " ║"); Console.WriteLine("║ " + Globals.image[Globals.triesLeft][2] + Line.calculateLine(67, Globals.phraseMarker) + "║"); Console.WriteLine("║ " + Globals.image[Globals.triesLeft][3] + " ║"); Console.WriteLine("║ " + Globals.image[Globals.triesLeft][4] + " ║"); Console.WriteLine("╠═══════════════════════╦═════════════════╦══════════╦══════════════╦══════════╣"); Console.Write("║ Category: " + Line.calculateLine(12, Globals.category) + "║"); Console.WriteLine(" Hints: " + Globals.hintsLeft + " [hint] ║ Lives: " + Globals.livesLeft + " ║ Score:" + Line.calculateLine(7, Globals.score.ToString()) + "║ [menu] ║"); Console.WriteLine("╚═══════════════════════╩═════════════════╩══════════╩══════════════╩══════════╝"); Console.WriteLine(""); if (!EndGame.SingleEndGame()) { Console.Write(" Input a letter: "); } }