public ActionResult Details(int id, int bank, int bet, int jediBet) { ServiceJediClient service = new ServiceJediClient(); TournoiWCF t = service.getAllTournoi().ToList().Find(x => x.Id == id); bank -= bet; if (t == null) { return(HttpNotFound()); } if (t.Matches.ToList().Count == 1) { return(RedirectToAction("End", new { bank = bank, win = true, idJedi = t.Matches[0].Jedi1.Id })); } else { // Jouer les matches et recuperer le nouveau tournois TournoiWCF tnew = service.playTournoi(t); string nom = t.Nom + " " + tnew.Matches[0].PhaseTournoi; tnew.Nom = nom; service.addTournoi(tnew); tnew = service.getAllTournoi().ToList().Find(x => x.Nom == nom); // Determine si le joueur a gagne bool win = false; for (int i = 0; i < tnew.Matches.ToList().Count&& !win; i++) { if (tnew.Matches[i].Jedi1.Id == jediBet || tnew.Matches[i].Jedi2.Id == jediBet) { win = true; bank += bet * 2; } } return(RedirectToAction("Details", new { Id = tnew.Id, bank = bank })); } }
public ActionResult Details(int id, int bank, int bet, int jediBet) { ServiceJediClient service = new ServiceJediClient(); TournoiWCF t = service.getAllTournoi().ToList().Find(x => x.Id == id); bank -= bet; if (t == null) { return HttpNotFound(); } if (t.Matches.ToList().Count == 1) { return RedirectToAction("End",new { bank = bank, win = true, idJedi = t.Matches[0].Jedi1.Id }); } else { // Jouer les matches et recuperer le nouveau tournois TournoiWCF tnew = service.playTournoi(t); string nom = t.Nom + " " + tnew.Matches[0].PhaseTournoi; tnew.Nom = nom; service.addTournoi(tnew); tnew = service.getAllTournoi().ToList().Find(x => x.Nom == nom); // Determine si le joueur a gagne bool win = false; for(int i=0; i<tnew.Matches.ToList().Count && !win; i++) { if(tnew.Matches[i].Jedi1.Id == jediBet || tnew.Matches[i].Jedi2.Id == jediBet) { win = true; bank += bet * 2; } } return RedirectToAction("Details", new { Id = tnew.Id, bank = bank }); } }