Beispiel #1
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);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a random deck of cards excluding dog, dragon, phoenix, mahjong
        /// </summary>
        public static TichuDeck CreateWithoutSpecials()
        {
            List <TichuCard> drawPool = new List <TichuCard>();

            for (int suit = 0; suit < 4; suit++)
            {
                for (int rank = 0; rank < 13; rank++)
                {
                    TichuCard c = new TichuCard((CardSuit)suit, (CardRank)rank);
                    drawPool.Add(c);
                }
            }
            TichuDeck deck   = new TichuDeck(drawPool);
            Random    random = new Random();

            for (int i = 0; i < 52; i++)
            {
                int randomCard = random.Next(drawPool.Count);
                deck._deck.Push(drawPool[randomCard]);
                drawPool.RemoveAt(randomCard);
            }

            return(deck);
        }
Beispiel #3
0
 public TichuGameState(TichuDeck deck, Random random)
 {
     RemainingCards = new HashSet <TichuCard>(deck.Cards);
     _random        = random;
 }