public ActionResult NextRoundMultiplayer(string name) { Poker poker; Poker serverPoker; MultiplayerGame.PDictionary.TryGetValue(name, out poker); try { if (poker.IsServer) { MultiplayerGame.PDictionary.TryGetValue(MultiplayerGame.ServerPlayer, out serverPoker); serverPoker = new Poker(poker.Players); serverPoker.PrepareForNextRound(); serverPoker.IsEndGame = false; serverPoker.IsServer = true; serverPoker.Host = serverPoker.Players.FirstOrDefault(p => p.Name.Equals(name)); serverPoker.Host.Opponents = serverPoker.Players.Where(p => !p.Name.Equals(name)).ToList(); HttpContext.Session["Poker"] = serverPoker; MultiplayerGame.PDictionary[MultiplayerGame.ServerPlayer] = serverPoker; MultiplayerGame.AccesLock = false; return PartialView("Multiplayer", MultiplayerGame.PDictionary[MultiplayerGame.ServerPlayer]); } while (MultiplayerGame.AccesLock) { //Wachten totdat de servergame opnieuw geinitialiseerd is. } MultiplayerGame.PDictionary.TryGetValue(MultiplayerGame.ServerPlayer, out serverPoker); poker.Players = serverPoker.Players; poker.Table = serverPoker.Table; poker.Host = serverPoker.Players.FirstOrDefault(p => p.Name.Equals(name)); poker.Host.Opponents = serverPoker.Players.Where(p => !p.Name.Equals(name)).ToList(); poker.ActivePlayer = serverPoker.ActivePlayer; poker.IndexActivePlayer = serverPoker.IndexActivePlayer; poker.StartIndex = serverPoker.StartIndex; poker.RollingIndex = serverPoker.RollingIndex; poker.PreFlop = false; poker.IsServer = false; poker.IsEndGame = false; MultiplayerGame.PDictionary[name] = poker; } catch (Exception e) { TempData["message"] = $"{e.Message}"; } return PartialView("Multiplayer", poker); }
public ActionResult NextRound(Poker poker) { Poker newPoker = null; try { IList<IPlayer> players = poker.Players; newPoker = new Poker(players); newPoker.PrepareForNextRound(); } catch (Exception e) { TempData["message"] = $"{e.Message}"; } HttpContext.Session["Poker"] = newPoker; return View("Create", newPoker); }