diff --git a/parse.php b/parse.php
index d6dc534..24320b5 100644
--- a/parse.php
+++ b/parse.php
@@ -30,6 +30,7 @@ else {
$turns = 0 ;
$winner = "" ;
+ $opp = "";
$first = "" ;
$data = htmlspecialchars(trim( $_POST["log"] ) ) ;
$data_ar = preg_split("/\r\n|\n|\r/", $data);
@@ -40,9 +41,13 @@ else {
$turns++ ;
}
- if ( strpos( $line, "ends turn 1" ) ) {
- $line_a = explode( " ", "$line" ) ;
- $winner = $line_a[0] ;
+ if ( preg_match( '/^([a-zA-Z0-9]+) ends turn 1$/', $line, $match ) ) {
+ $first = $match[1] ;
+ }
+ if( $opp==='') {
+ if( preg_match( '/^Attacked ([a-zA-Z0-9]+) for/', $line, $match ) ) {
+ $opp=$match[1] ;
+ }
}
if( preg_match( '/^Played <color=#[A-Z0-9]+>(.*)<\/color>/', $line, $match ) ) {
@@ -51,9 +56,16 @@ else {
if ( strpos( $line, "===" ) ) {
$line_a = explode( " ", "$line" ) ;
- $first = $line_a[9] ;
+ $winner = $line_a[9] ;
}
+ if( preg_match( '/^Acquired <color=#[A-Z0-9]+>(.*)<\/color>/', $line, $match ) ) {
+ $acLine = explode( " ", $previousLine ) ;
+ $p=$acLine[8] ;
+ echo "$$p buy $match[1]" ;
+ }
+
+ $previousLine=$line ;
}
echo "
" ;
echo "\n";
@@ -63,13 +75,14 @@ else {
$result = array(
"first player" => $first,
"winner" => $winner,
+ "opp" => $opp,
"num_turns" => $turns ,
"expansions" => array_values( array_unique($usedExt) ),
) ;
print json_encode( $result, JSON_PRETTY_PRINT );
print "
in csv format:
" ; - print "1st player, winner, #turns, expansions