public void Tie_User_And_Computer_Paper() { ChoiceModel choiceUser = _judgeService.CheckChoicePlayers("2"); ChoiceModel choiceComputer = _judgeService.CheckChoicePlayers("2"); ResultGameModel result = _judgeService.JudgeDefinesWinner(choiceUser.ChoiceEnum.ToString(), choiceComputer.ChoiceEnum.ToString()); Assert.AreEqual(result.ResultadoEnum, ResultadoEnum.Tie); }
public void User_Wins_With_Scissor_Against_Paper() { ChoiceModel choiceUser = _judgeService.CheckChoicePlayers("3"); ChoiceModel choiceComputer = _judgeService.CheckChoicePlayers("2"); var result = _judgeService.JudgeDefinesWinner(choiceUser.ChoiceEnum.ToString(), choiceComputer.ChoiceEnum.ToString()); Assert.AreEqual(result.ResultadoEnum, ResultadoEnum.UserWins); }
public void User_Loses_With_Rock_Against_Paper() { ChoiceModel choiceUser = _judgeService.CheckChoicePlayers("1"); ChoiceModel choiceComputer = _judgeService.CheckChoicePlayers("2"); ResultGameModel result = _judgeService.JudgeDefinesWinner(choiceUser.ChoiceEnum.ToString(), choiceComputer.ChoiceEnum.ToString()); Assert.AreEqual(result.ResultadoEnum, ResultadoEnum.ComputerWins); }
public IActionResult API() { var man = new ChoiceModel { Name = "Jeremiah", Height = "6 feet 8 inches", EyeColor = "Blue" }; return(Json(man)); }
public async Task <ActionResult> CreateChoice(ChoiceMvcModel model) { if (ModelState.IsValid) { IChoiceModel _choice = new ChoiceModel { ChoiceName = model.Name, UserID = (Guid)Session["UserID"] }; var status = await _choiceService.CreateAsync(_choice); Guid _userid = status.UserID; return(RedirectToAction("ListChoices", "LoggedIn", new { page = Session["page"] })); } return(View()); }
private void DisplayChoiceModel(IBaseTextModel ibtm) { ChoiceModel choiceModel = (ChoiceModel)ibtm; List <string> choiceTexts = choiceModel.choicesText; for (int i = 0; i < choiceTexts.Count; i++) { uiManager.SetChoiceText(choiceTexts[i], i + 1); } currentChoiceBranches = choiceModel.choicesBranch; isChoosing = true; }
private async Task QueryMarkupSetRelatedFieldValuesAsync(int markupSetArtifactId) { //retrieve markup set multipe choice field name var markupSetName = await ArtifactQueries.RetreiveMarkupSetNameAsync(AgentHelper.GetServicesManager(), _executionIdentity, WorkspaceArtifactId, markupSetArtifactId); string markupSetMultichoiceFieldName = $"{Constant.MarkupSet.MARKUP_SET_FIELD_NAME_PREFIX}{markupSetName}"; //retrieve markup set multipe choice field artifact id _markupSetMultiplechoiceFieldChoiceTypeId = await ArtifactQueries.RetreiveMarkupSetMultipleChoiceFieldTypeIdAsync(AgentHelper.GetServicesManager(), _executionIdentity, WorkspaceArtifactId, markupSetMultichoiceFieldName); //retrieve markup set multipe choice field choice values artifact id's var choices = await ArtifactQueries.QueryAllMarkupSetMultipleChoiceFieldValuesAsync(AgentHelper.GetServicesManager(), _executionIdentity, WorkspaceArtifactId, markupSetMultichoiceFieldName); _hasRedactionsChoiceModel = choices.First(x => x.Name.Equals(Constant.MarkupSet.MarkupSetMultiChoiceValues.HAS_REDACTIONS)); _hasHighlightsChoiceModel = choices.First(x => x.Name.Equals(Constant.MarkupSet.MarkupSetMultiChoiceValues.HAS_HIGHLIGHTS)); }
public ChoiceModel CheckChoicePlayers(string choicePlayers) { ChoiceModel choiceModel = new ChoiceModel(); ChoiceEnum choiceValue; if (Enum.TryParse(choicePlayers, out choiceValue)) { choiceModel.ChoiceEnum = choiceValue; } else { choiceModel.ErrorMessageWrongValue = "Opção de escolha indisponível. É necessário informar os valores '1', '2' ou '3' para jogar.\nPor favor, reinicie o jogo e tente novamente!"; choiceModel.ChoiceEnum = ChoiceEnum.ValorNaoSuportado; } return(choiceModel); }
private void showChoices() { string[] nicks = sequencerData.getSectionNames(); List <ChoiceModel> choices = new List <ChoiceModel>(); for (int i = 0; i < sectionIndexList.Count; i++) { ChoiceModel model = new ChoiceModel(); model.text = optionTextList [i]; model.sceneNameToJump = nicks [sectionIndexList [i]]; model.sceneCommandIndexToJump = commandIndexList [i]; choices.Add(model); } myPlayer.choiceController.generateButtons(choices, myPlayer); }
public IBaseTextModel ChoiceModel(string[] lines) { string[] splitedFirstLine = CutOutStrSet(lines[0]); List <string> choices = new List <string>(); foreach (string s in splitedFirstLine) { if (s == "n") { choices.Add("..."); } else { choices.Add(s); } } Debug.Log(lines.Length); List <Queue <IBaseTextModel> > branches = new List <Queue <IBaseTextModel> >(); Queue <IBaseTextModel> models = new Queue <IBaseTextModel>(); for (int i = 1; i < lines.Length; i++) { if (i == (lines.Length - 1)) { models.Enqueue(GeneralSolverExceptChoice(lines[i])); branches.Add(new Queue <IBaseTextModel>(models)); models.Clear(); } if (lines[i][0] == '1' || lines[i][0] == '2' || lines[i][0] == '3' || lines[i][0] == '4') { if (models.Count != 0) { branches.Add(new Queue <IBaseTextModel>(models)); models.Clear(); } continue; } models.Enqueue(GeneralSolverExceptChoice(lines[i])); } ChoiceModel choiceModel = new ChoiceModel(choices, branches); return(choiceModel); }
/// <summary> /// Maps the choice to choice model. /// </summary> /// <param name="choiceList">The choice list.</param> /// <returns></returns> private static IEnumerable <ChoiceModel> MapChoiceToChoiceModel(List <Choice> choiceList) { var models = new List <ChoiceModel>(); if (choiceList != null && choiceList.Any()) { foreach (var choice in choiceList) { var choiceModel = new ChoiceModel { Id = choice.Id, Name = choice.Name, Value = choice.Value }; models.Add(choiceModel); } } return(models); }
static void Main(string[] args) { //Setup DI var serviceProvider = new ServiceCollection() .AddScoped <IJudgeService, JudgeService>() .BuildServiceProvider(); var judgeResult = serviceProvider.GetService <IJudgeService>(); string choiceUser = null; string choiceCPU = null; Random rdn = new Random(); Console.WriteLine("Olá, seja bem vindo ao jogo de Jokenpoo!"); Console.WriteLine("As regras são as seguintes: \n" + " - Pedra empata com pedra e ganha de tesoura; \n" + " - Tesoura empata com tesoura e ganha de papel; \n" + " - Papel empata com papel e ganha de pedra."); Console.WriteLine("Para começarmos, digite '1' para 'Pedra', '2' para 'Papel' ou '3' para 'Tesoura':"); choiceUser = Console.ReadLine(); ChoiceModel verifyChoiceUser = judgeResult.CheckChoicePlayers(choiceUser); if (verifyChoiceUser.ChoiceEnum.ToString() != "Pedra" && verifyChoiceUser.ChoiceEnum.ToString() != "Papel" && verifyChoiceUser.ChoiceEnum.ToString() != "Tesoura") { Console.WriteLine(verifyChoiceUser.ErrorMessageWrongValue); } else { choiceCPU = rdn.Next(1, 3).ToString(); var verifyChoiceCPU = judgeResult.CheckChoicePlayers(choiceCPU); var result = judgeResult.JudgeDefinesWinner(verifyChoiceUser.ChoiceEnum.ToString(), verifyChoiceCPU.ChoiceEnum.ToString()); Console.WriteLine(result.ResultMessage); } Console.ReadKey(); }
public ChoiceBuilder(ChoiceModel cm) => _cm = cm;
public void MapJugementMajoritaireResultatModelToResultat() { var scrutinModel = new VotingProcessModel { Id = 52 }; var choice1 = new ChoiceModel { Id = 1, Value = 1 }; var choice2 = new ChoiceModel { Id = 2, Value = 2 }; var optionVainqueur = new OptionsModel { Id = 28, Name = "Winner" }; var optionPerdant = new OptionsModel { Id = 32, Name = "Loser" }; var resultatGagnant = new ResultatIndividualMajorityJudgmentModel { Option = optionVainqueur, Median = choice1, PercentageScoreInfMedian = 38m, PercentageScoreSupMedian = 42m }; var resultatPerdant = new ResultatIndividualMajorityJudgmentModel { Option = optionPerdant, Median = choice2, PercentageScoreInfMedian = 40m, PercentageScoreSupMedian = 36m }; var resultatModel = new ResultatMajoritaryJudgmentModel { Id = 96, IsValidResult = true, Voters = 4, Winner = optionVainqueur, IndividualResults = { resultatGagnant, resultatPerdant } }; var resultat = _mapper.MapResultatModelToResultat(scrutinModel, resultatModel); Check.That(resultat.IdVotingProcess).IsEqualTo(scrutinModel.Id); Check.That(resultat.IsValid).IsEqualTo(resultatModel.IsValidResult); Check.That(resultat.NbVoters).IsEqualTo(resultatModel.Voters); Check.That(resultat.IdWinningOption).IsEqualTo(resultatModel.Winner.Id); var scoreDetails = JsonConvert.DeserializeObject <List <ResultatIndividualMajorityJudgmentModel> >(resultat.ScoreDetail); Check.That(scoreDetails[0].PercentageScoreInfMedian).IsEqualTo(resultatGagnant.PercentageScoreInfMedian); Check.That(scoreDetails[0].PercentageScoreSupMedian).IsEqualTo(resultatGagnant.PercentageScoreSupMedian); Check.That(scoreDetails[0].Median.Id).IsEqualTo(resultatGagnant.Median.Id); Check.That(scoreDetails[0].Option.Id).IsEqualTo(resultatGagnant.Option.Id); Check.That(scoreDetails[1].PercentageScoreInfMedian).IsEqualTo(resultatPerdant.PercentageScoreInfMedian); Check.That(scoreDetails[1].PercentageScoreSupMedian).IsEqualTo(resultatPerdant.PercentageScoreSupMedian); Check.That(scoreDetails[1].Median.Id).IsEqualTo(resultatPerdant.Median.Id); Check.That(scoreDetails[1].Option.Id).IsEqualTo(resultatPerdant.Option.Id); }
public ChoiceBuilder() { _cm = new ChoiceModel(); }
public void User_Inserted_Unsupported_Value() { ChoiceModel choiceUser = _judgeService.CheckChoicePlayers("teste jogo"); Assert.AreEqual(choiceUser.ChoiceEnum, ChoiceEnum.ValorNaoSuportado); }
private void showChoices() { List<ChoiceModel> choices = new List<ChoiceModel>(); for (int i = 0; i < sectionNameList.Count; i++) { ChoiceModel model = new ChoiceModel(); model.text = optionTextList [i]; model.sceneNameToJump = sectionNameList [i]; model.sceneCommandIndexToJump = commandIndexList [i]; choices.Add(model); } myPlayer.choiceController.generateButtons(choices, myPlayer); }
public void Check_Choice_Computer_Rock() { ChoiceModel choiceComputer = _judgeService.CheckChoicePlayers("1"); Assert.AreEqual(choiceComputer.ChoiceEnum, ChoiceEnum.Pedra); }
public void Check_Choice_Computer_Scissor() { ChoiceModel choiceComputer = _judgeService.CheckChoicePlayers("3"); Assert.AreEqual(choiceComputer.ChoiceEnum, ChoiceEnum.Tesoura); }
public void Check_Choice_Computer_Paper() { ChoiceModel choiceComputer = _judgeService.CheckChoicePlayers("2"); Assert.AreEqual(choiceComputer.ChoiceEnum, ChoiceEnum.Papel); }