public static string ActionToString(HandAction action) { if (action is StreetAction) { return(","); } if (action.IsRaise()) { return("R"); } if (action.IsCall()) { return("C"); } if (action.IsBet()) { return("B"); } if (action.HandActionType == HandActionType.FOLD) { return("F"); } if (action.HandActionType == HandActionType.CHECK) { return("X"); } return(string.Empty); }
private static string GetPlayersActionString(HandAction action, decimal putInThisStreet) { var resultString = string.Empty; var handActionType = action is AllInAction allInAction ? allInAction.SourceActionType : action.HandActionType; switch (handActionType) { case HandActionType.SMALL_BLIND: resultString = "SB"; break; case HandActionType.BIG_BLIND: resultString = "BB"; break; case HandActionType.FOLD: return("Folds"); case HandActionType.CHECK: return("Checks"); case HandActionType.CALL: resultString = "Calls"; break; case HandActionType.RAISE: resultString = "Raises To"; break; case HandActionType.BET: resultString = "Bets"; break; case HandActionType.POSTS: resultString = "Posts Ante"; break; } var amount = action.IsRaise() ? Math.Abs(putInThisStreet) : Math.Abs(action.Amount); var amountString = amount % 1 == 0 ? amount.ToString("F0") : amount.ToString("F2"); resultString = $"{resultString} ${amountString}"; if (action.IsAllInAction || action.IsAllIn) { return($"{resultString} (allin)"); } return(resultString); }
public bool CheckAction(HandAction action) { Faced = true; if (action.HandActionType == HandActionType.FOLD) { Folded = true; return(true); } if (action.IsCall()) { Called = true; return(true); } if (action.IsRaise()) { Raised = true; return(true); } return(false); }
public static decimal GetFacingBetAndDidRaiseSizePot(PlayerstatisticExtended playerstatistic, Street targetStreet) { if (targetStreet == Street.Flop || targetStreet == Street.Turn || targetStreet == Street.River) { HandAction betAction = playerstatistic.HandHistory.HandActions.Where(x => x.Street == targetStreet) .SkipWhile(x => !x.IsBet()) .TakeWhile(x => x.PlayerName != playerstatistic.Playerstatistic.PlayerName) .LastOrDefault(x => x.IsBet() || x.IsRaise()); if (betAction == null || betAction.PlayerName == playerstatistic.Playerstatistic.PlayerName) { return(-1); } HandAction heroAction = playerstatistic.HandHistory.HandActions.Where(x => x.Street == targetStreet) .SkipWhile(x => x != betAction) .FirstOrDefault(x => x != betAction && x.HandActionType != HandActionType.FOLD || x.PlayerName == playerstatistic.Playerstatistic.PlayerName); if (heroAction != null && heroAction.PlayerName == playerstatistic.Playerstatistic.PlayerName && heroAction.IsRaise()) { return(ONE_HUNDRED_PERCENTS * Math.Abs(heroAction.Amount) / playerstatistic.HandHistory.HandActions.TakeWhile(x => x != heroAction).Sum(x => Math.Abs(x.Amount))); } } // no bet here just check if facing limpers or unopened if (targetStreet == Street.Preflop) { HandAction raiseAction = null; if (playerstatistic.Playerstatistic.FacingPreflop == EnumFacingPreflop.Limper || playerstatistic.Playerstatistic.FacingPreflop == EnumFacingPreflop.MultipleLimpers || playerstatistic.Playerstatistic.FacingPreflop == EnumFacingPreflop.Unopened) { raiseAction = playerstatistic.HandHistory.HandActions.FirstOrDefault(x => x.Street == Street.Preflop && x.IsRaise()); } if (raiseAction != null && raiseAction.PlayerName == playerstatistic.Playerstatistic.PlayerName) { return(ONE_HUNDRED_PERCENTS * Math.Abs(raiseAction.Amount) / playerstatistic.HandHistory.HandActions.TakeWhile(x => x != raiseAction).Sum(x => Math.Abs(x.Amount))); } } return(-1); }