public static HandCardResult GetHandCardResult(HandCard handCard) { HandCardResult result = new HandCardResult(); for (int i = 0; i < _judgeList.Count; i++) { JudgeFunction judgeFunction = _judgeList[i]; int cardNumLimit = judgeFunction.CardNumLimit; if ((cardNumLimit != 0) && (cardNumLimit != handCard.Count)) { continue; } if (judgeFunction.Fun.Invoke(handCard)) { result.Level = judgeFunction.Level; result.Odds = judgeFunction.Odds; if (judgeFunction.Odds == 0) { result.Odds = CaculateOdds(judgeFunction.Level, handCard); } break; } } // list.Count == 2是因为获取hash时需要OnesDigit if ((handCard.Count == 2) || (result.Level >= CardLevel.onesDigitIsZero)) { result.OnesDigit = handCard.OnesDigit; } return(result); }
private static bool IsOnesDigitIsZero(HandCard handCard) { if (handCard.JokerCount != 0) { return(false); } return(handCard.OnesDigit == 0); }
private static bool IsTianGongEight(HandCard handCard) { if (handCard.JokerCount != 0) { return(false); } return(handCard.OnesDigit == 8); }
public static void Get(List <Card> cardList, out HandCardResult result) { int hash = GetHash(cardList); if (!_dict.ContainsKey(hash)) { Wrapper wrapper = new Wrapper(); HandCard handCard = new HandCard(cardList); HandCardResult handCardResult = CardLevelJudgement.GetHandCardResult(handCard); wrapper.Result = handCardResult; _dict.Add(hash, wrapper); } result = _dict[hash].Result; }
public static LogKind GetLogKind(HandCard handCard) { LogKind result = LogKind.other; for (int i = 0; i < _judgeFunciontList.Count; i++) { JudgeFunction judgeFunction = _judgeFunciontList[i]; if (judgeFunction.Fun.Invoke(handCard)) { result = judgeFunction.Kind; break; } } return(result); }
private static int CaculateOdds(CardLevel level, HandCard handCard) { int result = 1; if (level == CardLevel.onesDigitIsZero) { result = 10; } if (handCard.IsSamePoint) { result = result * 2; } else if (handCard.IsSameKind) { result = result * handCard.Count; } return(result); }
private static bool IsNormal(HandCard handCardt) { return(true); }
private static bool IsStraight(HandCard handCard) { return(handCard.IsStraight); }
private static bool IsThreeCardWithSamePoint(HandCard handCard) { return(handCard.IsSamePoint); }
private static bool IsStraightFlush(HandCard handCard) { return(handCard.IsSameKind && handCard.IsStraight); }
private static bool IsOther(HandCard handCard) { return(true); }
private static bool IsTwoJoker(HandCard handCard) { return(handCard.IsTwoJoker); }
private static bool IsSameKind(HandCard handCard) { return(handCard.IsSameKind); }
private static bool IsStraightPossible2(HandCard handCard) { return(handCard.IsStraightPossible2); }
private static bool IsStraightPossible2AndSameKind(HandCard handCard) { return(handCard.IsSameKind && handCard.IsStraightPossible2); }
private static bool IsOneJoker(HandCard handCard) { return(handCard.JokerCount == 1); }
private static bool IsInvalid(HandCard handCard) { return(handCard.IsInvalid); }
private static bool IsThreeCardWithTwoJoker(HandCard handCard) { return(handCard.JokerCount == 2); }