Beispiel #1
0
        public string ToTextBoard()
        {
            var sb = new StringBuilder();

            for (var rank = 7; rank >= 0; rank--)
            {
                for (var file = 0; file < 8; file++)
                {
                    var  loc    = BoardLocation.At(file + 1, rank + 1);
                    var  entity = GetItem(loc)?.Item;
                    char chr;
                    if (entity == null)
                    {
                        chr = '.';
                    }
                    else
                    {
                        chr = ChessPieceNameMapper.ToChar(entity.EntityType, entity.Owner);

                        var epY = char.IsUpper(chr) ? 5 : 4;
                        if (chr == 'p' || chr == 'P' && loc.Y == epY && entity.LocationHistory.Count() == 2)
                        {
                            chr = chr == 'p' ? 'e' : 'E';
                        }
                    }

                    sb.Append(chr == '\0' ? '.' : chr);
                }

                sb.AppendLine();
            }

            return(sb.ToString());
        }
        private string buildExtra(ChessPieceName?promotionPiece)
        {
            if (promotionPiece.HasValue)
            {
                return
                    ($"{SanTokenParser.PromoteNotator.ToString()}{ChessPieceNameMapper.ToChar(promotionPiece.Value, Colours.White)}");
            }

            return(string.Empty);
        }