Ejemplo n.º 1
0
        public void Deal(PlayerRegister reg)
        {
            string[]  animal_type   = { "bat", "fly", "cocktail", "toad", "rat", "scorpion", "spider", "bug" };
            ArrayList TotalCardList = new ArrayList();

            for (int i = 0; i < 8; i++)
            {
                for (int t = 0; t < 8; t++)
                {
                    TotalCardList.Add(new Card(animal_type[i]));
                }
            }
            int mod        = TotalCardList.Count % reg.Count();
            int cards_each = (TotalCardList.Count - mod) / reg.Count();

            foreach (KeyValuePair <string, Player> pair in reg.dictionary)
            {
                for (int i = 0; i < cards_each; i++)
                {
                    int index = rnd.Next(0, TotalCardList.Count);
                    pair.Value.handcard.Add(TotalCardList[index]);
                    TotalCardList.RemoveAt(index);
                }
            }
            if (mod != 0)
            {
                foreach (KeyValuePair <string, Player> pair in reg.dictionary)
                {
                    if (TotalCardList.Count == 0)
                    {
                        break;
                    }
                    int index = rnd.Next(0, TotalCardList.Count);
                    pair.Value.handcard.Add(TotalCardList[index]);
                    TotalCardList.RemoveAt(index);
                }
            }
        }
Ejemplo n.º 2
0
        public void Deal(PlayerRegister reg)
        {
            string[] animal_type = { "bat", "fly", "cocktail", "toad", "rat", "scorpion", "spider", "bug" };
            ArrayList TotalCardList = new ArrayList();
            for (int i = 0; i < 8; i++)
            {
                for (int t = 0; t < 8; t++)
                {
                    TotalCardList.Add(new Card(animal_type[i]));
                }
            }
            int mod = TotalCardList.Count % reg.Count();
            int cards_each = (TotalCardList.Count - mod) / reg.Count();
            foreach (KeyValuePair<string, Player> pair in reg.dictionary)
            {

                for (int i = 0; i < cards_each; i++)
                {
                    int index = rnd.Next(0, TotalCardList.Count);
                    pair.Value.handcard.Add(TotalCardList[index]);
                    TotalCardList.RemoveAt(index);
                }
            }
            if (mod != 0)
            {
                foreach (KeyValuePair<string, Player> pair in reg.dictionary)
                {
                    if (TotalCardList.Count == 0)
                        break;
                    int index = rnd.Next(0, TotalCardList.Count);
                    pair.Value.handcard.Add(TotalCardList[index]);
                    TotalCardList.RemoveAt(index);
                }
            }
        }