Exemplo n.º 1
0
        private void DeterminizeModules(int player)
        {
            // Save other player hand sizes and shuffle them into the deck
            var handSizeDict = new Dictionary <int, int>(GameConstants.PlayerCount - 1);

            foreach (var otherPlayer in Players.Where(p => p.ID != player))
            {
                handSizeDict[otherPlayer.ID] = otherPlayer.Hand.Count;
                Deck.AddRange(otherPlayer.Hand);
                otherPlayer.Hand = new List <Module>();
            }

            // Shuffle the deck
            Deck.Shuffle();

            int i = 0;

            // Deal modules into other players' hands according to their previous hand sizes
            foreach (var entry in handSizeDict)
            {
                for (int j = 0; j < entry.Value; j++)
                {
                    Players[entry.Key - 1].Hand.Add(Deck[i]);
                    i++;
                }
            }
            Deck.RemoveRange(0, i);
        }