/// <summary> /// Called by the engine in various occasions to update the players information. /// </summary> /// <param name="orderedPlayers">The players in their current round order</param> /// <param name="potAmount">The current pot amount</param> /// <param name="communityCards">The game community cards, if any. Can be null</param> public void WaitSynchronizePlayers(IEnumerable <Player> orderedPlayers, int potAmount, Card[] communityCards) { List <Player> safePlayers = new List <Player>(); // showdown, send the actual players if (revealCards) { revealCards = false; safePlayers.AddRange(orderedPlayers); } else // create a the list of safe players { foreach (Player player in orderedPlayers) { safePlayers.Add(GetSafePlayer(player)); } } PotInformation information = new PotInformation(potAmount, owner.PlayersBettingData); KeyValuePair <Player, IPokerClient>[] copy = playerToClient.ToArray(); // send for each player the list of safe players, replace the player safe copy with the player actual data foreach (KeyValuePair <Player, IPokerClient> pair in copy) { Player[] sentArray = safePlayers.ToArray(); // search for the player entry in the safe array: int index = Array.FindIndex <Player>(sentArray, delegate(Player safe) { return(safe.Name == pair.Key.Name); }); if (index != -1) // if the player was found, replace it with the original value { sentArray[index] = pair.Key; } callAction(pair.Key, (cur) => cur.WaitSynchronization(sentArray, information, communityCards)); } foreachSpectator((cur) => cur.WaitSynchronization(safePlayers.ToArray(), information, communityCards)); }
/// <summary> /// Called by the client when an update message arrives. /// </summary> /// <param name="player">The players sorted by their round order</param> /// <param name="potInformation">The current state of the pot</param> /// <param name="communityCards">The community cards in the game (if any) may be null or in 0 length</param> public void WaitSynchronization(IEnumerable <Player> player, PokerService.PotInformation potInformation, Card[] communityCards) { Invoke <IEnumerable <Player>, PokerService.PotInformation, Card[]>(realHelper.WaitSynchronization, player, potInformation, communityCards); }