X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=remoteglot.pl;h=5c22aff4b9cbbb605d851717e3f70358ebb9f18b;hp=c8beaa463d5c58f3ae21f7b884c44257cb4d8d83;hb=2ef4eb46d19d0b41f0be2f60ad78618c197cd487;hpb=fbc73d17f36578f7eb877322ea63a6b488868c69 diff --git a/remoteglot.pl b/remoteglot.pl index c8beaa4..5c22aff 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -309,7 +309,9 @@ sub handle_pgn { push @repretty_moves, $pretty; $pos = $npos; } - $pos->{'result'} = $pgn->result; + if ($pgn->result eq '1-0' || $pgn->result eq '1/2-1/2' || $pgn->result eq '0-1') { + $pos->{'result'} = $pgn->result; + } $pos->{'pretty_history'} = \@repretty_moves; extract_clock($pgn, $pos); @@ -930,13 +932,18 @@ sub output_json { my $white = $other_game_json->{'position'}{'player_w'} // die 'Missing white'; my $black = $other_game_json->{'position'}{'player_b'} // die 'Missing black'; - push @games, { + my $game = { id => $ref->{'id'}, name => "$white–$black", url => $ref->{'url'}, hashurl => $ref->{'hash_url'}, - score => $other_game_json->{'score'} }; + if (defined($other_game_json->{'position'}{'result'})) { + $game->{'result'} = $other_game_json->{'position'}{'result'}; + } else { + $game->{'score'} = $other_game_json->{'score'}; + } + push @games, $game; }; if ($@) { warn "Could not add external game " . $ref->{'json_path'} . ": $@";