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()); }
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 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 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 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)); }
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 )); } }
public bool UnplayedCardsBeatPlayedCards(IPlayer thisPlayer, ITrick trick) { var unrevealedCards = GetUnrevealedCards(thisPlayer, trick); return(GameStateUtils.GetCardsThatCouldWin(trick, unrevealedCards).Any()); }
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()); }