Exemplo n.º 1
0
        static void PrintHands()
        {
            var hands   = game.Players.Select(p => p.Hand.ToArray());
            var forTurn = game.Players.Select(p => game.GetCardsForTurn(p.Id)).ToArray();

            int max     = hands.Max(h => h.Length);
            var players = game.Players.Select(p => $"{$"Player{p.Id}", 16}");

            Console.WriteLine(string.Join("", players));

            for (int i = 0; i < max; i++)
            {
                var set = hands
                          .Select(h => h.Length > i ? h[i] : null)
                          .Select((c, j) => $"{c,16} {(forTurn[j].Contains(c) ? "+" : " ")}");

                Console.WriteLine(string.Join("", set));
            }
        }
Exemplo n.º 2
0
 public GameStateHolder GetState(int playerId)
 {
     return(new GameStateHolder
     {
         Trump = _game.Trump.ToString(),
         GameState = _game.State.ToString(),
         DeckCount = _game.Deck.Count,
         IsAttack = _game.IsAttack,
         IsInitialAttack = _game.IsInitialAttack,
         DefenderId = _game.Players[_game.DefenderIndex].Id,
         AttackerId = _game.Players[_game.InitialAttacker].Id,
         Role = _game.GetPlayerRole(playerId),
         Players = _players,
         Hand = _game.Players.First(p => p.Id == playerId).Hand.Select(c => new NamedCard(c)),
         CardsForTurn = _game.GetCardsForTurn(playerId).Select(c => new NamedCard(c)),
         Attacks = _game.Attacks.Select(a => (new NamedCard(a.Attacker), new NamedCard(a.Defender)))
     });