private List <Card> getWinnableCards(Spades spades) { Card leadCard = spades.getBestPlayedCard(); if (leadCard == null) { return(spades.getPlayableCards(playerIndex)); } List <Card> winCards = new List <Card>(); List <Card> playableCards = spades.getPlayableCards(playerIndex); foreach (Card card in playableCards) { if (spades.isOtherCardBetter(leadCard, card)) { winCards.Add(card); } } return(winCards); }
private Card getLowestPlayableCard(Spades spades) { List <Card> playableCards = spades.getPlayableCards(playerIndex); Card lowest = playableCards[0]; foreach (Card card in playableCards) { if (!spades.isOtherCardBetter(lowest, card)) { lowest = card; } } return(lowest); }
private bool canWinTrick(Spades spades) { Card leadCard = spades.getBestPlayedCard(); if (leadCard == null) { return(true); } List <Card> playableCards = spades.getPlayableCards(playerIndex); foreach (Card card in playableCards) { if (spades.isOtherCardBetter(leadCard, card)) { return(true); } } return(false); }