public void notifyHitMade(int gameId, ServiceCard movedCard) { Trace.WriteLine("SERVICE: notify hit made"); Game g = listOfGames.ElementAt(gameId - 1); g.Players[g.HitsIndex].CardsInHand -= 1; g.NrOfCardsOnTable += 1; Trace.WriteLine("SERVICE: cards on table " + g.NrOfCardsOnTable); if (g.Players[g.HitsIndex].CardsInHand == 0 && g.TopCardIndex <= 0) { g.Players[g.HitsIndex].Finished = true; if (isGameOver(gameId)) { for (int i = 0; i < g.Count; i++) { int looser = getNextActivePlayerIndex(g, g.HitsIndex); Subscriber s = getSubscriberById(g.Players[i].Id); IServiceCallback cb = s.callback; cb.OnGameOver(gameId, g.Players[looser].Id); } return; } else { for (int i = 0; i < g.Count; i++) { Subscriber s = getSubscriberById(g.Players[i].Id); IServiceCallback cb = s.callback; cb.OnPlayerFinished(gameId, g.Players[g.HitsIndex].Id); } } } if (g.NrOfCardsOnTable == 12) { setNextMoveAndHitId(gameId); for (int i = 0; i < g.Count; i++) { Subscriber s = getSubscriberById(g.Players[i].Id); IServiceCallback cb = s.callback; Trace.WriteLine("SERVICE: calling round over"); Trace.WriteLine("SERVICE: hit index" + g.HitsIndex + " moveIndex " + g.MovesIndex); cb.OnHitMade(movedCard, gameId, g.Players[g.HitsIndex].Id); cb.OnRoundOver(gameId, g.Players[g.MovesIndex].Id, g.Players[g.HitsIndex].Id); } } else { for (int i = 0; i < g.Count; i++) { Subscriber s = getSubscriberById(g.Players[i].Id); IServiceCallback cb = s.callback; cb.OnHitMade(movedCard, gameId, g.Players[g.HitsIndex].Id); } } }