Esempio n. 1
0
        public Deck(GameType gt)
        {
            CardQueue = new Queue <ICard>();
            int len;

            if (gt == GameType.FiveColor)
            {
                len = 50;
            }
            else
            {
                len = 55;
            }
            int[] seq = new int[len];
            for (int i = 0; i < len; i++)
            {
                seq[i] = i;
            }
            for (int i = 1; i < len; ++i)
            {
                Utily.Swap <int>(ref seq[i], ref seq[Utily.Next() % (i + 1)]);
            }
            int mv = 0;

            while (CardBad(seq[mv]))
            {
                ++mv;
            }
            for (int j = 0; j < len; j++)
            {
                int i = (j + mv) % len;
                if (seq[i] >= 50)
                {
                    CardQueue.Enqueue(new Card(5, seq[i] - 49, gt));
                }
                else
                {
                    int color = seq[i] / 10;
                    int num   = seq[i] % 10;
                    if (num <= 2)
                    {
                        num = 1;
                    }
                    else if (num == 9)
                    {
                        num = 5;
                    }
                    else
                    {
                        num = (num + 1) / 2;
                    }
                    CardQueue.Enqueue(new Card(color, num, gt));
                }
            }
        }
Esempio n. 2
0
        public Game(GameType gt, int CountPlayers)
        {
            this.CountPlayers    = CountPlayers;
            this.CurrentGameType = gt;
            this.GameDeck        = new Deck(gt);
            CurrentPlayer        = Utily.Next() % CountPlayers;
            Players = new IPlayer[CountPlayers];
            if (CountPlayers == 3)
            {
                CardsOnHand = 5;
            }
            else
            {
                CardsOnHand = 4;
            }
            for (int i = 0; i < CountPlayers; ++i)
            {
                Players[i] = new Player();
                for (int j = 0; j < CardsOnHand; ++j)
                {
                    Players[i].TakeCard(GameDeck.GetNext());
                }
            }
            CountHints = 8;
            CountFall  = 0;
            Result     = 0;
            GameIsEnd  = false;
            int countColors = 6;

            if (gt == GameType.FiveColor)
            {
                countColors = 5;
            }
            Table      = new int[countColors];
            DropsCards = new List <ICard>();
            Story      = new GameStory();
        }