public void UpdateStatistics_RepositoryReturnsTwoAnalyzablePlayers_SetsLastQueriedIdToMaxIdOfReturnedPlayers() { IAnalyzablePokerPlayer analyzablePlayerStub1 = _stub.Setup <IAnalyzablePokerPlayer>() .Get(ap => ap.Id).Returns(1) .Get(ap => ap.ActionSequences).Returns(new[] { ActionSequences.PreFlopFrontRaise }) .Out; IAnalyzablePokerPlayer analyzablePlayerStub2 = _stub.Setup <IAnalyzablePokerPlayer>() .Get(ap => ap.Id).Returns(2) .Get(ap => ap.ActionSequences).Returns(new[] { ActionSequences.PreFlopFrontRaise }) .Out; _repositoryMock .Setup(rp => rp.FindAnalyzablePlayersWith(_playerIdentityStub.Id, _sut.LastQueriedId)) .Returns(new List <IAnalyzablePokerPlayer> { analyzablePlayerStub1, analyzablePlayerStub2 }); _sut.PlayerIdentitySet = _playerIdentityStub; _sut .InitializePlayer(Name, Site) .UpdateStatistics(); _sut.LastQueriedId.ShouldBeEqualTo(analyzablePlayerStub2.Id); }
public void GetFilteredAnalyzablePlayers_FilterSet_ReturnsPlayersPassedBackByFilterMethodOfFilter() { IAnalyzablePokerPlayer analyzablePlayerStub1 = _stub.Setup <IAnalyzablePokerPlayer>() .Get(ap => ap.Id).Returns(1) .Get(ap => ap.ActionSequences).Returns(new[] { ActionSequences.PreFlopFrontRaise }) .Out; IAnalyzablePokerPlayer analyzablePlayerStub2 = _stub.Setup <IAnalyzablePokerPlayer>() .Get(ap => ap.Id).Returns(2) .Get(ap => ap.ActionSequences).Returns(new[] { ActionSequences.PreFlopFrontRaise }) .Out; _sut.AnalyzablePlayers = new List <IAnalyzablePokerPlayer> { analyzablePlayerStub1, analyzablePlayerStub2 }; var filterStub = new Mock <IAnalyzablePokerPlayersFilter>(); filterStub .Setup(f => f.Filter(_sut.AnalyzablePlayers)) .Returns(new List <IAnalyzablePokerPlayer> { analyzablePlayerStub1 }); _sut.Filter = filterStub.Object; IEnumerable <IAnalyzablePokerPlayer> filteredPlayers = _sut.GetFilteredAnalyzablePlayersInvoke(); filteredPlayers.ShouldContain(analyzablePlayerStub1); filteredPlayers.ShouldNotContain(analyzablePlayerStub2); }
public string Describe(string playerName, IAnalyzablePokerPlayer analyzablePokerPlayer, Streets street, ITuple <double, double> ratioSizes) { ActionSequences actionSequence = analyzablePokerPlayer.ActionSequences[(int)street]; return(string.Format("{0} {1} ({2} of the pot), when {3} on the {4}, and was reraised", playerName, DescribeAction(actionSequence), PostFlopRaiseReactionDescriberUtils.DescribeBetSizes(ratioSizes), StatisticsDescriberUtils.DescribePosition(analyzablePokerPlayer, street), street.ToString().ToLower())); }
/// <summary> /// Describes the situation defined by the passed parameters to /// give the user feedback about what a statistics table depicts. /// </summary> /// <param name="playerName"></param> /// <param name="analyzablePokerPlayer">A sample player from the statistics set</param> /// <param name="street">Should always be preflop</param> /// <param name="ratioSizes">In this case is used to describe the range of strategic positions in which the player acted</param> /// <returns>A nice description of the situation depicted by the parameters</returns> public string Describe( string playerName, IAnalyzablePokerPlayer analyzablePokerPlayer, Streets street, ITuple <StrategicPositions, StrategicPositions> ratioSizes) { return(string.Format("{0} was sitting {1}, {2} {3} in {4} and was raised.", playerName, DescribePositions(ratioSizes), DescribeAction(analyzablePokerPlayer, street), street.ToString().ToLower(), StatisticsDescriberUtils.DescribePot(analyzablePokerPlayer, street))); }
public void UpdateStatistics_FilterSetAndPlayerIdentityNotNull_FiltersPlayers() { IAnalyzablePokerPlayer analyzablePlayerStub = _stub.Setup <IAnalyzablePokerPlayer>() .Get(ap => ap.Id).Returns(1) .Get(ap => ap.ActionSequences).Returns(new[] { ActionSequences.PreFlopFrontRaise }) .Out; _sut.AnalyzablePlayers = new List <IAnalyzablePokerPlayer> { analyzablePlayerStub }; _sut.Filter = _stub.Out <IAnalyzablePokerPlayersFilter>(); _sut.PlayerIdentitySet = _playerIdentityStub; _sut.UpdateStatistics(); _sut.MatchingPlayersWereFiltered.ShouldBeTrue(); }
public void UpdateStatistics_PlayerIdentityIsNotNull_AddsAnalyzablePlayersReturnedFromRepository() { IAnalyzablePokerPlayer analyzablePlayerStub = _stub.Setup <IAnalyzablePokerPlayer>() .Get(ap => ap.Id).Returns(1) .Get(ap => ap.ActionSequences).Returns(new[] { ActionSequences.PreFlopFrontRaise }) .Out; _repositoryMock .Setup(rp => rp.FindAnalyzablePlayersWith(_playerIdentityStub.Id, _sut.LastQueriedId)) .Returns(new List <IAnalyzablePokerPlayer> { analyzablePlayerStub }); _sut.PlayerIdentitySet = _playerIdentityStub; _sut .InitializePlayer(Name, Site) .UpdateStatistics(); _sut.AnalyzablePlayers.Last().ShouldBeEqualTo(analyzablePlayerStub); }
public IRaiseReactionsAnalyzer AnalyzeAndAdd( IRaiseReactionAnalyzer raiseReactionAnalyzer, IAnalyzablePokerPlayer analyzablePokerPlayer, Streets street, ActionSequences actionSequence, bool considerOpponentsRaiseSize) { _reactionAnalyzationPreparer.PrepareAnalyzationFor( analyzablePokerPlayer.Sequences[(int)street], analyzablePokerPlayer.Position, actionSequence); if (_reactionAnalyzationPreparer.WasSuccessful) { raiseReactionAnalyzer .AnalyzeUsingDataFrom(analyzablePokerPlayer, _reactionAnalyzationPreparer, considerOpponentsRaiseSize, RaiseSizeKeys); if (raiseReactionAnalyzer.IsValidResult & raiseReactionAnalyzer.IsStandardSituation) { _raiseReactionAnalyzers.Add(raiseReactionAnalyzer); } } return(this); }
/// <summary> /// Analyzes the data given by the analyzation preparer. /// </summary> /// <param name="analyzablePokerPlayer"> /// Player whose data is examined /// </param> /// <param name="analyzationPreparer"> /// Provides StartingIndex (Hero's original action) and Sequence /// </param> /// <param name="considerOpponentsRaiseSize">If true, it will determine the opponents re(raise) size and set the Considered raise size to it. /// So far this only is done like this for PostFlopHero acts. In all other cases set it to false and the raise size of the hero is used.</param> /// <param name="raiseSizeKeys"> /// Raise sizes to which the Opponent Raise size should be normalized to /// </param> public IRaiseReactionAnalyzer AnalyzeUsingDataFrom( IAnalyzablePokerPlayer analyzablePokerPlayer, IReactionAnalyzationPreparer analyzationPreparer, bool considerOpponentsRaiseSize, double[] raiseSizeKeys) { _considerOpponentsRaiseSize = considerOpponentsRaiseSize; AnalyzablePokerPlayer = analyzablePokerPlayer; _analyzationPreparer = analyzationPreparer; RaiseSizeKeys = raiseSizeKeys; try { IsValidResult = AnalyzeReaction(); } catch (Exception excep) { Log.Error(ToString(), excep); IsValidResult = false; } return(this); }
/// <summary> /// Gives a hint about how the statistics presentation is to be interpreted, e.g. if the raise size refers to the opponent or the hero /// </summary> /// <param name="playerName"></param> /// <param name="analyzablePokerPlayer"></param> /// <returns></returns> public string Hint(string playerName, IAnalyzablePokerPlayer analyzablePokerPlayer) { return(string.Format("Raise Size refers to the amount {0} raised after his opponent bet.", playerName)); }
internal static string DescribePosition(IAnalyzablePokerPlayer analyzablePokerPlayer, Streets street) { return(DescribePosition((bool)analyzablePokerPlayer.InPosition[(int)street])); }
internal static string DescribePot(IAnalyzablePokerPlayer analyzablePokerPlayer, Streets street) { return(DescribePot(analyzablePokerPlayer.ActionSequences[(int)street])); }
static string DescribeAction(IAnalyzablePokerPlayer analyzablePokerPlayer, Streets street) { return (ActionSequencesUtility.NamePastTenseOfLastActionSequence( analyzablePokerPlayer.ActionSequences[(int)street]).ToLower()); }
/// <summary> /// Gives a hint about how the statistics presentation is to be interpreted, e.g. if the raise size refers to the opponent or the hero /// </summary> /// <param name="playerName"></param> /// <param name="analyzablePokerPlayer"></param> /// <returns></returns> public string Hint(string playerName, IAnalyzablePokerPlayer analyzablePokerPlayer) { return(analyzablePokerPlayer.ActionSequences[(int)Streets.PreFlop] == ActionSequences.PreFlopFrontRaise ? string.Format("Raise Size refers to the amount {0} reraised his opponent.", playerName) : string.Format("Raise Size refers to the amount {0} raised before he was reraised.", playerName)); }