コード例 #1
0
        //================================================================================================================
        //================================================================================================================
        #endregion  // Home

        #region Card Shuffler
        //================================================================================================================
        //================================================================================================================

        public ActionResult CardShuffler()
        //================================================================================================================
        // This action is invoked when the card shuffler page is requested.
        //
        // Event Arguments
        //      arg_CardPackId: Unique id of the selected card pack
        //
        // Returns
        //      The card shuffler page view
        //================================================================================================================
        {
            // Safety check for the server
            if ((bool)Session[SiteHelpers.ServerRunning] == false)
            {
                return(View("ServerNotRunning", new PokerPlayground()));
            }

            // Retrieve the selected card pack
            int cardPackId = !string.IsNullOrEmpty(Request.Params[ARG_CARD_PACK_ID]) ? int.Parse(Request.Params[ARG_CARD_PACK_ID]) : 0;

            // Create the model
            CardShuffler model = new CardShuffler();

            // Populate the model
            SSCasino_DBContext dbCasino = null;

            try
            {
                // Connect the the database
                dbCasino = new SSCasino_DBContext();

                // Get a card pack for the card shuffler
                // Load the shuffler control panel with card packs
                model.CardPack = CreateCardPackModel(dbCasino, cardPackId, SiteHelpers.SampleSizes.FullDeck);
                LoadShufflerCards(dbCasino, model.ControlPanel, cardPackId);
            }
            finally
            {
                if (dbCasino != null)
                {
                    dbCasino.Dispose();
                }
            }

            return(View("CardShuffler", model));
        }
コード例 #2
0
        static void Main(string[] args)
        {
            List <Card>         deck         = GenerateDeck();
            CardShuffler <Card> cardShuffler = new CardShuffler <Card>(deck);

            double[] playersPoints = { 0, 0, 0, 0 };

            int maxIt = 5;

            for (int it = 0; it < maxIt; it++)
            {
                deck = cardShuffler.Shuffle();

                List <List <Card> > decks = cardShuffler.GiveCardsToPlayers(deck);
                Console.WriteLine("Game {0}/{1}", it + 1, maxIt);
                for (int i = 0; i < decks.Count; i++)
                {
                    playersPoints[i] += (double)CalculatePoints(decks[i]) / maxIt;

                    /*foreach(Card card in decks[i])
                     * {
                     *  Console.WriteLine(card.ToString());
                     * }
                     * Console.WriteLine();*/
                    Console.WriteLine("Player {0} => points : {1}", i + 1, CalculatePoints(decks[i]));
                }

                Console.WriteLine("");
            }

            Console.WriteLine("Average game points after {0} attempts", maxIt);
            for (int i = 0; i < 4; i++)
            {
                Console.WriteLine("Player {0}: {1} points per game", i + 1, Math.Round(playersPoints[i], 2));
            }
            Console.ReadKey();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            TextReader       inputReader                = Console.In;
            IGameInterface   gameInterface              = new GameInterface(NUMBER_OF_CARDS_IN_HAND);
            ICardShuffler    shuffler                   = new CardShuffler();
            ICardDealer      cardDealer                 = new CardDealer(NUMBER_OF_CARDS_IN_DECK, shuffler);
            ICardMapper      cardMapper                 = new CardMapper();
            ICardMapperForUI cardMapperForUI            = new CardMapperForUI();
            Hand             hand                       = new Hand(NUMBER_OF_CARDS_IN_HAND);
            IEvaluator       evaluator                  = new Evaluator(cardMapper);
            CombinationNameAndPayoutMapper resultMapper = new CombinationNameAndPayoutMapper();

            Game game = new Game(
                inputReader,
                gameInterface,
                cardDealer,
                cardMapper,
                cardMapperForUI,
                hand,
                evaluator,
                resultMapper);

            game.PlayGame();
        }
コード例 #4
0
        /// <summary>
        /// Randomly shuffle the cards on a card deck for a game.
        /// </summary>
        private void ShuffleCards()
        {
            CardShuffler cardShuffler = new CardShuffler();

            cardShuffler.ShuffleCards(_cardDeckDTO.Cards);
        }