Hi, i have a tricky problem and seems like i'm stuck. I have an idea how to proceed but no idea how to do it in practice.
What i want to do is convert a string inside .txt file to another format (using regex and variables?). The main problem is when i need to convert those lines marked with //comments.
NOTE: "...villainx calls $x" is calculated differently in original and in the format it should be converted to. And that's the problem i need some serious help.
Example: This needs to be converted...
HERO posts small blind $0.50.
villain4 posts big blind $1.00.
** Dealing down cards **
Dealt to HERO [ 7s 8c 5d 8d ]
villain1 calls $1.00
villain2 raises to $3.00 // total sum a player raises to
villain3 calls $3.00
HERO calls $3.00
villain4 calls $3.00
villain1 calls $3.00 // total sum a player calls whether he has put money in to the pot before (as he has -- $1 call, first to act)
** Dealing Flop ** [ 9c, Ah, Jh ]
...to this:
HERO posts small blind [$0.50 USD].
villain4 posts big blind [$1.00 USD].
** Dealing down cards **
Dealt to HERO [ 7s 8c 5d 8d ]
villain1 calls [$1.00 USD]
villain2 raises [$3.00 USD] // total sum a player raises to
villain3 calls [$3.00 USD]
HERO calls [$2.50 USD] // a sum player calls = last raise ($3) - money put in (=$0.50 small blind)
villain4 calls [$2.00 USD] // $3 - $1 (big blind)
villain1 calls [$2.00 USD] // $3 - $1 (the call first to act)
** Dealing Flop ** [ 9c, Ah, Jh ]
Another example:
HERO posts small blind $0.50.
villain4 posts big blind $1.00.
** Dealing down cards **
Dealt to HERO [ 7s 8c 5d 8d ]
villain1 bets $5.50
villain2 raises to $20.00
villain3 raises to $40.00
villain1 calls $40.00 //THIS NEEDS TO BE "calls $34.50"
villain2 calls $40.00 //THIS NEEDS TO BE "calls $20.00"
** Dealing Flop ** [ 9c, Ah, Jh ]
and here's the full example how the whole hand should look. Txt file could contain a hundreds of hands. I've managed to preg_replace basically all other issues but that above. I'm lost. Please help me! :D
***** Hand History for Game 335502358 ***** (Full Tilt)
$100.00 USD PL Omaha - Thursday, October 15, 01:32:21 ET 2009
Table Foxtrot (Real Money)
Seat 3 is the button
Seat 1: villain1 ( $38.50 USD )
Seat 2: villain2 ( $99.65 USD )
Seat 3: villain3 ( $415.55 USD )
Seat 4: HERO ( $99.00 USD )
Seat 6: villain4 ( $171.20 USD )
HERO posts small blind [$0.50 USD].
villain4 posts big blind [$1.00 USD].
** Dealing down cards **
Dealt to HERO [ 7s 8c 5d 8d ]
villain1 calls [$1.00 USD]
villain2 raises [$3.00 USD]
villain3 calls [$3.00 USD]
HERO calls [$2.50 USD]
villain4 calls [$2.00 USD]
villain1 calls [$2.00 USD]
** Dealing Flop ** [ 9c, Ah, Jh ]
HERO checks
villain4 checks
villain1 checks
villain2 bets [$8.00 USD]
villain3 folds
HERO folds
villain4 calls [$8.00 USD]
villain1 folds
** Dealing Turn ** [ Th ]
villain4 checks
villain2 bets [$13.00 USD]
villain4 calls [$13.00 USD]
** Dealing River ** [ 3c ]
villain4 checks
villain2 checks
villain2 shows [Qc, Js 8s Qd ]
villain4 shows [Kh, Tc 7h Kd ]
villain4 wins $54.15 USD from main pot
edit 1: added NOTE to clarify my real question
edit 2: added another example