X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=Position.pm;h=371e179b8139d9541b85d874917cbc1255ee1768;hp=777571e121d1ba5fc7301d54a6a6b7e1926cb202;hb=74d7aba567761212303524b6db6284e3a13a6a6a;hpb=2187ba0a0e12b8e751524491e25905d7ecc2e07b diff --git a/Position.pm b/Position.pm index 777571e..371e179 100644 --- a/Position.pm +++ b/Position.pm @@ -4,6 +4,7 @@ # use strict; use warnings; +use MIME::Base64; require 'Board.pm'; @@ -36,6 +37,8 @@ sub new { sub start_pos { my ($class, $white, $black) = @_; + $white = "base64:" . MIME::Base64::encode_base64($white); + $black = "base64:" . MIME::Base64::encode_base64($black); return $class->new("<12> rnbqkbnr pppppppp -------- -------- -------- -------- PPPPPPPP RNBQKBNR W -1 1 1 1 1 0 dummygamenum $white $black -2 dummytime dummyincrement 39 39 dummytime dummytime 1 none (0:00) none 0 0 0"); } @@ -103,7 +106,14 @@ sub fen { sub to_json_hash { my $pos = shift; - return { %$pos, board => undef, fen => $pos->fen() }; + my $json = { %$pos, board => undef, fen => $pos->fen() }; + if ($json->{'player_w'} =~ /^base64:(.*)$/) { + $json->{'player_w'} = MIME::Base64::decode_base64($1); + } + if ($json->{'player_b'} =~ /^base64:(.*)$/) { + $json->{'player_b'} = MIME::Base64::decode_base64($1); + } + return $json; } sub parse_pretty_move {