Пример #1
0
        public SheepCard PlayStrongestLoosingCard(IPlayer thisPlayer, ITrick trick)
        {
            var legalCards    = thisPlayer.Cards.Where(c => trick.IsLegalAddition(c, thisPlayer));
            var winnableCards = GameStateUtils.GetCardsThatCouldWin(trick, legalCards);

            return(legalCards.Except(winnableCards).OrderBy(c => CardUtil.GetRank(c)).First());
        }
Пример #2
0
        public SheepCard PlayWeakestWin(IPlayer thisPlayer, ITrick trick)
        {
            var legalCards    = thisPlayer.Cards.Where(c => trick.IsLegalAddition(c, thisPlayer));
            var winnableCards = GameStateUtils.GetCardsThatCouldWin(trick, legalCards);

            return(winnableCards.OrderByDescending(c => CardUtil.GetRank(c)).First());
        }
Пример #3
0
        public bool CanILoose(IPlayer thisPlayer, ITrick trick)
        {
            var legalCards     = thisPlayer.Cards.Where(c => trick.IsLegalAddition(c, thisPlayer)).ToList();
            var winnableCards  = GameStateUtils.GetCardsThatCouldWin(trick, legalCards).ToList();
            var looseableCards = legalCards.Except(winnableCards);

            return(looseableCards.Any());
        }
Пример #4
0
        public SheepCard PlaySecondStrongestLoosingCard(IPlayer thisPlayer, ITrick trick)
        {
            var legalCards    = thisPlayer.Cards.Where(c => trick.IsLegalAddition(c, thisPlayer));
            var winnableCards = GameStateUtils.GetCardsThatCouldWin(trick, legalCards);
            var cards         = legalCards.Except(winnableCards).OrderBy(c => CardUtil.GetRank(c)).ToList();

            if (cards.Count == 1)
            {
                return(cards.Single());
            }
            else
            {
                return(cards[1]);
            }
        }
Пример #5
0
        public bool MySideWinning(IPlayer thisPlayer, ITrick trick)
        {
            var winningPlay = GameStateUtils.GetWinningPlay(trick);

            if (trick.IHand.Picker == thisPlayer)
            {
                return(winningPlay.Key == trick.IHand.PresumedParnter);
            }
            if (PlayerKnowsSelfToBePartner(thisPlayer, trick))
            {
                return(winningPlay.Key == trick.IHand.Picker);
            }
            return(winningPlay.Key != trick.IHand.Picker &&
                   winningPlay.Key != trick.IHand.PresumedParnter &&
                   !(trick.IHand.PartnerCardEnum.HasValue && trick.IHand.PresumedParnter == null));
        }
Пример #6
0
        public static IEnumerable <SheepCard> GetCardsThatCouldWin(ITrick trick, IEnumerable <SheepCard> comparisonCards)
        {
            if (!trick.CardsByPlayer.Any())
            {
                return(comparisonCards);
            }
            var startSuit       = CardUtil.GetSuit(trick.CardsByPlayer.First().Value);
            var winningCard     = GameStateUtils.GetWinningPlay(trick).Value;
            var winningCardRank = CardUtil.GetRank(winningCard);

            if (CardUtil.GetSuit(winningCard) == Suit.TRUMP)
            {
                return(comparisonCards.Where(c => CardUtil.GetRank(c) < winningCardRank));
            }
            else
            {
                return(comparisonCards.Where(c =>
                                             CardUtil.GetSuit(c) == Suit.TRUMP ||
                                             CardUtil.GetSuit(c) == startSuit && CardUtil.GetRank(c) < winningCardRank
                                             ));
            }
        }
Пример #7
0
        public bool UnplayedCardsBeatPlayedCards(IPlayer thisPlayer, ITrick trick)
        {
            var unrevealedCards = GetUnrevealedCards(thisPlayer, trick);

            return(GameStateUtils.GetCardsThatCouldWin(trick, unrevealedCards).Any());
        }
Пример #8
0
        public bool ICanWinTrick(IPlayer thisPlayer, ITrick trick)
        {
            var playableCards = thisPlayer.Cards.Where(c => trick.IsLegalAddition(c, thisPlayer));

            return(GameStateUtils.GetCardsThatCouldWin(trick, playableCards).Any());
        }
Пример #9
0
        public bool CanIWin(IPlayer thisPlayer, ITrick trick)
        {
            var legalCards = thisPlayer.Cards.Where(c => trick.IsLegalAddition(c, thisPlayer)).ToList();

            return(GameStateUtils.GetCardsThatCouldWin(trick, legalCards).Any());
        }