public void Process(char c, ref IProcess step) { if (char.IsDigit(c)) { if (this.result.HalfMoveCount == null) { this.result.HalfMoveCount = $"{c}"; this.found = true; } else { this.result.HalfMoveCount += $"{c}"; } } else if (c == ' ') { if (!this.found) { this.result.Error = true; step = null; } else { step = new FullMoves(this.result); } } else { // Unexpected char. this.result.Error = true; step = null; } }
/// <summary> /// Converts the ChessState to a FEN board /// </summary> /// <returns>FEN board</returns> public string ToFenBoard() { StringBuilder strBuild = new StringBuilder(); strBuild.Append(CurrentBoard.ToPartialFenBoard()); if (CurrentPlayerColor == ChessColor.White) { strBuild.Append(" w"); } else { strBuild.Append(" b"); } //place holder for castling (not currently supported) strBuild.Append(" " + CastlingToFen()); //place holder for en passant (not currently supported) strBuild.Append(EnPassantToFen()); //half and full moves strBuild.Append(" " + HalfMoves.ToString() + " " + FullMoves.ToString()); return(strBuild.ToString()); }