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); }
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); }
/* * In the context of this method player1 has always win last game * */ public static void PlayOneDeal(Deck deck, Player player1, Player player2) { //we have to deal the cards. SixtySixUtil.DealCards(deck, player1, player2); int turnNumber = 1; do { if (!(player1.IsSilent && player2.IsSilent)) { Console.WriteLine("TURN: {0}", turnNumber++); Console.WriteLine("TRUMP: {0}!!! {1} cards in the deck.", deck.Cards.Count() > 0 ? deck.Cards.Last().ToString() : deck.TrumpSuit.ToString(), deck.Cards.Count()); Console.WriteLine("-" + player1.ToString() + " has " + player1.Score + " points"); Console.WriteLine("-" + player2.ToString() + " has " + player2.Score + " points"); Console.WriteLine(); } if (player1.HasWonLastHand) { MakeTurn(player1, player2, deck); if (SixtySixUtil.IsSixtySixReached(player1, player2)) { break; } } else if (player2.HasWonLastHand) { MakeTurn(player2, player1, deck); if (SixtySixUtil.IsSixtySixReached(player2, player1)) { break; } } if (!(player1.IsSilent && player2.IsSilent)) { Console.WriteLine("============================================================================="); } } while (player1.Cards.Count() > 0 && player2.Cards.Count() > 0); CardsDeckUtil.CollectCardsInDeck(deck, player1, player2); Console.Clear(); }