guess Opp
This commit is contained in:
25
parse.php
25
parse.php
@@ -30,6 +30,7 @@ else {
|
|||||||
|
|
||||||
$turns = 0 ;
|
$turns = 0 ;
|
||||||
$winner = "" ;
|
$winner = "" ;
|
||||||
|
$opp = "";
|
||||||
$first = "" ;
|
$first = "" ;
|
||||||
$data = htmlspecialchars(trim( $_POST["log"] ) ) ;
|
$data = htmlspecialchars(trim( $_POST["log"] ) ) ;
|
||||||
$data_ar = preg_split("/\r\n|\n|\r/", $data);
|
$data_ar = preg_split("/\r\n|\n|\r/", $data);
|
||||||
@@ -40,9 +41,13 @@ else {
|
|||||||
$turns++ ;
|
$turns++ ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( strpos( $line, "ends turn 1" ) ) {
|
if ( preg_match( '/^([a-zA-Z0-9]+) ends turn 1$/', $line, $match ) ) {
|
||||||
$line_a = explode( " ", "$line" ) ;
|
$first = $match[1] ;
|
||||||
$winner = $line_a[0] ;
|
}
|
||||||
|
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 ) ) {
|
if( preg_match( '/^Played <color=#[A-Z0-9]+>(.*)<\/color>/', $line, $match ) ) {
|
||||||
@@ -51,9 +56,16 @@ else {
|
|||||||
|
|
||||||
if ( strpos( $line, "===" ) ) {
|
if ( strpos( $line, "===" ) ) {
|
||||||
$line_a = explode( " ", "$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 "<br />" ;
|
echo "<br />" ;
|
||||||
echo "\n";
|
echo "\n";
|
||||||
@@ -63,13 +75,14 @@ else {
|
|||||||
$result = array(
|
$result = array(
|
||||||
"first player" => $first,
|
"first player" => $first,
|
||||||
"winner" => $winner,
|
"winner" => $winner,
|
||||||
|
"opp" => $opp,
|
||||||
"num_turns" => $turns ,
|
"num_turns" => $turns ,
|
||||||
"expansions" => array_values( array_unique($usedExt) ),
|
"expansions" => array_values( array_unique($usedExt) ),
|
||||||
) ;
|
) ;
|
||||||
print json_encode( $result, JSON_PRETTY_PRINT );
|
print json_encode( $result, JSON_PRETTY_PRINT );
|
||||||
print "<p>in csv format:</p>" ;
|
print "<p>in csv format:</p>" ;
|
||||||
print "1st player, winner, #turns, expansions<br />" ;
|
print "1st player, winner, opponent, #turns, expansions<br />" ;
|
||||||
print "$first,$winner,$turns, " . implode( " ", array_values( array_unique($usedExt) ) );
|
print "$first,$winner, $opp,$turns, " . implode( " ", array_values( array_unique($usedExt) ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
function guessExpansion( $card, $cards, $ext ) {
|
function guessExpansion( $card, $cards, $ext ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user