Skip to content

Commit

Permalink
Merge pull request #98 from RuijieZ/pokerstars-cashout
Browse files Browse the repository at this point in the history
Pokerstars Cashout Support
  • Loading branch information
ItalyToast committed Dec 25, 2023
2 parents e01ce46 + 22d6c53 commit 3eb27e0
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,9 @@
<None Update="SampleHandHistories\PokerStars\CashGame\HandActionTests\BigBlindOptionRaisesOption.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="SampleHandHistories\PokerStars\CashGame\HandActionTests\CashOut.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="SampleHandHistories\PokerStars\CashGame\HandActionTests\FoldedPreflop.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,30 @@ public void AllInHand_NeedsRaiseAdjusting_Works()
TestParseActions("NeedsRaiseAdjusting", expectedActions, expectedWinners);
}

[Test]
public void CashOut_Works()
{
List<HandAction> expectedActions = new List<HandAction>()
{
new HandAction("k12sat", HandActionType.SMALL_BLIND, -1m, Street.Preflop),
new HandAction("ontaba23", HandActionType.BIG_BLIND, -2m, Street.Preflop),
new HandAction("Greg1ry", HandActionType.FOLD, 0m, Street.Preflop),
new HandAction("l31kas", HandActionType.FOLD, 0m, Street.Preflop),
new HandAction("m788", HandActionType.RAISE, 6m, Street.Preflop),
new HandAction("k12sat", HandActionType.FOLD, 0, Street.Preflop),
new HandAction("ontaba23", HandActionType.RAISE, 18, Street.Preflop, true),
new HandAction("m788", HandActionType.CALL, 14m, Street.Preflop),
new HandAction("ontaba23", HandActionType.SHOW, 0, Street.Showdown),
new HandAction("m788", HandActionType.SHOW, 0, Street.Showdown),
};
List<WinningsAction> expectedWinners = new List<WinningsAction>()
{
new WinningsAction("m788", WinningsActionType.INSURANCE, 26.1m, 0),
};

TestParseActions("CashOut", expectedActions, expectedWinners);
}

[Test]
public void AllInHand_NeedsRaiseAdjusting_BigBlindOptionRaisesOption_Works()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
PokerStars Hand #159212572783: Hold'em No Limit ($1/$2 USD) - 2021/03/21 11:21:25 ET
Table 'Abetti I' 6-max Seat #2 is the button
Seat 1: l31kas ($161.21 in chips)
Seat 2: m788 ($133.5 in chips)
Seat 3: k12sat ($146.48 in chips)
Seat 4: ontaba23 ($20 in chips)
Seat 5: Greg1ry ($156.15 in chips)
k12sat: posts small blind $1
ontaba23: posts big blind $2
kebab: sits out
*** HOLE CARDS ***
Greg1ry: folds
l31kas: folds
m788: raises $4 to $6
k12sat: folds
ontaba23: raises $14 to $20 and is all-in
m788: calls $14
*** FLOP *** [Jd 3s 7h]
*** TURN *** [Jd 3s 7h] [4h]
*** RIVER *** [Jd 3s 7h 4h] [Kd]
*** SHOW DOWN ***
ontaba23: shows [7d As] (a pair of Sevens)
m788: shows [Th Ts] (a pair of Tens)
m788 cashed out the hand for $26.10 | Cash Out Fee $0.26
*** SUMMARY ***
Total pot $41 | Rake $2.05
Board [Jd 3s 7h 4h Kd]
Seat 1: l31kas folded before Flop (didn't bet)
Seat 2: m788 (button) showed [Th Ts] and won ($38.95) with a pair of Tens (pot not awarded as player cashed out)
Seat 3: k12sat (small blind) folded before Flop
Seat 4: ontaba23 (big blind) showed [7d As] and lost with a pair of Sevens
Seat 5: Greg1ry folded before Flop (didn't bet)
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,7 @@ public void ParseShowDown(string[] handLines, List<HandAction> handActions, List
{
var line = handLines[i];

var lastChar = line[line.Length - 1];

switch (lastChar)
switch (line.Last())
{
// woezelenpip collected $7.50 from pot
// kiljka: sits out
Expand All @@ -684,6 +682,7 @@ public void ParseShowDown(string[] handLines, List<HandAction> handActions, List
}
continue;
// templargio collected €6.08 from side pot-2
// m788 cashed out the hand for $26.10 | Cash Out Fee $0.26
case '0':
case '1':
case '2':
Expand All @@ -699,11 +698,18 @@ public void ParseShowDown(string[] handLines, List<HandAction> handActions, List
// Hudison747 was removed from the table for failing to post
if (line[line.Length - 1] == 't' && line[line.Length - 2] == 's')
continue;

if (line[line.Length - 2] == '-')
{
winners.Add(ParseCollectedLine(line, Street.Showdown));
}

int barIndex = line.IndexOf('|');
// m788 cashed out the hand for $26.10 | Cash Out Fee $0.26
if (barIndex >= 0 && line[barIndex+2] == 'C')
{
winners.Add(ParseCashoutLine(line, barIndex));
}
continue;

//*** FLOP *** [6d 7c 6h]
Expand Down Expand Up @@ -1127,6 +1133,19 @@ public WinningsAction ParseCollectedLine(string actionLine, Street currentStreet
return new WinningsAction(playerName, handActionType, amount.ParseAmount(), potNumber);
}

public WinningsAction ParseCashoutLine(string actionLine, int barIndex)
{
// m788 cashed out the hand for $26.10 | Cash Out Fee $0.26
int letterRIndex = actionLine.LastIndexOf('r', barIndex);
int amountStartIndex = letterRIndex + 3;
int playerNameEndIndex = letterRIndex - 23;

string playerName = actionLine.SubstringBetween(0, playerNameEndIndex);
decimal amount = actionLine.SubstringBetween(amountStartIndex, barIndex-2).ParseAmount();

return new WinningsAction(playerName, WinningsActionType.INSURANCE, amount, 0);
}

public HandAction ParseUncalledBetLine(string actionLine, Street currentStreet)
{
// Uncalled bet lines look like:
Expand Down

0 comments on commit 3eb27e0

Please sign in to comment.