]> git.sesse.net Git - remoteglot/blobdiff - Position.pm
Format the short score (for the page title) properly from the backend instead of...
[remoteglot] / Position.pm
index 9868b218e6c4e2b74b5d2a21eeb8623d849d1295..90e7c1ccc07f649d66b081cb8e01f0a33cb70622 100644 (file)
@@ -35,6 +35,7 @@ sub new {
                $pos->{'last_move_uci'} = undef;
        }
        $pos->{'last_move'} = $x[29];
+       $pos->{'prettyprint_cache'} = {};
 
        bless $pos, $class;
        return $pos;
@@ -111,7 +112,7 @@ sub fen {
 
 sub to_json_hash {
        my $pos = shift;
-       my $json = { %$pos, board => undef, fen => $pos->fen() };
+       my $json = { %$pos, board => undef, prettyprint_cache => undef, fen => $pos->fen() };
        if ($json->{'player_w'} =~ /^base64:(.*)$/) {
                $json->{'player_w'} = MIME::Base64::decode_base64($1);
        }
@@ -126,6 +127,11 @@ sub parse_pretty_move {
        return $pos->{'board'}->parse_pretty_move($move, $pos->{'toplay'});
 }
 
+sub num_pieces {
+       my ($pos) = @_;
+       return $pos->{'board'}->num_pieces();
+}
+
 # Returns a new Position object.
 sub make_move {
         my ($pos, $from_row, $from_col, $to_row, $to_col, $promo) = @_;