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()); }
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()); }
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()); } } }
public SheepCard GiveAwayPoints(IPlayer thisPlayer, ITrick trick) { return(thisPlayer.Cards .Where(c => trick.IsLegalAddition(c, thisPlayer)) .OrderByDescending(c => CardUtil.GetPoints(c)) .First()); }
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()); }
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); }
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]); } }
public bool ICanWinTrick(IPlayer thisPlayer, ITrick trick) { var playableCards = thisPlayer.Cards.Where(c => trick.IsLegalAddition(c, thisPlayer)); return(GameStateUtils.GetCardsThatCouldWin(trick, playableCards).Any()); }
public bool CanIWin(IPlayer thisPlayer, ITrick trick) { var legalCards = thisPlayer.Cards.Where(c => trick.IsLegalAddition(c, thisPlayer)).ToList(); return(GameStateUtils.GetCardsThatCouldWin(trick, legalCards).Any()); }
public override SheepCard GetMove(ITrick trick) { return(this.Cards.First(c => trick.IsLegalAddition(c, this))); }