コード例 #1
0
        public GameView(Durak game, int id)
        {
            this.game = game;
            variation = game.variation;

            List <Player> players = game.GetPlayers();

            playerID = id;
            hand     = players[id].GetPlayersHand();

            if (prevDiscardedHeapValue != discardHeapSize)
            {
                discardHeapChanged = true;
            }
            prevDiscardedHeapValue = discardHeapSize;

            PlayerView        playerView;
            List <PlayerView> pViews = new List <PlayerView>();


            for (int i = 0; i < game.GetSizeOfPlayers(); i++)
            {
                playerView = new PlayerView();

                playerView.numberOfCards = players[i].GetNumberOfCards();
                playerView.isAttacking   = (attackingPlayer == i);
                playerView.playerState   = players[i].playerState;
                playerView.passport      = players[i].passport;

                if (players[i].playerState == PlayerState.Winner)
                {
                    passportGameOver = true;
                }

                if (variation == Variation.Passport && players[i].CheckIfAllCardsPassport())
                {
                    playerView.allCardsPassport = true;
                }

                pViews.Add(playerView);
            }
            playersView = pViews;

            trumpCard = deckSize == 0 ? new Card(game.GetTrumpCard().suit, (Rank)5)
                                       : game.GetTrumpCard();

            attackingCards = game.GetBoutInformation().GetAttackingCards();
            defendingCards = game.GetBoutInformation().GetDefendingCards();

            takingCards = game.GetPlayer(defendingPlayer).IsPlayerTaking();

            playerTurn = game.GetPlayersTurn();
            gameStatus = game.gameStatus;
        }