public override bool Equals(object obj) { HandAction handAction = obj as HandAction; if (handAction == null) { return(false); } return(handAction.ToString().Equals(ToString())); }
public override bool Equals(object obj) { HandAction handAction = obj as HandAction; if (handAction == null) { return(false); } return(this == handAction); }
private static HandAction GetAction(SiteActionRegexesBase siteActions, Street street, string actionText, string playerName) { HandActionType ActionType = ParseActionType(siteActions, street, actionText); decimal amount; if (ActionType == HandActionType.CHAT) { amount = 0m; } else if (ActionType == HandActionType.POSTS) { amount = ParseAmountPosts(siteActions, actionText); } else { amount = ParseAmount(siteActions, actionText); } if (ActionType == HandActionType.ALL_IN) { return new AllInAction(playerName, amount, street, true); } HandAction handAction = new HandAction(playerName, ActionType, amount, street); if (handAction.IsWinningsAction) { int potNumber; if (actionText.Contains(" main pot ")) potNumber = 0; else if (actionText.Contains(" side pot 1 ")) potNumber = 1; else if (actionText.Contains(" side pot ") == false) potNumber = 0; else throw new NotImplementedException("Can't do side pots for " + actionText); return new WinningsAction(playerName, ActionType, amount, potNumber); } return handAction; }
public static IEnumerable<HandAction> Street(this IEnumerable<HandAction> actions, HandAction action) { return actions.Where(p => p.Street == action.Street); }
public static IEnumerable<HandAction> Player(this IEnumerable<HandAction> actions, HandAction action) { return actions.Where(p => p.PlayerName == action.PlayerName); }
private List<HandAction> GetWinningAndShowCardActions(string[] handLines) { int actionNumber = Int32.MaxValue - 100; PlayerList playerList = ParsePlayers(handLines); List<HandAction> winningAndShowCardActions = new List<HandAction>(); foreach (Player player in playerList) { if (player.HoleCards.Count > 0) { HandAction showCardsAction = new HandAction(player.PlayerName, HandActionType.SHOW, 0, Street.Showdown, actionNumber++); winningAndShowCardActions.Add(showCardsAction); } } string[] playerLines = GetPlayerLinesFromHandLines(handLines); for (int i = 0; i < playerLines.Length; i++) { string playerLine = playerLines[i]; decimal winnings = GetWinningsFromPlayerLine(playerLine); if (winnings > 0) { string playerName = GetNameFromPlayerLine(playerLine); WinningsAction winningsAction = new WinningsAction(playerName, HandActionType.WINS, winnings, 0, actionNumber++); winningAndShowCardActions.Add(winningsAction); } } return winningAndShowCardActions; }
public static IEnumerable <WinningsAction> Player(this IEnumerable <WinningsAction> winners, HandAction action) { return(winners.Where(p => p.PlayerName == action.PlayerName)); }
private List<HandAction> FixDeadMoneyPosting(List<HandAction> actions) { // sort the actions, because regular SB + BB actions are always the first actions ( although might not be the first in the hand history ) actions = actions.OrderBy(t => t.ActionNumber).ToList(); var bigBlindValue = 0.0m; var looper = new List<HandAction>(actions); foreach (var action in looper) { if (action.HandActionType.Equals(HandActionType.BIG_BLIND)) { if (bigBlindValue == 0.0m) { bigBlindValue = Math.Abs(action.Amount); continue; } if (Math.Abs(action.Amount) > bigBlindValue) { var newAction = new HandAction(action.PlayerName, HandActionType.POSTS, action.Amount, action.Street, action.ActionNumber); actions.Remove(action); actions.Add(newAction); } } } return actions; }
public static IEnumerable <HandAction> Player(this IEnumerable <HandAction> actions, HandAction action) { return(actions.Where(p => p.PlayerName == action.PlayerName)); }
public static IEnumerable <HandAction> Street(this IEnumerable <HandAction> actions, HandAction action) { return(actions.Where(p => p.Street == action.Street)); }
/// <summary> /// Some sites (like IPoker) don't specifically identify All-In calls/raises. In these cases we need to parse the actions /// and reclassify certain actions as all-in /// </summary> protected List<HandAction> IdentifyAllInActions(string[] handLines, List<HandAction> handActions) { PlayerList playerList = ParsePlayers(handLines); Dictionary<string, decimal> playerStackRemaining = new Dictionary<string, decimal>(); foreach (Player player in playerList) { playerStackRemaining.Add(player.PlayerName, player.StartingStack); } List<HandAction> identifiedActions = new List<HandAction>(handActions.Count); foreach (HandAction action in handActions) { //Negative amounts represent putting money into the pot - ignore actions which aren't negative if (action.Amount >= 0) { identifiedActions.Add(action); continue; } //Skip actions which have already been identified if (action.IsAllIn) { identifiedActions.Add(action); continue; } //Update the remaining stack with our action's amount playerStackRemaining[action.PlayerName] += action.Amount; if (playerStackRemaining[action.PlayerName] == 0) { HandAction allInAction = new HandAction(action.PlayerName, action.HandActionType, action.Amount, action.Street, true); identifiedActions.Add(allInAction); } else { identifiedActions.Add(action); } } return identifiedActions; }