예제 #1
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());
        }
예제 #2
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());
        }
예제 #3
0
 private SheepCard GetLeadMove(ITrick trick)
 {
     if (trick.IHand.Picker == this || IamPartner(trick))
     {
         return(Cards
                .Where(c => trick.IsLegalAddition(c, this))
                .OrderBy(c => CardUtil.GetSuit(c) == Suit.TRUMP ? 1 : 2)
                .FirstOrDefault());
     }
     else
     {
         if (trick.IHand.IGame.PartnerMethodEnum == PartnerMethod.CalledAce && trick.IHand.PartnerCardEnum.HasValue)
         {
             var partnerCardSuit = CardUtil.GetSuit(trick.IHand.PartnerCardEnum.Value);
             return(Cards
                    .OrderBy(c => CardUtil.GetSuit(c) == partnerCardSuit ? 1 : 2)
                    .FirstOrDefault());
         }
         else
         {
             return(Cards
                    .OrderBy(c => CardUtil.GetSuit(c) != Suit.TRUMP ? 1 : 2)
                    .FirstOrDefault());
         }
     }
 }
예제 #4
0
 public SheepCard GiveAwayPoints(IPlayer thisPlayer, ITrick trick)
 {
     return(thisPlayer.Cards
            .Where(c => trick.IsLegalAddition(c, thisPlayer))
            .OrderByDescending(c => CardUtil.GetPoints(c))
            .First());
 }
예제 #5
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());
        }
예제 #6
0
        public bool UnplayedCardsBeatMyCards(IPlayer thisPlayer, ITrick trick)
        {
            var playableCards           = thisPlayer.Cards.Where(c => trick.IsLegalAddition(c, thisPlayer));
            var unrevealedCards         = GetUnrevealedCards(thisPlayer, trick);
            var startSuit               = CardUtil.GetSuit(trick.CardsByPlayer.First().Value);
            var strongestUnrevealedCard = GetStrongestCard(unrevealedCards, startSuit);
            var strongestOfMyCards      = GetStrongestCard(playableCards, startSuit);
            var strongestCard           = GetStrongestCard(new List <SheepCard>()
            {
                strongestUnrevealedCard, strongestOfMyCards
            }, startSuit);

            return(strongestCard == strongestUnrevealedCard);
        }
예제 #7
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]);
            }
        }
예제 #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());
        }
예제 #10
0
 public override SheepCard GetMove(ITrick trick)
 {
     return(this.Cards.First(c => trick.IsLegalAddition(c, this)));
 }