internal static UserGuess UIGuessToLogicGuess(List <ButtonGuess> i_UIGuess, List <Color> i_ColorDictionary, GameManager i_GameManager) { List <eGuessOption> enumGuess = colorToEnum(i_UIGuess, i_ColorDictionary); UserGuess userGuess = new UserGuess(enumGuess, i_GameManager.GoalSequence); return(userGuess); }
public void SetGuessStrings(bool correctGuess) { bool addToString = false; if (ValidGuess) { for (int i = 0; i < alphabet.Length; i++) { if (alphabet[i] == UserGuess) { if (AlphaGuess[i] == 0) { addToString = true; break; } } } if (addToString) { if (correctGuess) { CorrectGuesses += UserGuess.ToString() + " "; } else { IncorrectGuesses += UserGuess.ToString() + " "; } } } }
private void checkButton_Click(object sender, EventArgs e) { List <ButtonGuess> currentUIGuess = r_GuessRows[r_GameManager.CurrentTurn].GuessButtons; UserGuess userGuess = Parse.UIGuessToLogicGuess(currentUIGuess, r_ColorDictionary, r_GameManager); r_GuessRows[r_GameManager.CurrentTurn].DisableButtons(); r_GameManager.UpdateGuess(userGuess); updateResultButtons(); continueToNextTurn(); }
public StartGameForm(Form3 form3) { InitializeComponent(); this.form3 = form3; //user tahmin etme int[] nums = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; int[] randomNum = new int[4]; //pcSayi UserGuess.sayilariKar(ref nums); //binler basamağı 0 olamaz Array.Copy(nums, randomNum, 4); pcSayi = randomNum; richTextBox1.Text = String.Format("My guess is {0}. If it is wrong, can you give me a few clue ?", PcGuess.guess(answers)); }
public void OnPostCheckAnswer() { dateTimeStr = Request.Form["xz"]; dateTime = DateTime.Parse(dateTimeStr); string translation = DateTranslation.Translate(dateTime); if (UserGuess != null && translation == UserGuess.Trim()) { Result = "Correct!"; } else { UserGuess = $"Your try: {UserGuess}"; Result = $"Correct : {translation}, looser!"; } }
static void Main(string[] args) { int Guesses = 5; string UserGuess; bool NameFound = false; string NameToGuess = "Sofus"; Console.WriteLine("Welcome to the Name Guesser, the game with a prize pool of absolutely nothing." + "\n \nThis is just a stupid program that is made because my teacher Marco said I should. But it's cool.. " + "\nAnyway, all you have to do is to guess the name that is hard programmed into this code. You have " + Guesses + " guesses."); Console.WriteLine("\n\nEnter your guess:"); while (!NameFound) { UserGuess = Console.ReadLine(); //If correct answer if (UserGuess.ToLower() == NameToGuess.ToLower()) { Console.WriteLine("Congrats, you've won nothing"); NameFound = true; Console.ReadLine(); //If incorrect answer } else if (!(UserGuess.ToLower() == NameToGuess.ToLower()) && Guesses > 0) { Guesses--; Console.WriteLine("\n\nWRONG! You have " + Guesses + " left \nEnter your guess:"); } //All tries used if (Guesses == 0) { Console.WriteLine("Du har brugt alle dine spil, og spillet stopper nu."); } } }
private void guessBtn_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(positiveBox.Text) && !String.IsNullOrEmpty(negativeBox.Text) && !String.IsNullOrEmpty(guessBox.Text)) { if ((int.Parse(positiveBox.Text) < 0 || int.Parse(positiveBox.Text) > 4) || (int.Parse(negativeBox.Text) < 0 || int.Parse(negativeBox.Text) > 4)) { MessageBox.Show("Clues can not be greater than 4 and smaller than 0 !"); } else { if (int.Parse(guessBox.Text) > 999 && int.Parse(guessBox.Text) < 10000) { userTahmin = int.Parse(guessBox.Text); pcNegative = 0; pcPositive = 0; var isfound = UserGuess.tahminDogruMu(pcSayi, userTahmin, ref pcPositive, ref pcNegative); //tahmin doğruysa richTextBox1.Text += "\nYour Guess:" + guessBox.Text + ", Your Clues:+" + positiveBox.Text + ",-" + negativeBox.Text + "\n"; if (!isfound) { tahminAdedi++; } if (isfound) { richTextBox1.Text += "You Won! Congratulations :)"; MessageBox.Show("You Won! Congratulations :>"); richTextBox1.Text += tahminAdedi + ". Step"; } else if (pcPositive > 0) { StringBuilder sb = new StringBuilder(); sb.AppendLine("+" + pcPositive + ""); if (pcNegative > 0) { sb.AppendLine("-" + pcNegative + ""); } richTextBox1.Text += ("===========\nMy Clues:\n" + sb.ToString()); pcguess(); } else if (pcNegative > 0) { StringBuilder sb = new StringBuilder(); sb.AppendLine("-" + pcNegative + ""); richTextBox1.Text += ("===========\nMy Clues:\n" + sb.ToString()); pcguess(); } else { richTextBox1.Text += ("===========\nYou didn't find any number, please try again !\nClues: 0,0"); pcguess(); } } else { MessageBox.Show("Please enter a 4-digit estimate!"); } } } else { MessageBox.Show("You must fill in all fields!"); } }
public async Task CreateGuess(UserGuess guess) { guess.TimeStamp = DateTime.Now; await _context.Guesses.InsertOneAsync(guess); }