/// <summary> /// Sends card to the game. Severely unreasonable approach /// </summary> /// <param name="cardMoved">card moved</param> /// <param name="playerId">playet that made the move</param> /// <param name="gameId">game in view</param> public void notifyMove(ServiceCard cardMoved, long playerId, int gameId) { Game g = listOfGames.ElementAt(gameId - 1); ServiceUser player = getUserById(gameId, playerId); player.CardsInHand -= 1; g.NrOfCardsOnTable += 1; if (player.CardsInHand == 0 && g.TopCardIndex <= 0) { player.Finished = true; if (isGameOver(gameId)) { for (int i = 0; i < g.Count; i++) { ServiceUser p = g.Players[i]; Subscriber s = getSubscriberById(p.Id); IServiceCallback cb = s.callback; cb.OnGameOver(gameId, g.Players[g.HitsIndex].Id); Trace.WriteLine("SERVICE: Calling back to notify Game Over!"); } return; } else { for (int i = 0; i < g.Count; i++) { ServiceUser p = g.Players[i]; Subscriber s = getSubscriberById(p.Id); IServiceCallback cb = s.callback; cb.OnPlayerFinished(gameId, playerId); Trace.WriteLine("SERVICE: Calling back to notify player finished!"); } } } for (int i = 0; i < g.Count; i++) { ServiceUser p = g.Players[i]; Subscriber s = getSubscriberById(p.Id); IServiceCallback cb = s.callback; cb.OnNotifyMove(cardMoved, gameId, playerId, g.Players[g.HitsIndex].Id);//seepärast peakski teenusele lisaks olema back endis veel üks klass Trace.WriteLine("SERVICE: Calling back to notify move done!"); } }