コード例 #1
0
        public IGameState <Play> Clone()
        {
            TichuGameState clonedState = new TichuGameState();

            clonedState.CurrentPlayerTurn     = CurrentPlayerTurn;
            clonedState.PlayedCards           = new HashSet <TichuCard>(PlayedCards);
            clonedState.RemainingCards        = new HashSet <TichuCard>(RemainingCards);
            clonedState.RemainingPlayoutCards = new HashSet <TichuCard>(RemainingPlayoutCards);
            clonedState.Players = new TichuPlayerState[PlayerCount];
            for (int i = 0; i < PlayerCount; i++)
            {
                clonedState.Players[i] = Players[i].Clone();
            }
            Array.Copy(_tricks, clonedState._tricks, _tricks.Length);
            clonedState._currentTrick      = new List <Play>(_currentTrick);
            clonedState._playHistory       = new List <Play>(_playHistory);
            clonedState._random            = _random;
            clonedState._pointOfViewPlayer = _pointOfViewPlayer;
            return(clonedState);
        }
コード例 #2
0
        public static TichuGameState SetupFourPlayerGame(Random random)
        {
            TichuDeck      deck      = TichuDeck.CreateWithoutSpecials();
            TichuGameState gameState = new TichuGameState(deck, random);

            gameState.SetCurrentPlayer(random.Next(4));
            gameState.Players = new TichuPlayerState[4];
            for (int i = 0; i < 4; i++)
            {
                gameState.Players[i] = new TichuPlayerState();
            }

            int player = 0;

            while (deck.Count > 0)
            {
                gameState.Players[player].Cards.Add(deck.DealCard());
                player = (player + 1) % 4;
            }

            return(gameState);
        }