public override string ToString() { switch (Rank) { case HandRank.FourOfAKind: return("4 of a kind"); case HandRank.FullHouse: return("Full House"); case HandRank.HighCard: return("High Card"); case HandRank.RoyalFlush: return("Royal Flush"); case HandRank.StraightFlush: return("Straight Flush"); case HandRank.ThreeOfAKind: return("3 of a kind"); case HandRank.TwoPair: return("Two Pair"); default: return(Rank.ToString()); } }
/** * Register rules that is pre-defined * * @param {HandRank} ruleName name of the rule */ public static void RegisterRules(HandRank ruleName) { if (!ALLRULES.Contains(ruleName)) { throw new InvalidPokerRuleException(ruleName.ToString()); } else if (!rules.Contains(ruleName)) { rules.Add(ruleName); } }
void ShowRanks() { Instructions.SetActive(false); Instructions2.SetActive(false); Hand1Text.gameObject.SetActive(true); Hand1Text.text = player1Rank.ToString(); Hand2Text.gameObject.SetActive(true); Hand2Text.text = player2Rank.ToString(); }
override public string ToString() { string str = rank.ToString(); str += ": "; if (rank == HandRank.HighCard) { str += Card.RankToString(primaryRank) + ", " + Card.RankToString(secondRank) + ", " + Card.RankToString(kicker1Rank) + ", " + Card.RankToString(kicker2Rank) + ", " + Card.RankToString(kicker3Rank); } if (rank == HandRank.OnePair) { str += Card.RankToString(primaryRank) + ", " + Card.RankToString(kicker1Rank) + ", " + Card.RankToString(kicker2Rank) + ", " + Card.RankToString(kicker3Rank); } if (rank == HandRank.TwoPair) { str += Card.RankToString(primaryRank) + ", " + Card.RankToString(secondRank) + ", " + Card.RankToString(kicker1Rank); } if (rank == HandRank.Trips) { str += Card.RankToString(primaryRank) + ", " + Card.RankToString(kicker1Rank) + ", " + Card.RankToString(kicker2Rank); } if (rank == HandRank.Straight) { str += Card.RankToString(primaryRank) + ", " + Card.RankToString(secondRank) + ", " + Card.RankToString(kicker1Rank) + ", " + Card.RankToString(kicker2Rank) + ", " + Card.RankToString(kicker3Rank); } if (rank == HandRank.Flush) { str += Card.RankToString(primaryRank) + ", " + Card.RankToString(secondRank) + ", " + Card.RankToString(kicker1Rank) + ", " + Card.RankToString(kicker2Rank) + ", " + Card.RankToString(kicker3Rank); } if (rank == HandRank.FullHouse) { str += Card.RankToString(primaryRank) + ", " + Card.RankToString(secondRank); } if (rank == HandRank.Poker) { str += Card.RankToString(primaryRank) + ", " + Card.RankToString(kicker1Rank); } if (rank == HandRank.SFlush) { str += Card.RankToString(primaryRank) + ", " + Card.RankToString(secondRank) + ", " + Card.RankToString(kicker1Rank) + ", " + Card.RankToString(kicker2Rank) + ", " + Card.RankToString(kicker3Rank); } return(str); }
/// <summary> /// Convert notation of enum HankdRank as used in C# to what needs to be written to string (convert CamelCasing to /// something-with-dashes-and-lower-case-only) /// </summary> /// <param name="rank"></param> /// <returns></returns> public static string ToRankString(this HandRank rank) { return(RegEx.Replace(rank.ToString(), "-$1").ToLower().Substring(1)); }