commit 6d0a75262003ceaf0edd760c1cfe4a115da722a2 Author: Thomas Constans Date: Sun Aug 6 22:38:21 2023 +0200 Actually able to guess expansions used during game diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..df7216c --- /dev/null +++ b/Readme.md @@ -0,0 +1,15 @@ +# SR Log Parser + +## Notes + +cards.csv created from google doc minus columns "text" and "notes" + +## Objectifs + +get winner + +get # of turns + +guess used expansions + +get damage \ No newline at end of file diff --git a/log b/log new file mode 100644 index 0000000..503f8bb --- /dev/null +++ b/log @@ -0,0 +1,524 @@ +Played Scout + randomized > Scout +1 Trade (Trade:1) +Acquired Solar Skiff + randomized - -1 Trade (Trade:0) +Played Scout + randomized > Scout +1 Trade (Trade:1) +Played Scout + randomized > Scout +1 Trade (Trade:2) +Acquired Trade Hauler + randomized - -2 Trade (Trade:0) +randomized ends turn 1 + Drew 5 cards. + Refresh ally indicators + It is now BlackTotoro's turn 2 +Play all + BlackTotoro > Scout +1 Trade (Trade:1) + BlackTotoro > Scout +1 Trade (Trade:2) + BlackTotoro > Viper +1 Combat (Combat:1) + BlackTotoro > Scout +1 Trade (Trade:3) + BlackTotoro > Scout +1 Trade (Trade:4) +Acquired Space Station + BlackTotoro - -4 Trade (Trade:0) +Attacked randomized for 1 (New Authority:49) + BlackTotoro - -1 Combat (Combat:0) + randomized - -1 Authority (Authority:49) +BlackTotoro ends turn 2 + Drew 5 cards. + Refresh ally indicators + It is now randomized's turn 3 +Played Scout + randomized > Scout +1 Trade (Trade:1) +Played Scout + randomized > Scout +1 Trade (Trade:2) +Played Scout + randomized > Scout +1 Trade (Trade:3) +Acquired Imperial Frigate + randomized - -3 Trade (Trade:0) +Played Scout + randomized > Scout +1 Trade (Trade:1) +Acquired Imperial Fighter + randomized - -1 Trade (Trade:0) +Played Viper + randomized > Viper +1 Combat (Combat:1) +Attacked BlackTotoro for 1 (New Authority:49) + randomized - -1 Combat (Combat:0) + BlackTotoro - -1 Authority (Authority:49) +randomized ends turn 3 + Drew 2 cards. + Shuffled discard pile to form new deck + Drew 3 cards. + Refresh ally indicators + It is now BlackTotoro's turn 4 +Play all + BlackTotoro > Viper +1 Combat (Combat:1) + BlackTotoro > Scout +1 Trade (Trade:1) + BlackTotoro > Scout +1 Trade (Trade:2) + BlackTotoro > Scout +1 Trade (Trade:3) + BlackTotoro > Scout +1 Trade (Trade:4) +Acquired Space Station + BlackTotoro - -4 Trade (Trade:0) +Attacked randomized for 1 (New Authority:48) + BlackTotoro - -1 Combat (Combat:0) + randomized - -1 Authority (Authority:48) +BlackTotoro ends turn 4 + Shuffled discard pile to form new deck + Drew 5 cards. + Refresh ally indicators + It is now randomized's turn 5 +Played Scout + randomized > Scout +1 Trade (Trade:1) +Played Scout + randomized > Scout +1 Trade (Trade:2) +Played Scout + randomized > Scout +1 Trade (Trade:3) +Acquired Survey Ship + randomized - -3 Trade (Trade:0) +Played Viper + randomized > Viper +1 Combat (Combat:1) +Attacked BlackTotoro for 1 (New Authority:48) + randomized - -1 Combat (Combat:0) + BlackTotoro - -1 Authority (Authority:48) +randomized ends turn 5 + Drew 5 cards. + Refresh ally indicators + It is now BlackTotoro's turn 6 +Play all + BlackTotoro > Viper +1 Combat (Combat:1) + BlackTotoro > Space Station +2 Combat (Combat:3) + BlackTotoro > Scout +1 Trade (Trade:1) + BlackTotoro > Scout +1 Trade (Trade:2) + BlackTotoro > Scout +1 Trade (Trade:3) +Acquired Embassy Yacht + BlackTotoro - -3 Trade (Trade:0) +Attacked randomized for 3 (New Authority:45) + BlackTotoro - -3 Combat (Combat:0) + randomized - -3 Authority (Authority:45) +BlackTotoro ends turn 6 + Drew 5 cards. + Refresh ally indicators + It is now randomized's turn 7 +Played Imperial Frigate + randomized > Imperial Frigate +4 Combat (Combat:4) + BlackTotoro < Imperial Frigate +1 Discard (Discarding: 1) +Attacked Space Station + randomized - -4 Combat (Combat:0) + Destroyed Space Station +Played Viper + randomized > Viper +1 Combat (Combat:1) +Attacked BlackTotoro for 1 (New Authority:47) + randomized - -1 Combat (Combat:0) + BlackTotoro - -1 Authority (Authority:47) +Played Scout + randomized > Scout +1 Trade (Trade:1) +Played Scout + randomized > Scout +1 Trade (Trade:2) +Acquired Explorer + randomized - -2 Trade (Trade:0) +randomized ends turn 7 + Drew 4 cards. + Shuffled discard pile to form new deck + Drew 1 cards. + Refresh ally indicators + It is now BlackTotoro's turn 8 +Resolving Discard 1 cards +BlackTotoro is discarding Viper + no more cards to discard + Discarded Viper +Play all + BlackTotoro > Scout +1 Trade (Trade:1) + BlackTotoro > Scout +1 Trade (Trade:2) + BlackTotoro > Scout +1 Trade (Trade:3) + BlackTotoro > Scout +1 Trade (Trade:4) +Acquired Mining Mech + BlackTotoro - -4 Trade (Trade:0) +BlackTotoro ends turn 8 + Drew 2 cards. + Shuffled discard pile to form new deck + Drew 3 cards. + Refresh ally indicators + It is now randomized's turn 9 +Played Trade Hauler + randomized > Trade Hauler +3 Trade (Trade:3) +Played Solar Skiff + randomized > Solar Skiff +2 Trade (Trade:5) + randomized > Trade Hauler +3 Authority (Authority:48) + Drew 1 cards. +Played Scout + randomized > Scout +1 Trade (Trade:6) +Played Scout + randomized > Scout +1 Trade (Trade:7) +Played Imperial Fighter + randomized > Imperial Fighter +2 Combat (Combat:2) + BlackTotoro < Imperial Fighter +1 Discard (Discarding: 1) +Attacked BlackTotoro for 2 (New Authority:45) + randomized - -2 Combat (Combat:0) + BlackTotoro - -2 Authority (Authority:45) +Acquired Machine Base + randomized - -7 Trade (Trade:0) +Played Scout + randomized > Scout +1 Trade (Trade:1) +Acquired Blob Fighter + randomized - -1 Trade (Trade:0) +randomized ends turn 9 + Drew 5 cards. + Refresh ally indicators + It is now BlackTotoro's turn 10 +Resolving Discard 1 cards +BlackTotoro is discarding Scout + no more cards to discard + Discarded Scout +Played Space Station + BlackTotoro > Space Station +2 Combat (Combat:2) +Played Space Station + BlackTotoro > Space Station +2 Combat (Combat:4) + BlackTotoro > Space Station +2 Combat (Combat:6) + BlackTotoro > Space Station +2 Combat (Combat:8) +Played Embassy Yacht + BlackTotoro > Embassy Yacht +3 Authority (Authority:48) + BlackTotoro > Embassy Yacht +2 Trade (Trade:2) + Drew 1 cards. + Drew 1 cards. +Play all + BlackTotoro > Scout +1 Trade (Trade:3) + BlackTotoro > Viper +1 Combat (Combat:9) + BlackTotoro > Viper +1 Combat (Combat:10) +Scrapping Space Station + Scrapped Space Station + BlackTotoro > Space Station +4 Trade (Trade:7) +Acquired Dreadnaught + BlackTotoro - -7 Trade (Trade:0) +Attacked randomized for 10 (New Authority:38) + BlackTotoro - -10 Combat (Combat:0) + randomized - -10 Authority (Authority:38) +BlackTotoro ends turn 10 + Drew 5 cards. + Refresh ally indicators + It is now randomized's turn 11 +Played Survey Ship + Drew 1 cards. + randomized > Survey Ship +1 Trade (Trade:1) +Played Imperial Frigate + randomized > Imperial Frigate +4 Combat (Combat:4) + BlackTotoro < Imperial Frigate +1 Discard (Discarding: 1) + randomized > Imperial Frigate +2 Combat (Combat:6) +Attacked Space Station + randomized - -4 Combat (Combat:2) + Destroyed Space Station +Played Scout + randomized > Scout +1 Trade (Trade:2) +Played Scout + randomized > Scout +1 Trade (Trade:3) +Acquired Ram + randomized - -3 Trade (Trade:0) +Played Scout + randomized > Scout +1 Trade (Trade:1) +Played Scout + randomized > Scout +1 Trade (Trade:2) +Acquired Missile Bot + randomized - -2 Trade (Trade:0) +Attacked BlackTotoro for 2 (New Authority:46) + randomized - -2 Combat (Combat:0) + BlackTotoro - -2 Authority (Authority:46) +randomized ends turn 11 + Drew 4 cards. + Shuffled discard pile to form new deck + Drew 1 cards. + Refresh ally indicators + It is now BlackTotoro's turn 12 +Resolving Discard 1 cards +BlackTotoro is discarding Scout + no more cards to discard + Discarded Scout +Played Mining Mech +BlackTotoro is scrapping: Viper + BlackTotoro > Mining Mech +3 Trade (Trade:3) + Scrapped Viper +Play all + BlackTotoro > Scout +1 Trade (Trade:4) + BlackTotoro > Scout +1 Trade (Trade:5) + BlackTotoro > Scout +1 Trade (Trade:6) +Acquired Peacekeeper + BlackTotoro - -6 Trade (Trade:0) +BlackTotoro ends turn 12 + Drew 2 cards. + Shuffled discard pile to form new deck + Drew 3 cards. + Refresh ally indicators + It is now randomized's turn 13 +Played Viper + randomized > Viper +1 Combat (Combat:1) +Played Viper + randomized > Viper +1 Combat (Combat:2) +Played Explorer + randomized > Explorer +2 Trade (Trade:2) +Scrapping Explorer + Scrapped Explorer + randomized > Explorer +2 Combat (Combat:4) +Attacked BlackTotoro for 4 (New Authority:42) + randomized - -4 Combat (Combat:0) + BlackTotoro - -4 Authority (Authority:42) +randomized ends turn 13 + Drew 5 cards. + Refresh ally indicators + It is now BlackTotoro's turn 14 +Played Space Station + BlackTotoro > Space Station +2 Combat (Combat:2) +Played Mining Mech +BlackTotoro is scrapping: Scout + BlackTotoro > Mining Mech +3 Trade (Trade:3) + Scrapped Scout +Play all + BlackTotoro > Scout +1 Trade (Trade:4) + BlackTotoro > Scout +1 Trade (Trade:5) +Acquired Mech Cruiser + BlackTotoro - -5 Trade (Trade:0) +Attacked randomized for 2 (New Authority:36) + BlackTotoro - -2 Combat (Combat:0) + randomized - -2 Authority (Authority:36) +BlackTotoro ends turn 14 + Drew 5 cards. + Refresh ally indicators + It is now randomized's turn 15 +Played Trade Hauler + randomized > Trade Hauler +3 Trade (Trade:3) +Played Scout + randomized > Scout +1 Trade (Trade:4) +Played Scout + randomized > Scout +1 Trade (Trade:5) +Played Scout + randomized > Scout +1 Trade (Trade:6) +Acquired Battle Blob + randomized - -6 Trade (Trade:0) +randomized ends turn 15 + Drew 5 cards. + Refresh ally indicators + It is now BlackTotoro's turn 16 + BlackTotoro > Space Station +2 Combat (Combat:2) +Played Peacekeeper + BlackTotoro > Peacekeeper +6 Combat (Combat:8) + BlackTotoro > Peacekeeper +6 Authority (Authority:48) +Play all + BlackTotoro > Scout +1 Trade (Trade:1) + BlackTotoro > Scout +1 Trade (Trade:2) + BlackTotoro > Viper +1 Combat (Combat:9) + BlackTotoro > Scout +1 Trade (Trade:3) +Acquired Trade Bot + BlackTotoro - -1 Trade (Trade:2) +Acquired Federation Shuttle + BlackTotoro - -1 Trade (Trade:1) +Acquired Unity Fighter + BlackTotoro - -1 Trade (Trade:0) +Attacked randomized for 9 (New Authority:27) + BlackTotoro - -9 Combat (Combat:0) + randomized - -9 Authority (Authority:27) +BlackTotoro ends turn 16 + Drew 4 cards. + Shuffled discard pile to form new deck + Drew 1 cards. + Refresh ally indicators + It is now randomized's turn 17 +Played Survey Ship + Drew 1 cards. + randomized > Survey Ship +1 Trade (Trade:1) +Played Machine Base + randomized > Machine Base ability available +Activating Machine Base + Drew 1 cards. +Resolving Scrap a card from your hand + Scrapped Scout +Played Imperial Frigate + randomized > Imperial Frigate +4 Combat (Combat:4) + BlackTotoro < Imperial Frigate +1 Discard (Discarding: 1) + randomized > Imperial Frigate +2 Combat (Combat:6) +Played Missile Bot +randomized is scrapping: Scout + randomized > Missile Bot +2 Combat (Combat:8) + Scrapped Scout + randomized > Missile Bot +2 Combat (Combat:10) +Played Blob Fighter + randomized > Blob Fighter +3 Combat (Combat:13) +Attacked Space Station + randomized - -4 Combat (Combat:9) + Destroyed Space Station +Attacked BlackTotoro for 9 (New Authority:39) + randomized - -9 Combat (Combat:0) + BlackTotoro - -9 Authority (Authority:39) +Scrapping Survey Ship + Scrapped Survey Ship + BlackTotoro < Survey Ship +1 Discard (Discarding: 2) +randomized ends turn 17 + Drew 3 cards. + Shuffled discard pile to form new deck + Drew 2 cards. + Refresh ally indicators + It is now BlackTotoro's turn 18 +Resolving Discard 2 cards +BlackTotoro is discarding Scout +BlackTotoro is discarding Scout + no more cards to discard + Discarded Scout + Discarded Scout +Played Dreadnaught + BlackTotoro > Dreadnaught +7 Combat (Combat:7) + Drew 1 cards. +Played Mining Mech +BlackTotoro is scrapping: Scout + BlackTotoro > Mining Mech +3 Trade (Trade:3) + Scrapped Scout +Played Embassy Yacht + BlackTotoro > Embassy Yacht +3 Authority (Authority:42) + BlackTotoro > Embassy Yacht +2 Trade (Trade:5) +Played Scout + BlackTotoro > Scout +1 Trade (Trade:6) +Attacked Machine Base + BlackTotoro - -6 Combat (Combat:1) + Destroyed Machine Base +Acquired Flagship + BlackTotoro - -6 Trade (Trade:0) +Attacked randomized for 1 (New Authority:26) + BlackTotoro - -1 Combat (Combat:0) + randomized - -1 Authority (Authority:26) +BlackTotoro ends turn 18 + Drew 5 cards. + Refresh ally indicators + It is now randomized's turn 19 +Played Imperial Fighter + randomized > Imperial Fighter +2 Combat (Combat:2) + BlackTotoro < Imperial Fighter +1 Discard (Discarding: 1) +Played Imperial Frigate + randomized > Imperial Frigate +4 Combat (Combat:6) + BlackTotoro < Imperial Frigate +1 Discard (Discarding: 2) + randomized > Imperial Fighter +2 Combat (Combat:8) + randomized > Imperial Frigate +2 Combat (Combat:10) +Scrapping Imperial Frigate + Scrapped Imperial Frigate + Drew 1 cards. +Played Blob Fighter + randomized > Blob Fighter +3 Combat (Combat:13) +Played Ram + randomized > Ram +5 Combat (Combat:18) + Drew 1 cards. + randomized > Ram +2 Combat (Combat:20) +Played Scout + randomized > Scout +1 Trade (Trade:1) +Acquired Unity Fighter + randomized - -1 Trade (Trade:0) +Played Solar Skiff + randomized > Solar Skiff +2 Trade (Trade:2) +Played Scout + randomized > Scout +1 Trade (Trade:3) +Acquired Blob Wheel + randomized - -3 Trade (Trade:0) +Attacked BlackTotoro for 20 (New Authority:22) + randomized - -20 Combat (Combat:0) + BlackTotoro - -20 Authority (Authority:22) +randomized ends turn 19 + Drew 5 cards. + Refresh ally indicators + It is now BlackTotoro's turn 20 +Resolving Discard 2 cards +BlackTotoro is discarding Scout +BlackTotoro is discarding Viper + no more cards to discard + Discarded Scout + Discarded Viper +Played Mech Cruiser +BlackTotoro is scrapping: Viper + BlackTotoro > Mech Cruiser ability available + BlackTotoro > Mech Cruiser +6 Combat (Combat:6) + Scrapped Viper +Played Peacekeeper + BlackTotoro > Peacekeeper +6 Combat (Combat:12) + BlackTotoro > Peacekeeper +6 Authority (Authority:28) +Played Federation Shuttle + BlackTotoro > Federation Shuttle +2 Trade (Trade:2) + Drew 1 cards. + BlackTotoro > Federation Shuttle +4 Authority (Authority:32) +Played Unity Fighter + BlackTotoro > Unity Fighter ability available + BlackTotoro > Unity Fighter +3 Combat (Combat:15) + Scrapped Blob World +Acquired Cutter + BlackTotoro - -2 Trade (Trade:0) +Attacked randomized for 15 (New Authority:11) + BlackTotoro - -15 Combat (Combat:0) + randomized - -15 Authority (Authority:11) +BlackTotoro ends turn 20 + Drew 4 cards. + Shuffled discard pile to form new deck + Drew 1 cards. + Refresh ally indicators + It is now randomized's turn 21 +Played Battle Blob + randomized > Battle Blob +8 Combat (Combat:8) +Played Viper + randomized > Viper +1 Combat (Combat:9) +Played Trade Hauler + randomized > Trade Hauler +3 Trade (Trade:3) +Played Scout + randomized > Scout +1 Trade (Trade:4) +Acquired Gunship + randomized - -4 Trade (Trade:0) +Scrapping Battle Blob + Scrapped Battle Blob + randomized > Battle Blob +4 Combat (Combat:13) +Attacked BlackTotoro for 13 (New Authority:19) + randomized - -13 Combat (Combat:0) + BlackTotoro - -13 Authority (Authority:19) +randomized ends turn 21 + Drew 4 cards. + Shuffled discard pile to form new deck + Drew 1 cards. + Refresh ally indicators + It is now BlackTotoro's turn 22 +Played Peacekeeper + BlackTotoro > Peacekeeper +6 Combat (Combat:6) + BlackTotoro > Peacekeeper +6 Authority (Authority:25) +Played Scout + BlackTotoro > Scout +1 Trade (Trade:1) +Played Scout + BlackTotoro > Scout +1 Trade (Trade:2) +Played Scout + BlackTotoro > Scout +1 Trade (Trade:3) +Played Trade Bot + BlackTotoro > Trade Bot +1 Trade (Trade:4) +Acquired Frontier Ferry + BlackTotoro - -4 Trade (Trade:0) +Attacked randomized for 6 (New Authority:5) + BlackTotoro - -6 Combat (Combat:0) + randomized - -6 Authority (Authority:5) +BlackTotoro ends turn 22 + Drew 5 cards. + Refresh ally indicators + It is now randomized's turn 23 +Played Missile Bot +randomized is scrapping: Scout + randomized > Missile Bot +2 Combat (Combat:2) + Scrapped Scout +Played Scout + randomized > Scout +1 Trade (Trade:1) +Acquired Battle Bot + randomized - -1 Trade (Trade:0) +Played Viper + randomized > Viper +1 Combat (Combat:3) +Attacked BlackTotoro for 3 (New Authority:22) + randomized - -3 Combat (Combat:0) + BlackTotoro - -3 Authority (Authority:22) +randomized ends turn 23 + Drew 5 cards. + Refresh ally indicators + It is now BlackTotoro's turn 24 +Played Dreadnaught + BlackTotoro > Dreadnaught +7 Combat (Combat:7) + Drew 1 cards. +Played Space Station + BlackTotoro > Space Station +2 Combat (Combat:9) + BlackTotoro > Space Station +2 Combat (Combat:11) +Played Embassy Yacht + BlackTotoro > Embassy Yacht +3 Authority (Authority:25) + BlackTotoro > Embassy Yacht +2 Trade (Trade:2) +Attacked randomized for 11 (New Authority:-6) + BlackTotoro - -11 Combat (Combat:0) + randomized - -11 Authority (Authority:-6) + === BlackTotoro has won the game. === diff --git a/parse.php b/parse.php new file mode 100644 index 0000000..b370a82 --- /dev/null +++ b/parse.php @@ -0,0 +1,71 @@ + + + + + +EOF; +print $form ; + + +} +else { + $ext=array() ; + $cards=array() ; + $csvfile = fopen('cards.csv', "r") or die( "unable to open card file" ) ; + while( $line = fgetcsv( $csvfile ) ){ + array_push( $ext, $line[0] ); + array_push( $cards, $line[2] ) ; + } + + $turns = 0 ; + $winner = "" ; + $first = "" ; + $data = trim( $_POST["log"] ) ; + $data_ar = preg_split("/\r\n|\n|\r/", $data); + + foreach ($data_ar as $line ) { + if( strpos( $line, "ends turn" ) ) { + static $turns ; + $turns++ ; + } + + if ( strpos( $line, "ends turn 1" ) ) { + $line_a = explode( " ", "$line" ) ; + $winner = $line_a[0] ; + } + + if( preg_match( '/^Played (.*)<\/color>/', $line, $match ) ) { + guessExpansion( $match[1], $cards, $ext ) ; + } + + if ( strpos( $line, "===" ) ) { + $line_a = explode( " ", "$line" ) ; + $first = $line_a[9] ; + } + + } + echo "
" ; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "first player is: $first
"; + echo "winner is: $winner
" ; + echo "num of turns: $turns
" ; + +} +function guessExpansion( $card, $cards, $ext ) { + if( $key = array_search( $card, $cards)){ + print( $ext[$key]."
" ) ; + } +}