public void NotifyNewPlayer(List <Player> PlayersRegistered, IDominoServiceCallbackContract Callback, int PlayerPosition, string PlayerName) { PlayerData playerData = new PlayerData(PlayerName, PlayerPosition); Callback.NewPlayerJoined(playerData); foreach (Player PlayerRegistered in PlayersRegistered) { PlayerData PlayerRegisteredData = new PlayerData(PlayerRegistered.getName(), PlayerRegistered.getPosition()); PlayerRegistered.getCallback().NewPlayerJoined(playerData); Callback.NewPlayerJoined(PlayerRegisteredData); } }
public void InfoPlayerJoined(List <Player> PlayersRegistered, string PlayerName, IDominoServiceCallbackContract Callback, int PlayerPosition) { playerD = new PlayerData(PlayerName, PlayerPosition); //aqui me siento yo Callback.NewPlayerJoined(playerD); foreach (Player PlayerRegistered in PlayersRegistered) { //aqui informo a los demas jugadores que me he sentado yo PlayerRegistered.PlayerCallbackChannel.NewPlayerJoined(playerD); PlayerData playerOld = new PlayerData(PlayerRegistered.playerName, PlayerRegistered.tablePosition); //aqui me informo yo de los jugadores que ya estan sentados Callback.NewPlayerJoined(playerOld); } }
public void RequestSitPlayer(string PlayerName) { IDominoServiceCallbackContract Callback = OperationContext.Current.GetCallbackChannel <IDominoServiceCallbackContract>(); try { Table.getTable().RequestSitPlayer(PlayerName, Callback); int PlayerPosition = Table.getTable().playersRegistered.Count; // Ha podido sentar al nuevo jugador y se notifica a todos los sentados los datos del nuevo jugador //Callback.NewPlayerJoined(PlayerName, PlayerPosition); PlayerData jugadorNuevo = new PlayerData(PlayerName, PlayerPosition - 1); Callback.NewPlayerJoined(jugadorNuevo); foreach (Player PlayerRegistered in Table.getTable().playersRegistered) { PlayerData jugadorRegistrado = new PlayerData(PlayerRegistered.playerName, PlayerRegistered.tablePosition); PlayerRegistered.PlayerCallbackChannel.NewPlayerJoined(jugadorNuevo); Callback.NewPlayerJoined(jugadorRegistrado); //PlayerRegistered.PlayerCallbackChannel.NewPlayerJoined(PlayerName, PlayerPosition-1); //Callback.NewPlayerJoined(PlayerRegistered.playerName, PlayerRegistered.tablePosition); } if (Table.getTable().playersRegistered.Count == Table.getTable().GetMAX_PLAYERS() && !Table.getTable().gameHasStarted) { Table.getTable().StartGame(); } } catch (ExcepcionNombreRepetido) { Callback.PlayerNotSat("Ya hay un jugador sentado a la mesa con ese nombre"); } catch (ExcepcionMesaLlena) { Callback.PlayerNotSat("La mesa ya tiene todas las posiciones ocupadas"); } }