コード例 #1
0
ファイル: GameEngine.cs プロジェクト: vpechev/sixtysix
        /*
         * Itterative are deals been played until one of the players reach sixty six
         */
        public static Player PlaySixtySix(Player player1, Player player2)
        {
            var deck = CardsDeckUtil.InitializeDeck();

            player1.HasWonLastDeal = true;

            CardsDeckUtil.ShuffleDeck(deck); //we first shuffle the deck
            do
            {
                player1.ResetPlayerAfterDeal();
                player2.ResetPlayerAfterDeal();

                if (player1.HasWonLastDeal)
                {
                    var splitIndex = MovementUtil.GetDeckSplittingIndex(player2);
                    CardsDeckUtil.SplitDeck(deck, splitIndex); //one of the players should split the deck
                    player1.HasWonLastHand = true;
                    player2.HasWonLastHand = false;
                    PlayOneDeal(deck, player1, player2);
                }
                else if (player2.HasWonLastDeal)
                {
                    var splitIndex = MovementUtil.GetDeckSplittingIndex(player1);
                    CardsDeckUtil.SplitDeck(deck, splitIndex); //one of the players should split the deck
                    player2.HasWonLastHand = true;
                    player1.HasWonLastHand = false;
                    PlayOneDeal(deck, player2, player1);
                }
                else
                {
                    //Should not enter here
                    PlayOneDeal(deck, player1, player2);
                }
            }while (player1.WinsCount < Constants.TOTAL_PLAYS_FOR_WIN && player2.WinsCount < Constants.TOTAL_PLAYS_FOR_WIN);

            if (player1.WinsCount >= Constants.TOTAL_PLAYS_FOR_WIN)
            {
                if (!player1.IsSilent)
                {
                    Console.WriteLine("You has won!!! Result is: {0} to {1}.", player1.WinsCount, player2.WinsCount);
                }

                return(player1);
            }
            else
            {
                if (!player2.IsSilent)
                {
                    Console.WriteLine("AI player has won!!! Result is: {0} to {1}.", player2.WinsCount, player1.WinsCount);
                }
                return(player2);
            }
        }
コード例 #2
0
        public CardsBoardViewModel()
        {
            this.Player   = new PlayerViewModel(false);
            this.Opponent = new PlayerViewModel(true, PlayStrategy.MCTS);
            this.Deck     = CardsDeckUtil.InitializeDeck();
            CardsDeckUtil.ShuffleDeck(this.Deck);
            var player   = this.Player.ToPlayer();
            var opponent = this.Opponent.ToPlayer();

            SixtySixUtil.DealCards(this.Deck, player, opponent);
            this.Player   = PlayerViewModel.ConvertToPlayerViewModel(player);
            this.Opponent = PlayerViewModel.ConvertToPlayerViewModel(opponent);
        }