Exemplo n.º 1
0
 public static int GetDeckSplittingIndex(Player player)
 {
     if (player.IsAIPlayer)
     {
         return(AIMovementUtil.GetDeckSplittingIndex());
     }
     else
     {
         return(InputPlayerMovementUtil.GetDeckSplittingIndex());
     }
 }
Exemplo n.º 2
0
        private bool HandleEndOfDeal(PlayerViewModel player, PlayerViewModel opponent, Deck deck)
        {
            if (player.HasWonLastHand && player.Score >= Constants.TOTAL_SCORE)
            {
                deck.IsEndOfGame = true;

                var enginePlayer   = player.ToPlayer();
                var engineOpponent = opponent.ToPlayer();
                CardsDeckUtil.CollectCardsInDeck(deck, enginePlayer, engineOpponent);

                player.Cards = new ObservableCollection <CardViewModel>();

                player.WinsCount     += SixtySixUtil.GetNumberOfWins(opponent.ToPlayer());
                player.Score          = 0;
                opponent.Score        = 0;
                this.TrumpCard        = null;
                player.SelectedCard   = null;
                opponent.SelectedCard = null;

                player.HasWonLastDeal   = true;
                opponent.HasWonLastDeal = false;
                player.ThrownCards      = new ObservableCollection <CardViewModel>();
                opponent.Cards          = new ObservableCollection <CardViewModel>();
                opponent.ThrownCards    = new ObservableCollection <CardViewModel>();


                if (enginePlayer.HasWonLastDeal)
                {
                    var splitIndex = AIMovementUtil.GetDeckSplittingIndex();
                    CardsDeckUtil.SplitDeck(deck, splitIndex); //one of the players should split the deck
                    SixtySixUtil.DealCards(deck, engineOpponent, enginePlayer);
                }
                else if (engineOpponent.HasWonLastDeal)
                {
                    //TODO Get User Input
                    var splitIndex = 10;                       //MovementUtil.GetDeckSplittingIndex(engineOpпonent);
                    CardsDeckUtil.SplitDeck(deck, splitIndex); //one of the players should split the deck
                    SixtySixUtil.DealCards(deck, enginePlayer, engineOpponent);
                }

                player   = PlayerViewModel.ConvertToPlayerViewModel(enginePlayer);
                opponent = PlayerViewModel.ConvertToPlayerViewModel(engineOpponent);

                player.Messages   = "WIN";
                opponent.Messages = "LOSE";

                return(true);
            }
            return(false);
        }