Exemplo n.º 1
0
        static SixNimmtGameState CreateNewGame(Random random, double[] scores, bool proMode)
        {
            SixNimmtDeck      deck  = SixNimmtDeck.Create(random);
            SixNimmtGameState state = SixNimmtGameState.Create(random, deck, PlayerCount, proMode);

            if (scores != null)
            {
                state.SetInitialScores(scores);
            }

            for (int player = 0; player < PlayerCount; player++)
            {
                for (int i = 0; i < 10; i++)
                {
                    state.DealCard(player, deck.DealCard());
                }
            }

            state.SetCurrentPlayer(0);

            // Give each row a starting card
            for (int i = 0; i < SixNimmtGameState.BoardRowCount; i++)
            {
                state.AddStartingCard(i, deck.DealCard());
            }

            return(state);
        }
Exemplo n.º 2
0
 public static SixNimmtGameState Create(Random random, SixNimmtDeck deck, int playerCount, bool proMode)
 {
     return(new SixNimmtGameState(new SharedState()
     {
         Random = random, PlayerCount = playerCount, ProMode = proMode
     }, deck));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a random deck of cards excluding dog, dragon, phoenix, mahjong
        /// </summary>
        public static SixNimmtDeck Create(Random random)
        {
            int[] unshuffled = new int[DeckSize];
            for (int i = 0; i < DeckSize; i++)
            {
                unshuffled[i] = i + 1;
            }
            SixNimmtDeck deck = new SixNimmtDeck(unshuffled);

            deck.Shuffle(random);

            return(deck);
        }
Exemplo n.º 4
0
        static SixNimmtGameState CreateNewGame(Random random, double[] scores, bool proMode)
        {
            SixNimmtDeck      deck  = SixNimmtDeck.Create(random);
            SixNimmtGameState state = SixNimmtGameState.Create(random, deck, PlayerCount, proMode);

            if (scores != null)
            {
                state.SetInitialScores(scores);
            }

            // Get pov player's hand
            while (true)
            {
                Console.WriteLine("Enter hand (ie, '1 3 43 104')");
                string   handInput  = Console.ReadLine();
                string[] handInputs = handInput.Split(" ");
                if (handInputs.Length != 10)
                {
                    Console.WriteLine($"Enter 10 cards. I counted {handInputs.Length}");
                    continue;
                }

                for (int i = 0; i < handInputs.Length; i++)
                {
                    state.DealCard(0, int.Parse(handInputs[i]));
                }
                break;
            }

            state.SetCurrentPlayer(0);

            while (true)
            {
                Console.WriteLine("Enter starting row cards top to bottom (ie, '43 32 45 98')");
                string   rowsInput  = Console.ReadLine();
                string[] rowsInputs = rowsInput.Split(" ");
                if (rowsInputs.Length != SixNimmtGameState.BoardRowCount)
                {
                    Console.WriteLine($"Enter {SixNimmtGameState.BoardRowCount} cards. I counted {rowsInputs.Length}");
                    continue;
                }

                for (int i = 0; i < SixNimmtGameState.BoardRowCount; i++)
                {
                    state.AddStartingCard(i, int.Parse(rowsInputs[i]));
                }
                break;
            }

            return(state);
        }
Exemplo n.º 5
0
 private SixNimmtGameState(SharedState sharedState, SixNimmtDeck deck)
 {
     PlayInputState = SixNimmtInputState.SelectCard;
     _sharedState   = sharedState;
     _board         = new int[BoardRowCount][];
     for (int row = 0; row < BoardRowCount; row++)
     {
         _board[row] = new int[MaxCardsPerRow];
     }
     _scores = new int[PlayerCount];
     for (int i = 0; i < _scores.Length; i++)
     {
         _scores[i] = StartingScore;
     }
     _boardRowCounts = new int[BoardRowCount];
     PlayerCards     = new List <int> [PlayerCount];
     for (int i = 0; i < PlayerCards.Length; i++)
     {
         PlayerCards[i] = new List <int>();
     }
     _remainingCards = new HashSet <int>(deck.Cards);
 }