/// <summary> /// Converts the given Hand with absolute ratios into a Hand with relative ratios /// It assumes all Players of the Hand were sorted previously /// </summary> /// <param name="sortedAquiredHand">Hand to be converted</param> /// <returns>Converted Hand</returns> public IConvertedPokerHand ConvertAquiredHand(IAquiredPokerHand sortedAquiredHand) { if (sortedAquiredHand == null) { Log.Debug("AquiredHand was null, returning null"); return(null); } if (sortedAquiredHand.TotalPlayers < 2 || sortedAquiredHand.TotalPlayers > 10) { Log.DebugFormat("AquiredHand had {0} players.\n<{1}>", sortedAquiredHand.TotalPlayers, sortedAquiredHand); return(null); } // At this point Players are already sorted according to their Positions // Now parse through the hand and create the relative actions // Start w/ SB except for Preflop try { // First we just need to call the big blind double toCall = sortedAquiredHand.BB; double theoreticalStartingPot = sortedAquiredHand.BB + sortedAquiredHand.SB + (sortedAquiredHand.Ante * sortedAquiredHand.TotalPlayers); // This could be different from the theoretical starting pot if a player // posted out of line (like from middle position) -> the actual pot at the beginning // of the hand will be bigger than the theoretical pot double pot = RemovePostingActionsAndCalculatePotAfterPosting(ref sortedAquiredHand); // PokerOffice sometimes didn't store posting Actions // This will ignore Ante though if (pot <= 0) { pot = theoreticalStartingPot; } IConvertedPokerHand convertedHand = _convertedHandMake.New .InitializeWith(sortedAquiredHand) .AddPlayersFrom(sortedAquiredHand, theoreticalStartingPot, _convertedPlayerMake); convertedHand = _pokerRoundsConverter .InitializeWith(sortedAquiredHand, convertedHand, pot, toCall) .ConvertPreflop() .ConvertFlopTurnAndRiver(); convertedHand .RemoveInactivePlayers() .SetNumOfPlayersInEachRound() .AdjustOrderOfPlayersIfItIsHeadsUp() .SetWhoHasPositionInEachRound(); foreach (var player in convertedHand) { player.SetActionSequencesAndBetSizeKeysFromSequenceStrings(); } return(convertedHand); } catch (Exception excep) { Log.Error("Unhandled", excep); return(null); } }