public void IncrementHandsContainingRank(ERankType rank, int incr) { IncrementHandsContainingCardIndex(CardToIndex(new Card(rank, ESuitType.SuitClubs)), incr); IncrementHandsContainingCardIndex(CardToIndex(new Card(rank, ESuitType.SuitHearts)), incr); IncrementHandsContainingCardIndex(CardToIndex(new Card(rank, ESuitType.SuitSpades)), incr); IncrementHandsContainingCardIndex(CardToIndex(new Card(rank, ESuitType.SuitDiamonds)), incr); }
public bool SendMsgRankSystemGC2GMReqGetRankData(ERankType type, CBMsgRankSystemGC2GMReqGetRankData cb) { CMsgRankSystemGC2GMReqGetRankData msgReq = new CMsgRankSystemGC2GMReqGetRankData(type); CMsgRankSystemGM2GCAckGetRankData.s_cb = cb; return(CGameClient.Singleton.SendMsg(msgReq)); }
IsStraightFlush(ref int numSubRanks, ref ERankType[] subRank) { // These are required parameters, but can be ignored var flushNumSubRanks = 0; var flushSubRank = new ERankType[5]; return(IsStraight(ref numSubRanks, ref subRank) && IsFlush(ref flushNumSubRanks, ref flushSubRank)); }
private static IEnumerable <ConsoleLine> Card(ERankType rank, ESuitType suit, int startingX, int startingY) { var rankSymbol = GetRankSymbol(rank); var isDouble = rankSymbol.Length > 1; var cardColor = GetSuitColor(suit); return(new List <ConsoleLine> { new ConsoleLine(startingX, startingY, rankSymbol + (isDouble ? " " : " "), cardColor, ConsoleColor.White), new ConsoleLine(startingX, startingY + 1, " " + GetSuitSymbol(suit) + " ", cardColor, ConsoleColor.White), new ConsoleLine(startingX, startingY + 2, (isDouble ? " " : " ") + rankSymbol, cardColor, ConsoleColor.White) }); }
private static string GetRankSymbol(ERankType rank) { switch (rank) { case ERankType.RankTwo: return("2"); case ERankType.RankThree: return("3"); case ERankType.RankFour: return("4"); case ERankType.RankFive: return("5"); case ERankType.RankSix: return("6"); case ERankType.RankSeven: return("7"); case ERankType.RankEight: return("8"); case ERankType.RankNine: return("9"); case ERankType.RankTen: return("10"); case ERankType.RankJack: return("J"); case ERankType.RankQueen: return("Q"); case ERankType.RankKing: return("K"); case ERankType.RankAce: return("A"); case ERankType.RankUnknown: return(" "); default: throw new ArgumentOutOfRangeException("rank", rank, null); } }
public static string RankToString(ERankType Rank) { switch (Rank) { case ERankType.RankAce: return("A"); case ERankType.RankKing: return("K"); case ERankType.RankQueen: return("Q"); case ERankType.RankJack: return("J"); case ERankType.RankTen: return("T"); case ERankType.RankNine: return("9"); case ERankType.RankEight: return("8"); case ERankType.RankSeven: return("7"); case ERankType.RankSix: return("6"); case ERankType.RankFive: return("5"); case ERankType.RankFour: return("4"); case ERankType.RankThree: return("3"); case ERankType.RankTwo: return("2"); default: return("?"); } }
protected override bool _SerializeFrom(UnityUtility.CStream msgStream) { byte result = msgStream.ReadByte(); m_result = (EGetRankDataResult)result; if (m_result == EGetRankDataResult.EGET_RANK_DATA_RESULT_SUCCESS) { byte rankType = msgStream.ReadByte(); m_rankType = (ERankType)rankType; UInt16 count = msgStream.ReadUShort(); for (Int16 i = 0; i < count; ++i) { CRankData data = new CRankData(); data.SerializeFrom(msgStream); m_listRankData.Add(data); } } return(true); }
IsFullHouse(ref int numSubRanks, ref ERankType[] subRank) { var threesNumSubRanks = 0; var threesSubRank = new ERankType[5]; var pairNumSubRanks = 0; var pairSubRank = new ERankType[5]; if (IsThrees(ref threesNumSubRanks, ref threesSubRank) && IsPair(ref pairNumSubRanks, ref pairSubRank)) { numSubRanks = 2; subRank[0] = threesSubRank[0]; subRank[1] = pairSubRank[0]; return(true); } return(false); }
IsStraightFlush(ref int numSubRanks, ref ERankType[] subRank) { // These are required parameters, but can be ignored var flushNumSubRanks = 0; var flushSubRank = new ERankType[5]; return IsStraight(ref numSubRanks, ref subRank) && IsFlush(ref flushNumSubRanks, ref flushSubRank); }
public Card(ERankType pRank, ESuitType pSuit) { Rank = pRank; Suit = pSuit; }
private bool IsPair(ref int numSubRanks, ref ERankType[] subRank) { ERankType currRank; numSubRanks = 4; for (currRank = 0; (int)currRank < 13; currRank++) { if (_rankCount[(int)currRank] == 2) { subRank[0] = currRank; var currSubRank = 1; int currCard; for (currCard = 0; currCard < 5; currCard++) { if (_cards[currCard].Rank != subRank[0]) { subRank[currSubRank] = _cards[currCard].Rank; currSubRank++; } } return true; } } return false; }
private bool IsTwoPair(ref int numSubRanks, ref ERankType[] subRank) { ERankType currRank; var highPairRank = ERankType.RankUnknown; var lowPairRank = ERankType.RankUnknown; var oddCardRank = ERankType.RankUnknown; var pairCount = 0; numSubRanks = 3; for (currRank = 0; (int)currRank < 13; currRank++) { if (_rankCount[(int)currRank] == 2) { pairCount++; if (highPairRank != ERankType.RankUnknown) { lowPairRank = highPairRank; } highPairRank = currRank; } else if (_rankCount[(int)currRank] == 1) { oddCardRank = currRank; } } if (pairCount == 2) { subRank[0] = highPairRank; subRank[1] = lowPairRank; subRank[2] = oddCardRank; return true; } return false; }
private bool IsStraight(ref int numSubRanks, ref ERankType[] subRank) { int i; var lowRank = ERankType.RankUnknown; var highRank = ERankType.RankUnknown; numSubRanks = 1; // if more than one card of the same rank // then it is not a straight for (i = 0; i < 13; i++) { if (_rankCount[i] > 1) { return false; } // Determine highest and lowest ranked cards in hand here if (_rankCount[i] == 1) { highRank = (ERankType)Enum.ToObject(typeof(ERankType), i); if (lowRank == ERankType.RankUnknown) { lowRank = (ERankType)Enum.ToObject(typeof(ERankType), i); } } } subRank[0] = highRank; // If the highest and lowest rank cards are within a spread of 5 cards, // and there are no pairs, then it must be straight if (highRank - lowRank == 4) { return true; } // Check for Ace low straight here (special case as my code usually treats Ace as high) if ((lowRank == ERankType.RankTwo) && (highRank == ERankType.RankAce)) { // Got Ace and Two // Check for any 6's -> K's. (If any then no straight) for (i = (int)ERankType.RankSix; i <= (int)ERankType.RankKing; i++) { if (_rankCount[i] > 0) { return false; } } // This is a 5 high straight subRank[0] = ERankType.RankFive; return true; } return false; }
private bool IsFlush(ref int numSubRanks, ref ERankType[] subRank) { int i; numSubRanks = 5; for (i = 0; i < 4; i++) { if ((_suitCount[i] != 0) && (_suitCount[i] != 5)) { return false; } } for (i = 0; i < 5; i++) { subRank[i] = _cards[i].Rank; } return true; }
IsFullHouse(ref int numSubRanks, ref ERankType[] subRank) { var threesNumSubRanks = 0; var threesSubRank = new ERankType[5]; var pairNumSubRanks = 0; var pairSubRank = new ERankType[5]; if (IsThrees(ref threesNumSubRanks, ref threesSubRank) && IsPair(ref pairNumSubRanks, ref pairSubRank)) { numSubRanks = 2; subRank[0] = threesSubRank[0]; subRank[1] = pairSubRank[0]; return true; } return false; }
public void Evaluate() { CurrentBestHand = Hand.FindPlayersBestHand(HoleCards.CardList, Board); IsStraightDraw = false; IsFlushDraw = false; IsStraightFlushDraw = false; RanksToMakeStraight = new List <ERankType>(); List <Card> cards = new List <Card>(); cards.AddRange(HoleCards.CardList); cards.AddRange(Board.ToList()); // Check for flush draw _rankCount = new int[13]; _suitCount = new int[4]; // count how many of each rank and suit foreach (Card c in cards) { _rankCount[(int)c.Rank]++; _suitCount[(int)c.Suit]++; } //if at least 4 in same suit then flush draw for (int i = 0; i < 4; i++) { if (_suitCount[i] >= 4) { IsFlushDraw = true; SuitToMakeFlush = (ESuitType)i; } } // if 4 cards in a 5 card range then straight draw for (ERankType rank = ERankType.RankFive; rank <= ERankType.RankAce; rank++) { int numInRange = 0; ERankType rankNotInRange = ERankType.RankUnknown; for (int j = 0; j < 5; j++) { ERankType currRank; if (rank - j < 0) { currRank = ERankType.RankAce; } else { currRank = rank - j; } if (_rankCount[(int)currRank] > 0) { numInRange++; } else { rankNotInRange = currRank; } } if (numInRange == 4) { IsStraightDraw = true; RanksToMakeStraight.Add(rankNotInRange); } } }
private bool IsFours(ref int numSubRanks, ref ERankType[] subRank) { int currRank; numSubRanks = 2; for (currRank = 0; currRank < 13; currRank++) { if (_rankCount[currRank] == 4) { subRank[0] = (ERankType)Enum.ToObject(typeof(ERankType), currRank); int currCard; for (currCard = 0; currCard < 5; currCard++) { if (_cards[currCard].Rank != subRank[0]) { subRank[1] = _cards[currCard].Rank; return true; } } } } return false; }
public CMsgRankSystemGC2GMReqGetRankData(ERankType type) : base(CServerType.SRVTYPE_GAMESERVER, CFuncType.EFUNCTYPE_RANKSYSTEM, CRankSystemMsgNumID.EMSGNUMID_RANKSYSTEM_GC2GM_REQ_GET_RANK_DATA) { m_rankType = type; }