public static Winner CmpCards(CardCollection cards1, CardCollection cards2, CompareSuitType type) { // FIXME: assert cards1.size == cards2.size var size = cards1.Size; if (size == 0) { return(Winner.NoWin); } Winner cmp(CompareSuitType t) { for (uint cardIndex = size - 1; cardIndex >= 0; cardIndex--) { var card1 = cards1.At(cardIndex); var card2 = cards2.At(cardIndex); var result = CmpCard(card1, card2, t); if (result != Winner.NoWin) { return(result); } } return(Winner.NoWin); } var r = cmp(CompareSuitType.NoneCompareSuit); if (r != Winner.NoWin) { return(r); } return(cmp(type)); }
public static int GetScoreBySuit(CardSuit suit, CompareSuitType type) { switch (type) { case CompareSuitType.NoneCompareSuit: return(0); case CompareSuitType.HeartsDiamondsClubsSpades: return(HeartsDiamondsClubsSpadesSuit[(int)suit.Index]); case CompareSuitType.SpadesDiamondsClubsHearts: return(SpadesDiamondsClubsHeartsSuit[(int)suit.Index]); } return(0); }
public static Winner CmpCard(Card card1, Card card2, CompareSuitType type) { if (card1.Rank == card2.Rank) { switch (type) { case CompareSuitType.NoneCompareSuit: return(Winner.NoWin); default: var suitScore1 = GetScoreBySuit(card1.Suit, type); var suitScore2 = GetScoreBySuit(card2.Suit, type); return(suitScore1 > suitScore2 ? Winner.Player1 : Winner.Player2); } } else { return(card1.Rank > card2.Rank ? Winner.Player1 : Winner.Player2); } }
public void SetCompareSuitType(CompareSuitType type) { _compareSuitType = type; }
public static Winner CmpCardsUnknownHands(CardCollection cards1, CardCollection cards2, CompareSuitType type) { var size = Math.Min(cards1.Size, cards2.Size); if (size == 0) { return(Winner.NoWin); } for (uint cardIndex = size - 1; cardIndex >= 0; cardIndex--) { var card1 = cards1.At(cardIndex); var card2 = cards2.At(cardIndex); var result = CmpCard(card1, card2, type); if (result != Winner.NoWin) { return(result); } } if (cards1.Size == cards2.Size) { return(Winner.NoWin); } return(cards1.Size > cards2.Size ? Winner.Player1 : Winner.Player2); }
public static bool CheckMissSetHand(CardCollection hand1, CardCollection hand2, CardCollection hand3, CompareSuitType type) { return(false); }
/// <summary> /// So sánh 2 chi /// </summary> public static Winner CmpHands(CardCollection hand1, CardCollection hand2, PokerHand hand, CompareSuitType type) { return(Winner.NoWin); }
/// <summary> /// So sánh cù lũ /// </summary> public static Winner CmpFullHouses(CardCollection cards1, CardCollection cards2, CompareSuitType type) { return(Winner.NoWin); }