guess Opp

This commit is contained in:
2023-08-12 10:55:48 +02:00
parent 6d91b7fc16
commit 0e36b095fa

View File

@@ -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 "<br />" ;
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 "<p>in csv format:</p>" ;
print "1st player, winner, #turns, expansions<br />" ;
print "$first,$winner,$turns, " . implode( " ", array_values( array_unique($usedExt) ) );
print "1st player, winner, opponent, #turns, expansions<br />" ;
print "$first,$winner, $opp,$turns, " . implode( " ", array_values( array_unique($usedExt) ) );
}
function guessExpansion( $card, $cards, $ext ) {