void TestAdjustedCallAllInAmount(decimal amount, List <HandAction> actions, decimal expectedAmount) { var result = AllInActionHelper.GetAdjustedCallAllInAmount(amount, actions); Assert.AreEqual(expectedAmount, result); }
private HandAction ParseAction(string Line, Street currentStreet, List <HandAction> actions) { const int playerHandActionStartIndex = 21; const int fixedAmountDistance = 9; char handActionType = Line[playerHandActionStartIndex]; int playerNameStartIndex; string playerName; switch (handActionType) { //<ACTION TYPE="ACTION_ALLIN" PLAYER="SAMERRRR" VALUE="15972.51"></ACTION> case 'A': playerNameStartIndex = playerHandActionStartIndex + 15; playerName = GetActionPlayerName(Line, playerNameStartIndex); decimal amount = GetActionAmount(Line, playerNameStartIndex + playerName.Length + fixedAmountDistance); HandActionType allInType = AllInActionHelper.GetAllInActionType(playerName, amount, currentStreet, actions); if (allInType == HandActionType.CALL) { amount = AllInActionHelper.GetAdjustedCallAllInAmount(amount, actions.Player(playerName)); } return(new HandAction(playerName, allInType, amount, currentStreet, true)); //<ACTION TYPE="ACTION_BET" PLAYER="ItalyToast" VALUE="600.00"></ACTION> case 'B': playerNameStartIndex = playerHandActionStartIndex + 13; playerName = GetActionPlayerName(Line, playerNameStartIndex); return(new HandAction( playerName, HandActionType.BET, GetActionAmount(Line, playerNameStartIndex + playerName.Length + fixedAmountDistance), currentStreet )); //<ACTION TYPE="ACTION_CHECK" PLAYER="gasmandean"></ACTION> //<ACTION TYPE="ACTION_CALL" PLAYER="fatima1975" VALUE="0.04"></ACTION> case 'C': if (Line[playerHandActionStartIndex + 1] == 'H') { playerNameStartIndex = playerHandActionStartIndex + 15; playerName = GetActionPlayerName(Line, playerNameStartIndex); return(new HandAction( playerName, HandActionType.CHECK, 0, currentStreet )); } else { playerNameStartIndex = playerHandActionStartIndex + 14; playerName = GetActionPlayerName(Line, playerNameStartIndex); return(new HandAction( playerName, HandActionType.CALL, GetActionAmount(Line, playerNameStartIndex + playerName.Length + fixedAmountDistance), currentStreet )); } //<ACTION TYPE="ACTION_FOLD" PLAYER="Belanak"></ACTION> case 'F': playerNameStartIndex = playerHandActionStartIndex + 14; playerName = GetActionPlayerName(Line, playerNameStartIndex); return(new HandAction( playerName, HandActionType.FOLD, 0, currentStreet )); //<ACTION TYPE="ACTION_RAISE" PLAYER="ItalyToast" VALUE="400.00"></ACTION> case 'R': playerNameStartIndex = playerHandActionStartIndex + 15; playerName = GetActionPlayerName(Line, playerNameStartIndex); return(new HandAction( playerName, HandActionType.RAISE, GetActionAmount(Line, playerNameStartIndex + playerName.Length + fixedAmountDistance), currentStreet )); default: throw new ArgumentOutOfRangeException("Unkown hand action: " + handActionType + " - " + Line); } }