public void ConvertPreflop_Player1IsSmallBlind__SetsSequencesCorrectly() { RelativeRatioResult result = ConvertPreflopThreePlayersHand(); IConvertedPokerHand convHand = result.ConvertedHand; IConvertedPokerPlayer smallBlindPlayer = convHand[0]; IConvertedPokerPlayer bigBlindPlayer = convHand[1]; IConvertedPokerPlayer buttonPlayer = convHand[2]; var action1 = new ConvertedPokerActionWithId(buttonPlayer[Streets.PreFlop][0], buttonPlayer.Position); var action2 = new ConvertedPokerActionWithId( smallBlindPlayer[Streets.PreFlop][0], smallBlindPlayer.Position); var action3 = new ConvertedPokerActionWithId(bigBlindPlayer[Streets.PreFlop][0], bigBlindPlayer.Position); var action4 = new ConvertedPokerActionWithId(buttonPlayer[Streets.PreFlop][1], buttonPlayer.Position); var action5 = new ConvertedPokerActionWithId( smallBlindPlayer[Streets.PreFlop][1], smallBlindPlayer.Position); var action6 = new ConvertedPokerActionWithId(bigBlindPlayer[Streets.PreFlop][1], bigBlindPlayer.Position); IConvertedPokerRound expectedPreflopSequence = new ConvertedPokerRound() .Add(action1) .Add(action2) .Add(action3) .Add(action4) .Add(action5) .Add(action6); Assert.That(expectedPreflopSequence, Is.EqualTo(convHand.Sequences[(int)Streets.PreFlop])); }
public void Insert(IConvertedPokerHand convHand) { // Don't insert if null or hand contains no players if ((convHand != null) && (convHand.Players.Count > 0)) { try { if (!HandIsAlreadyInDatabase(convHand.Site, convHand.GameId)) { bool successfullyUpdatedGameTable = UpdateGameTable(convHand); if (successfullyUpdatedGameTable) { int handId = _databaseUtility .Use(_dataProvider) .GetIdentityOfLastInsertedHand(); // dd all active players in the hand to the Action Table foreach (IConvertedPokerPlayer convPlayer in convHand) { int playerId = GetPlayerID(convHand, convPlayer); UpdateActionTable(handId, playerId, convPlayer); } } } } catch (Exception excep) { Log.Error("Unexpected", excep); } } }
IConvertedPokerHand CreateHandFromDatabase(int handId) { // Hand Header string query = string.Format( "SELECT * FROM {0} WHERE {1} = {2};", Tables.gamehhd, GameTable.identity, handId); using (IDataReader dr = _dataProvider.ExecuteQuery(query)) { if (dr.Read()) { try { IConvertedPokerHand convertedPokerHand = ExtractHandHeader(handId, dr); ExtractNumberOfPlayersInEachRound(convertedPokerHand, dr); ExtractSequencesForEachRound(convertedPokerHand, dr); return(convertedPokerHand); } catch (Exception excep) { Log.Error("Unexpected", excep); } } } return(null); }
void ExtractNamesForAllPlayers(IConvertedPokerHand convHand) { foreach (IConvertedPokerPlayer convPlayer in convHand) { convPlayer.Name = GetPlayerNameFromId(convPlayer.PlayerId); } }
IConvertedPokerHand ExtractHandHeader(int handId, IDataRecord dr) { DateTime timeStamp = DateTime.Parse(dr[(int)GameTable.timein].ToString()); ulong gameId = ExtractGameId(dr); double bb = ExtractBigBlind(dr); double sb = ExtractSmallBlind(dr); int totalPlayers = ExtractTotalPlayers(dr); ulong tournamentId = ExtractTournamentId(dr); IConvertedPokerHand convertedHand = _convertedHandMake.New .InitializeWith( dr[GameTable.site.ToString()].ToString(), gameId, timeStamp, bb, sb, totalPlayers); convertedHand.HandId = handId; convertedHand.Board = dr[GameTable.board.ToString()].ToString(); convertedHand.TournamentId = tournamentId; convertedHand.TableName = dr[GameTable.tablename.ToString()].ToString(); return(convertedHand); }
void ExtractSequencesForEachRound(IConvertedPokerHand convHand, IDataRecord dr) { if (dr.FieldCount > (int)GameTable.sequence0) { convHand.AddSequence( _pokerHandStringConverter.ConvertedRoundFrom(dr[(int)GameTable.sequence0].ToString())); } if (dr.FieldCount > (int)GameTable.sequence1) { convHand.AddSequence( _pokerHandStringConverter.ConvertedRoundFrom(dr[(int)GameTable.sequence1].ToString())); } if (dr.FieldCount > (int)GameTable.sequence2) { convHand.AddSequence( _pokerHandStringConverter.ConvertedRoundFrom(dr[(int)GameTable.sequence2].ToString())); } if (dr.FieldCount > (int)GameTable.sequence3) { convHand.AddSequence( _pokerHandStringConverter.ConvertedRoundFrom(dr[(int)GameTable.sequence3].ToString())); } }
void SetupTableOverlayManager(IConvertedPokerHand convertedPokerHand) { _tableOverlayManager.InitializeWith(_gameHistory, _overlayPokerTableStatistics, LiveTrackerSettings.ShowHoleCardsDuration, convertedPokerHand); }
public ITableOverlayManager UpdateWith(IConvertedPokerHand newHand) { UpdateTableOverlay(newHand); UpdateSeatMapper(newHand); UpdateOverlayToTableAttacher(newHand); return(this); }
ITableOverlaySettingsViewModel SetupOverlaySettings(IConvertedPokerHand convertedPokerHand) { var overlaySettings = _layoutManager.Load(convertedPokerHand.Site, convertedPokerHand.TotalSeats); overlaySettings.SaveChanges += () => _layoutManager.Save(overlaySettings, convertedPokerHand.Site); overlaySettings.UndoChanges += revertTo => revertTo(_layoutManager.Load(convertedPokerHand.Site, convertedPokerHand.TotalSeats)); return(overlaySettings); }
public void _Init() { _session.Clear(); new SchemaExport(_configuration).Execute(false, true, false, _session.Connection, null); _identity = new PlayerIdentity(Name, Site); _hand = new ConvertedPokerHand(Site, 1, DateTime.MinValue, 2, 1, 2); }
/// <summary> /// Inserts Hand into database and returns the Id that was assigned to it /// </summary> /// <param name="convertedHand"></param> /// <returns>Id used in the identity column of the gamehhd table of the database</returns> public int?InsertHandAndReturnHandId(IConvertedPokerHand convertedHand) { _convertedPokerHandInserter .Use(_dataProvider) .Insert(convertedHand); return(_databaseUtility .Use(_dataProvider) .GetHandIdForHandWith(convertedHand.GameId, convertedHand.Site)); }
public IPokerRoundsConverter InitializeWith( IAquiredPokerHand aquiredHand, IConvertedPokerHand convertedHand, double pot, double toCall) { ToCall = toCall; Pot = pot; _convertedHand = convertedHand; _aquiredHand = aquiredHand; return(this); }
public RelativeRatioResult(IConvertedPokerHand convertedHand, IConvertedPokerRound player1FirstRound, IConvertedPokerRound player2FirstRound, double relativeRatio1, double relativeRatio2, double relativeRatio3, double relativeRatio4) { ConvertedHand = convertedHand; Player1FirstRound = player1FirstRound; Player2FirstRound = player2FirstRound; RelativeRatio4 = relativeRatio4; RelativeRatio3 = relativeRatio3; RelativeRatio2 = relativeRatio2; RelativeRatio1 = relativeRatio1; }
void InitConvertedPokerHand() { var player1 = new ConvertedPokerPlayer("player1", 10, 5, 0, 6, "As Kd") { new ConvertedPokerRound() }; player1[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.C, 0.2)); var player2 = new ConvertedPokerPlayer("player2", 12, 4, 1, 6, "?? ??") { new ConvertedPokerRound() }; player2[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.X, 1.0)); var player3 = new ConvertedPokerPlayer("player3", 13, 2, 2, 6, "?? ??") { new ConvertedPokerRound() }; player3[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.C, 0.3)); var player4 = new ConvertedPokerPlayer("player4", 14, 4, 3, 6, "?? ??") { new ConvertedPokerRound() }; player4[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.F, 1.0)); var player5 = new ConvertedPokerPlayer("player5", 15, 3, 4, 6, "?? ??") { new ConvertedPokerRound() }; player5[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.C, 0.3)); var player6 = new ConvertedPokerPlayer("player6", 16, 14, 5, 6, "?? ??") { new ConvertedPokerRound() }; player6[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.F, 1.0)); _pokerHand = new ConvertedPokerHand("PokerStars", 1234, DateTime.MinValue, 200, 100, 6); _pokerHand.AddPlayer(player1); _pokerHand.AddPlayer(player2); _pokerHand.AddPlayer(player3); _pokerHand.AddPlayer(player4); _pokerHand.AddPlayer(player5); _pokerHand.AddPlayer(player6); _pokerHand.Ante = 50; _pokerHand.TournamentId = 2354; }
public IConvertedPokerHand RetrieveHand(int handId) { IConvertedPokerHand convHand = CreateHandFromDatabase(handId); if (convHand != null) { ExtractPlayersFromDatabase(handId, convHand); } return(convHand); }
void Launch(IConvertedPokerHand convertedPokerHand) { SetupLiveStatsWindow(); if (LiveTrackerSettings.ShowTableOverlay) { SetupTableOverlayManager(convertedPokerHand); } IsLaunched = true; }
public void _Init() { _session.Clear(); new SchemaExport(_configuration).Execute(false, true, false, _session.Connection, null); _hand = new ConvertedPokerHand(Site, GameId, _timeStamp, BB, SB, TotalPlayers); _playerIdentity1 = new PlayerIdentity(Name1, Site); _playerIdentity2 = new PlayerIdentity(Name2, Site); }
void FillPlayerRows(IConvertedPokerHand hand) { PlayerRows.Clear(); foreach (var player in hand) { if (_showPreflopFolds || player[Streets.PreFlop][0].What != ActionTypes.F) { PlayerRows.Add(new HandHistoryRow(player)); } } }
public void Get_HandWithPlayersInRoundWasSaved_RestoresPlayersInRound() { _hand.PlayersInRound[(int)Streets.Flop] = 3; _hand.PlayersInRound[(int)Streets.Turn] = 2; _hand.PlayersInRound[(int)Streets.River] = 1; _session.Save(_hand); FlushAndClearSession(); IConvertedPokerHand retrievedHand = _sut.Get(_hand.Id); retrievedHand.PlayersInRound.ShouldBeEqualTo(_hand.PlayersInRound); }
public void Get_HandWithTwoPlayerWasSaved_RestoresBothPlayers() { _hand .AddPlayer(SavePlayerIdentityAndReturnPlayerNamed("player1")) .AddPlayer(SavePlayerIdentityAndReturnPlayerNamed("player2")); _session.Save(_hand); FlushAndClearSession(); IConvertedPokerHand retrievedHand = _sut.Get(_hand.Id); retrievedHand.Players.ShouldBeEqualTo(_hand.Players); }
public void Get_HandWithTwoPlayerWasSaved_RestoresBothPlayerIdentitiesAsProxies() { _hand .AddPlayer(SavePlayerIdentityAndReturnPlayerNamed("player1")) .AddPlayer(SavePlayerIdentityAndReturnPlayerNamed("player2")); _session.Save(_hand); FlushAndClearSession(); IConvertedPokerHand retrievedHand = _sut.Get(_hand.Id); retrievedHand.Players.First().PlayerIdentity.GetType().Name.Contains("Proxy").ShouldBeTrue(); retrievedHand.Players.Last().PlayerIdentity.GetType().Name.Contains("Proxy").ShouldBeTrue(); }
void NewHandFound(string fullPath, IConvertedPokerHand convertedPokerHand) { if (!GameControllers.ContainsKey(fullPath)) { if (!_liveTrackerSettings.AutoTrack) { return; } StartTracking(fullPath); } GameControllers[fullPath].NewHand(convertedPokerHand); }
void UpdatePlayerStatistics(IConvertedPokerHand convertedPokerHand) { var playerStatisticsToUpdate = new List <IPlayerStatistics>(); convertedPokerHand.Players.ForEach(p => { if (LiveTrackerSettings.ShowMyStatistics || p.Name != convertedPokerHand.HeroName) { AddPlayerStatisticsIfNotAddedBeforeFor(p.Name, convertedPokerHand.Site); playerStatisticsToUpdate.Add(PlayerStatistics[p.Name]); } }); _playerStatisticsUpdater.Update(playerStatisticsToUpdate); }
public void _Init() { new SchemaExport(_configuration).Execute(false, true, false, _session.Connection, null); _hand = new ConvertedPokerHand(Site, GameId, _timeStamp, BB, SB, TotalPlayers); var sessionFactoryManager = new Mock <ISessionFactoryManager>(); sessionFactoryManager .SetupGet(sfm => sfm.CurrentSession) .Returns(_session); _playerIdentityDaoStub = new Mock <IPlayerIdentityDao>(); _sut = new ConvertedPokerHandDao(sessionFactoryManager.Object, _playerIdentityDaoStub.Object); }
public override bool IsMetBy(IConvertedPokerHand hand) { if (hand == null) { return(false); } var matches = from player in hand.Players where player.Name.Equals(PlayerName) && player.Rounds.Count > 1 select player; return(matches.Count() > 0); }
string[] PrepareSequences(IConvertedPokerHand convHand) { var theSequenceStrings = new string[4]; for (int i = 0; i < convHand.Sequences.Count; i++) { theSequenceStrings[i] = _pokerHandStringConverter.BuildSqlStringFrom(convHand.Sequences[i]); } for (int i = convHand.Sequences.Count; i < 4; i++) { theSequenceStrings[i] = null; } return(theSequenceStrings); }
static Mock <IPokerHandConverter> ConverterThatReturnsConvertedHandWith(ulong extractedGameId) { var stub = new StubBuilder(); IConvertedPokerHand stubConvertedHand = stub.Setup <IConvertedPokerHand>() .Get(hand => hand.GameId) .Returns(extractedGameId).Out; var mockConverter = new Mock <IPokerHandConverter>(); mockConverter .Setup(c => c.ConvertAquiredHand(It.IsAny <IAquiredPokerHand>())) .Returns(stubConvertedHand); return(mockConverter); }
public void _Init() { _session.Clear(); new SchemaExport(_configuration).Execute(false, true, false, _session.Connection, null); _hand = new ConvertedPokerHand("someSite", 1, DateTime.MinValue, 2, 1, 2); var playerIdentity = new PlayerIdentity(Name, Site); _session.Save(playerIdentity); _player = new ConvertedPokerPlayer { PlayerIdentity = playerIdentity }; }
/// <summary> /// Converts the given Hands with absolute ratios into Hands with relative ratios /// This is done by replaying the hand and determining the relation of each action ratio /// to the pot or the amount that needed to be called /// </summary> /// <param name="sortedAquiredHands">Hands to be converted</param> /// <returns>Converted Hands</returns> public IPokerHands ConvertAquiredHands(IPokerHands sortedAquiredHands) { var convertedHands = new PokerHands(); for (int i = 0; i < sortedAquiredHands.Hands.Count; i++) { IConvertedPokerHand convertedHand = ConvertAquiredHand((IAquiredPokerHand)sortedAquiredHands.Hands[i]); // Only add hands with active players if (convertedHand != null) { convertedHands.AddHand(convertedHand); } } return(convertedHands); }
public void _Init() { _stub = new StubBuilder(); _heroName = "hero"; _convertedHand = new ConvertedPokerHand(); _heroPlayer = new ConvertedPokerPlayer( _heroName, _stub.Some <double>(), _stub.Some <double>(), _stub.Valid(For.Position, 1), _stub.Valid(For.TotalPlayers, 2), _stub.Valid(For.HoleCards, string.Empty)); _sawFlopCondition = new SawFlopCondition().AppliesTo(_heroName); }