public static List<PlayerAction> parseString(final String clipBoard) {
// final TextTransfer textTransfer = new TextTransfer();
// final String clipBoard = textTransfer.getClipboardContents();
final String[] arrClipBoard = clipBoard.split("\n");
final PlayingCards playingCards = new PlayingCards();
final List<PlayerAction> situation = new ArrayList<PlayerAction>();
for (int i = arrClipBoard.length - 1; i > 0; i--) {
if (arrClipBoard[i].startsWith(START_NEW_HAND)) {
for (int j = arrClipBoard.length - 1; j > i; j--) {
if (arrClipBoard[j].startsWith(PLAYER)) {
// System.out.println("skip: " + arrClipBoard[j]);
continue;
}
if (arrClipBoard[j].equals(DEALER)) {
// System.out.println("skip: " + arrClipBoard[j]);
continue;
}
if (arrClipBoard[j].startsWith(DEALER)) {
final String[] tempStr = arrClipBoard[j].split(" ");
if (tempStr[2].equals(FOLD)) {
situation.add(new PlayerAction(Action.Fold, 0D,
tempStr[PLAYER_POSITION]));
// System.out.println(tempStr[1] + " FOLD ");
continue;
}
if (tempStr[2].equals(CHECK)) {
situation.add(new PlayerAction(Action.Check, 0D,
tempStr[PLAYER_POSITION]));
// System.out.println(tempStr[1] + " CHECK ");
continue;
}
if (tempStr[2].equals(ALLIN)) {
situation.add(new PlayerAction(Action.Raise, Double
.parseDouble(tempStr[MONEY_POSITION_ALLIN].substring(1)),
tempStr[PLAYER_POSITION]));
// System.out.println(tempStr[1] + " ALLIN ");
continue;
}
if (tempStr[2].equals(CALL)) {
situation.add(new PlayerAction(Action.Call, Double
.parseDouble(tempStr[MONEY_POSITION_CALL].substring(1)),
tempStr[PLAYER_POSITION]));
// System.out.println(tempStr[1] + " CALL " + tempStr[3]);
continue;
}
if (tempStr[2].equals(RAISE)) {
situation.add(new PlayerAction(Action.Raise, Double
.parseDouble(tempStr[MONEY_POSITION_RAISE].substring(1)),
tempStr[PLAYER_POSITION]));
// System.out.println(tempStr[1] + " RAISE " + tempStr[4]);
continue;
}
if (tempStr[2].equals(BET)) {
situation.add(new PlayerAction(Action.Bet, Double
.parseDouble(tempStr[MONEY_POSITION_BET].substring(1)),
tempStr[PLAYER_POSITION]));
// System.out.println(tempStr[1] + " BET " + tempStr[3]);
continue;
}
continue;
}
// end current turn
if (arrClipBoard[j].startsWith(DEALING)) {
if (arrClipBoard[j].startsWith(DEALING_PREFLOP)) {
System.out.println("Turn is preflop");
continue;
}
System.out.println("->Turn is " + arrClipBoard[j].substring(8));
break;
}
// your cards
if (arrClipBoard[j].startsWith(YOUR_CARDS)) {
// cards
final String[] arrCards = arrClipBoard[j].split(" ");
System.out.println("->Your card is " + parseCard(arrCards[2]) + " and "
+ parseCard(arrCards[3]));
playingCards.getPlayerCards()[0] = parseCard(arrCards[2]);
playingCards.getPlayerCards()[1] = parseCard(arrCards[3]);
continue;
}
// cards
final String[] arrCards = arrClipBoard[j].split(" ");
if (arrCards.length == 3 || arrCards.length == 4 || arrCards.length == 5) {
System.out.print("->Table card is ");
for (int k = 0; k < arrCards.length; k++) {
playingCards.getTableCards()[k] = parseCard(arrCards[k]);
System.out.print(parseCard(arrCards[k]) + " ; ");
}
System.out.println();
continue;
}