]> git.sesse.net Git - remoteglot/blobdiff - Position.pm
Fix the red note on moves where we have no historic analysis.
[remoteglot] / Position.pm
index 90e7c1ccc07f649d66b081cb8e01f0a33cb70622..9333bcd58af514badb9a7b31463a4c00763da609 100644 (file)
@@ -112,7 +112,14 @@ sub fen {
 
 sub to_json_hash {
        my $pos = shift;
-       my $json = { %$pos, board => undef, prettyprint_cache => undef, fen => $pos->fen() };
+       my $json = { %$pos, fen => $pos->fen() };
+       delete $json->{'board'};
+       delete $json->{'prettyprint_cache'};
+       delete $json->{'black_castle_k'};
+       delete $json->{'black_castle_q'};
+       delete $json->{'white_castle_k'};
+       delete $json->{'white_castle_q'};
+       delete $json->{'time_since_100move_rule_reset'};
        if ($json->{'player_w'} =~ /^base64:(.*)$/) {
                $json->{'player_w'} = MIME::Base64::decode_base64($1);
        }
@@ -195,6 +202,16 @@ sub make_move {
        return bless $np;
 }
 
+# Returns a new Position object, and the parsed UCI move.
+sub make_pretty_move {
+       my ($pos, $move) = @_;
+
+       my ($from_row, $from_col, $to_row, $to_col, $promo) = $pos->parse_pretty_move($move);
+       my $uci_move = Board::move_to_uci_notation($from_row, $from_col, $to_row, $to_col, $promo);
+       $pos = $pos->make_move($from_row, $from_col, $to_row, $to_col, $promo);
+       return ($pos, $uci_move);
+}
+
 sub _pos_to_square {
         my ($row, $col) = @_;
         return sprintf("%c%d", ord('a') + $col, 8 - $row);