public void dealRound(int gameId) { Game g = listOfGames.ElementAt(gameId - 1); Subscriber sb = GetMe(); Trace.WriteLine("SEVICE: dealRound called by " + sb.nickname); if (sb.Id == g.Players[0].Id) { for (int i = 0; i < g.Count; i++) { List <ServiceCard> cards = new List <ServiceCard>(); int index = (g.Count - g.MovesIndex - i) % g.Count; ServiceUser u = g.Players[index]; while (u.CardsInHand < 6 && g.TopCardIndex >= 0) { cards.Add(g.Deck[g.TopCardIndex]); g.TopCardIndex -= 1; u.CardsInHand += 1; } Subscriber s = getSubscriberById(u.Id); IServiceCallback cb = s.callback; Trace.WriteLine("SEVICE: calling onDeal after dealRound "); Trace.WriteLine("SEVICE: calling to " + s.nickname + " with id " + g.Players[index].Id); Trace.WriteLine("SEVICE: sending " + cards.Count + " cards"); cb.OnDeal(cards.ToArray(), g.Deck[0], g.Players[index].Id, gameId); } } }
public void dealCards(int gameid) { Subscriber me = GetMe(); Trace.WriteLine("SERVICE: Dealing card !!!"); Game g = listOfGames.ElementAt(gameid - 1); int deckIndex = g.Deck.Length - 1; for (int i = 0; i < g.Count; i++) { ServiceCard[] cards = new ServiceCard[6]; for (int j = 0; j < 6; j++) { cards[j] = g.Deck[deckIndex]; deckIndex = deckIndex - 1; } ServiceUser p = g.Players[i]; p.CardsInHand = 6; Subscriber s = getSubscriberById(p.Id); IServiceCallback cb = s.callback; Trace.WriteLine("SERVICE: Calling callback "); Trace.WriteLine("SERVICE: Calling player " + s.nickname); Trace.WriteLine("SERVICE: Subscribers " + subscrbers.Count); cb.OnDeal(cards, g.Deck[0], g.Players[i].Id, g.Id); Trace.WriteLine("SERVICE: Calling back done!"); } g.TopCardIndex = deckIndex; Trace.WriteLine("SERVICE: deal done!"); }