private async Task CheckAnswerAsync2(IDialogContext context, IAwaitable <Guessed> result) { var selection = await result; ansindf++; if (ansindf < f + 1) { if (selection.ToString().Equals("right")) { await context.PostAsync("**Great, guessed right one more time !**"); PromptDialog.Confirm(context, startgame, "Do you wanna Play Again?"); } else if (ansindf < f) { try { var options = new Guessed[] { Guessed.right, Guessed.wrong }; var descriptions = new string[] { "Am I Right", "Am I Wrong" }; PromptDialog.Choice <Guessed>(context, CheckAnswerAsync2, options, "Is Your item......." + finalans1[ansindf], descriptions: descriptions); } catch (Exception e) { } } else { await context.PostAsync("**No Such Vegetable or Fruit Exists**"); PromptDialog.Confirm(context, startgame, "Do you wanna Play Again?"); } } else { var cardMsg = context.MakeMessage(); var attachment = bravo("", ""); cardMsg.Attachments.Add(attachment); await context.PostAsync(cardMsg); await context.PostAsync("**Bravo!!!You Defeated Me**"); PromptDialog.Confirm(context, startgame, "Do you wanna Play Again?"); } }
public void StartGuessing(int numberToGuess) { int delta; do { int guessingNumber; lock (_reportingObject) { guessingNumber = _player.GuessNumber(); } delta = Math.Abs(numberToGuess - guessingNumber); if (delta > 0) { GuessedIncorrectNumber?.Invoke(Name, guessingNumber); Console.WriteLine($"{Name} has a penalty {delta} miliseconds"); Thread.Sleep(delta); _attempts++; _penalty += delta; } if (_penalty >= TotalPenalty) { TotalPenaltyReached?.Invoke(Name); return; } if (_attempts >= TotalAttempts) { TotalAttemptsReached?.Invoke(Name); return; } if (_guessingFinished) { return; } } while (delta != 0); Guessed?.Invoke(Name, _attempts); }
private async Task OnquestionReply(IDialogContext context, IAwaitable <bool> result) { var answer = await result; ansind = 0; if (answer) { ans[qno] = "Yes"; } else { ans[qno] = "No"; } int c = 0, i = 0; string propertyValue = ""; qno++; if (qno == 12) { ansind = 0; Methods rm = new Methods(); JArray r = rm.getValues(); foreach (JObject parsedObject in r.Children <JObject>()) { c = 0; i = 0; foreach (JProperty parsedProperty in parsedObject.Properties()) { propertyValue = (string)parsedProperty.Value; if (propertyValue.Equals(ans[i])) { c++; i++; } } if (c == 12) { try { finalans[k++] = propertyValue; var options = new Guessed[] { Guessed.right, Guessed.wrong }; var descriptions = new string[] { "Am I Right", "Am I Wrong" }; PromptDialog.Choice <Guessed>(context, CheckAnswerAsync, options, "Is Your Character......." + finalans[ansind] + "", descriptions: descriptions); // await context.PostAsync(finalans[ansind]); } catch (Exception e) { // await context.PostAsync("error------->"+e.ToString()); } } } if (k == 0) { await context.PostAsync("**No Such Animal or Bird Exists**"); PromptDialog.Confirm(context, startgame, "Do you wanna Play Again?"); } } else if (qno < 12) { var cardMsg = context.MakeMessage(); var attachment = GetThumbnailCard(s[imgidx], ""); cardMsg.Attachments.Add(attachment); await context.PostAsync(cardMsg); PromptDialog.Confirm(context, OnquestionReply, keys[qno], attachment.ToString()); } else { context.Wait(MessageReceived); } }
private async Task OnquestionReplyforVeg(IDialogContext context, IAwaitable <bool> result) { var answer = await result; ansindf = 0; if (answer) { ans[qno] = "Yes"; } else { ans[qno] = "No"; } int c = 0, i = 0; string propertyValue = ""; qno++; if (qno == 11) { ansindf = 0; Methods rm = new Methods(); JArray r = rm.getValuesofveg(); foreach (JObject parsedObject in r.Children <JObject>()) { c = 0; i = 0; foreach (JProperty parsedProperty in parsedObject.Properties()) { propertyValue = (string)parsedProperty.Value; if (propertyValue.Equals(ans[i])) { c++; i++; } } if (c == 11) { try { finalans1[f++] = propertyValue; var options = new Guessed[] { Guessed.right, Guessed.wrong }; var descriptions = new string[] { "Am I Right", "Am I Wrong" }; PromptDialog.Choice <Guessed>(context, CheckAnswerAsync2, options, "Is Your Item......." + finalans1[ansindf] + "", descriptions: descriptions); } catch (Exception e) { // await context.PostAsync("error------->"+e.ToString()); } } } if (f == 0) { await context.PostAsync("**No Such Vegetable or Fruit Exists**"); PromptDialog.Confirm(context, startgame, "Do you wanna Play Again?"); } } else if (qno < 11) { PromptDialog.Confirm(context, OnquestionReplyforVeg, keys[qno]); } else { context.Wait(MessageReceived); } }
private void HandleGuessed(Guessed guessed) { Console.WriteLine("Enquirer: Guessed {0}", guessed.Number); game.Tell(guessed); }
private void EndGame(Guessed guessed) { Console.WriteLine("Game: Number is guessed, game is over"); starter.Tell(guessed); }