private static Card GiveRandomBasedCard(Player player, Deck deck, Card playedFromOther = null) { var rand = new Random(); if (playedFromOther != null) { if ((deck.Cards.Count() == 0 || deck.IsClosed) && SixtySixUtil.HasAnsweringCard(player, playedFromOther)) { var answeringCards = SixtySixUtil.GetHandAnsweringCards(player, playedFromOther); return(answeringCards[rand.Next(0, answeringCards.Count)]); } else { if (player.Cards.Count != 0) { return(player.Cards [rand.Next(player.Cards.Count)]); } else { return(SixtySixUtil.DrawCard(player, deck)); } } } else { return(player.Cards[rand.Next(0, player.Cards.Count)]); } }
private static void MakeTurn(Player player1, Player player2, Deck deck, Card cardOnTable) { var card = new Card(); var otherCard = new Card(); int handScore; //give card if (cardOnTable != null) { card = AIMovementUtil.MakeTurn(player1, player2, deck, cardOnTable); otherCard = cardOnTable; } else { card = AIMovementUtil.MakeTurn(player1, player2, deck, cardOnTable); //Check for additional point -> (20 or 40) //TODO Idea for modification: Player choose if he wants to call his announce. If has more than one announce can choose which one wants to play. if (SixtySixUtil.HasForty(player1.Cards, card, deck)) { SixtySixUtil.CallForty(player1); } else if (SixtySixUtil.HasTwenty(player1.Cards, card, deck)) { SixtySixUtil.CallTwenty(player1); } otherCard = AIMovementUtil.MakeTurn(player2, player1, deck, card); } handScore = (int)card.Value + (int)otherCard.Value; deck.ThrownCards.Add(card); deck.ThrownCards.Add(otherCard); // player1 plays first, so if first card wins, then the first player wins if (SixtySixUtil.WinsFirstCard(card, otherCard, deck.TrumpSuit)) { player1.Score += handScore; player1.HasWonLastHand = true; player2.HasWonLastHand = false; SixtySixUtil.DrawCard(player1, deck); SixtySixUtil.DrawCard(player2, deck); } else { player2.Score += handScore; player2.HasWonLastHand = true; player1.HasWonLastHand = false; SixtySixUtil.DrawCard(player2, deck); SixtySixUtil.DrawCard(player1, deck); } }