public static decimal GetFacingBetSizePot(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?.PlayerName == playerstatistic.Playerstatistic.PlayerName) { return(ONE_HUNDRED_PERCENTS * Math.Abs(betAction.Amount) / playerstatistic.HandHistory.HandActions.TakeWhile(x => x != heroAction).Sum(x => Math.Abs(x.Amount))); } } return(-1); }
/// <summary> /// Checks whenever the specified <see cref="PlayerstatisticExtended"/> matches the specified <see cref="NoteObject"/> /// </summary> /// <param name="note"><see cref="NoteObject"/> to match</param> /// <param name="playerstatistic"><see cref="PlayerstatisticExtended"/> to match</param> /// <returns>True if matches, otherwise - false</returns> public static bool IsMatch(NoteObject note, PlayerstatisticExtended playerstatistic) { var selectedPlayerStatistics = new List <PlayerstatisticExtended> { playerstatistic }; selectedPlayerStatistics = FilterByMiscConditions(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByPositionCondition(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByPreflopFacingCondition(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByPositionThreeBetCondition(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByPositionRaiserCondition(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByNoOfPlayerCondition(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByStakeCondition(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByHoleCardCondition(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByPreflopActionCondition(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByFlopActionCondition(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByTurnActionCondition(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByRiverActionCondition(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByFlopTextureCondition(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByTurnTextureCondition(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByRiverTextureCondition(selectedPlayerStatistics, note.Settings); selectedPlayerStatistics = FilterByHandValueConditions(selectedPlayerStatistics, note.Settings.FlopHvSettings, Street.Flop); selectedPlayerStatistics = FilterByHandValueConditions(selectedPlayerStatistics, note.Settings.TurnHvSettings, Street.Turn); selectedPlayerStatistics = FilterByHandValueConditions(selectedPlayerStatistics, note.Settings.RiverHvSettings, Street.River); selectedPlayerStatistics = FilterByAllSelectedFilters(selectedPlayerStatistics, note.Settings.SelectedFilters, note.Settings.SelectedFiltersComparison); return(selectedPlayerStatistics.Count > 0); }
public IEnumerable <Playernotes> ProcessHand(IEnumerable <NoteObject> notes, Playerstatistic stats, HandHistory handHistory) { if (!licenseService.IsRegistered) { return(null); } var matchInfo = new GameMatchInfo { GameType = handHistory.GameDescription.GameType, CashBuyIn = !handHistory.GameDescription.IsTournament ? Utils.ConvertToCents(handHistory.GameDescription.Limit.BigBlind) : 0, TournamentBuyIn = handHistory.GameDescription.IsTournament ? handHistory.GameDescription.Tournament.BuyIn.PrizePoolValue : 0 }; if (!Limit.IsMatch(matchInfo)) { return(null); } var playernotes = new List <Playernotes>(); foreach (var note in notes) { var playerstatistic = new PlayerstatisticExtended { Playerstatistic = stats, HandHistory = handHistory }; if (NoteManager.IsMatch(note, playerstatistic)) { var playerCardsText = string.IsNullOrEmpty(playerstatistic.Playerstatistic.Cards) ? string.Empty : $"[{playerstatistic.Playerstatistic.Cards}]"; var playerNote = new Playernotes { PlayerId = stats.PlayerId, PokersiteId = (short)stats.PokersiteId, Note = $"=[{note.ParentStageType}]= {note.DisplayedNote}", CardRange = note.Settings.IncludeBoard && !string.IsNullOrEmpty(playerCardsText) && !string.IsNullOrEmpty(playerstatistic.Playerstatistic.Board) ? $"{playerCardsText}({playerstatistic.Playerstatistic.Board})" : playerCardsText, IsAutoNote = true, GameNumber = handHistory.HandId, Timestamp = handHistory.DateOfHandUtc }; playernotes.Add(playerNote); } } return(playernotes); }
public static bool WasRaisedAnalyzer(PlayerstatisticExtended playerstatistic, Street targetStreet) { HandAction raiseAction = playerstatistic.HandHistory.HandActions.Where(x => x.Street == targetStreet) .FirstOrDefault(x => x.HandActionType == HandActionType.RAISE); if (raiseAction == null || raiseAction.PlayerName == playerstatistic.Playerstatistic.PlayerName) { return(false); } return(playerstatistic.HandHistory.HandActions.Where(x => x.Street == targetStreet) .SkipWhile(x => x != raiseAction).Skip(1) .Any(x => x.PlayerName == playerstatistic.Playerstatistic.PlayerName)); }
public static bool WasBetIntoAnalyzer(PlayerstatisticExtended playerstatistic, Street targetStreet) { HandAction betAction = playerstatistic.HandHistory.HandActions.Where(x => x.Street == targetStreet) .FirstOrDefault(x => x.HandActionType == HandActionType.BET); if (betAction == null || betAction.PlayerName == playerstatistic.Playerstatistic.PlayerName) { return(false); } return(playerstatistic.HandHistory.HandActions.Where(x => x.Street == targetStreet) .SkipWhile(x => x != betAction).Skip(1) .Any(x => x.PlayerName == playerstatistic.Playerstatistic.PlayerName)); }
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); }
//here is possible: a player makes check then hero makes bet then a player makes raise and hero is facing raise public static decimal GetFacingRaiseSizePot(PlayerstatisticExtended playerstatistic, Street targetStreet) { if (targetStreet == Street.Flop || targetStreet == Street.Turn || targetStreet == Street.River) { HandAction raiseAction = playerstatistic.HandHistory.HandActions.Where(x => x.Street == targetStreet) .FirstOrDefault(x => x.IsRaise()); if (raiseAction == null || raiseAction.PlayerName == playerstatistic.Playerstatistic.PlayerName) { return(-1); } HandAction heroAction = playerstatistic.HandHistory.HandActions.Where(x => x.Street == targetStreet) .SkipWhile(x => x != raiseAction) .FirstOrDefault(x => x != raiseAction && x.HandActionType != HandActionType.FOLD || x.PlayerName == playerstatistic.Playerstatistic.PlayerName); if (heroAction?.PlayerName == playerstatistic.Playerstatistic.PlayerName) { return(ONE_HUNDRED_PERCENTS * Math.Abs(raiseAction.Amount) / playerstatistic.HandHistory.HandActions.TakeWhile(x => x != heroAction).Sum(x => Math.Abs(x.Amount))); } } //calculations in this part are different from flop, turn or river. //here we take first hero action facing, excluding hero actions as BB or SB if (targetStreet == Street.Preflop) { if (playerstatistic.Playerstatistic.FacingPreflop == EnumFacingPreflop.Raiser) { return(ONE_HUNDRED_PERCENTS * Math.Abs(playerstatistic.HandHistory.HandActions.FirstOrDefault(x => x.IsRaise()).Amount) / playerstatistic.HandHistory.HandActions.TakeWhile(x => !x.IsRaise()).Sum(x => Math.Abs(x.Amount))); } } return(-1); }
public static decimal StackPotRatio(PlayerstatisticExtended playerstatistic, Street targetStreet) { List <HandAction> streetActions = playerstatistic.HandHistory.HandActions.Where(x => x.Street == targetStreet).ToList(); List <string> playerNames = streetActions.GroupBy(x => x.PlayerName).Select(x => x.Key).ToList(); if (playerNames.All(x => x != playerstatistic.Playerstatistic.PlayerName)) { return(0); } decimal potAmount = 0; switch (targetStreet) { case Street.Flop: potAmount = Math.Abs(playerstatistic.HandHistory.HandActions.Where(x => x.Street == Street.Preflop).Sum(x => x.Amount)); break; case Street.Turn: potAmount = Math.Abs(playerstatistic.HandHistory.HandActions.Where(x => x.Street == Street.Preflop).Sum(x => x.Amount)) + Math.Abs(playerstatistic.HandHistory.HandActions.Where(x => x.Street == Street.Flop).Sum(x => x.Amount)); break; case Street.River: potAmount = Math.Abs(playerstatistic.HandHistory.HandActions.Where(x => x.Street == Street.Preflop).Sum(x => x.Amount)) + Math.Abs(playerstatistic.HandHistory.HandActions.Where(x => x.Street == Street.Flop).Sum(x => x.Amount)) + Math.Abs(playerstatistic.HandHistory.HandActions.Where(x => x.Street == Street.Turn).Sum(x => x.Amount)); break; } decimal playerPutInAmount = 0; List <decimal> playerStreetStackAmount = new List <decimal>(); foreach (string player in playerNames) { switch (targetStreet) { case Street.Flop: playerPutInAmount = Math.Abs(playerstatistic.HandHistory.HandActions.Where(x => x.Street == Street.Preflop && x.PlayerName == player).Sum(x => x.Amount)); break; case Street.Turn: playerPutInAmount = Math.Abs(playerstatistic.HandHistory.HandActions.Where(x => x.Street == Street.Preflop && x.PlayerName == player).Sum(x => x.Amount)) + Math.Abs(playerstatistic.HandHistory.HandActions.Where(x => x.Street == Street.Flop && x.PlayerName == player).Sum(x => x.Amount)); break; case Street.River: playerPutInAmount = Math.Abs(playerstatistic.HandHistory.HandActions.Where(x => x.Street == Street.Preflop && x.PlayerName == player).Sum(x => x.Amount)) + Math.Abs(playerstatistic.HandHistory.HandActions.Where(x => x.Street == Street.Flop && x.PlayerName == player).Sum(x => x.Amount)) + Math.Abs(playerstatistic.HandHistory.HandActions.Where(x => x.Street == Street.Turn && x.PlayerName == player).Sum(x => x.Amount)); break; } var playerHand = playerstatistic.HandHistory.Players.FirstOrDefault(x => x.PlayerName == player); if (playerHand == null) { return(0); } playerStreetStackAmount.Add(playerHand.StartingStack - playerPutInAmount); } decimal effectiveStackSize = playerStreetStackAmount.Min(); if (potAmount != 0) { return(effectiveStackSize / potAmount); } return(0); }