/// <summary> /// 获得棋步的音频字符串 /// </summary> /// <param name="start">起始坐标</param> /// <param name="end">终止坐标</param> /// <returns></returns> public String get_audio_string(Coordinate start, Coordinate end) { ChessColour player = this.current_player; PieceType piece = this[start].type; CoordinateDelta delta = end - start; VerticalLine start_line = ChessPosition.get_vertical_line( start, player); VerticalLine end_line = ChessPosition.get_vertical_line( end, player); MoveDirection direction = ChessPosition.get_move_direction( delta, player); PieceIdentifier id; switch (piece) { default: throw new ArgumentOutOfRangeException("棋子种类越界!"); case PieceType.ADVISOR: case PieceType.BISHOP: return(ChessMove.to_audio_name( player, piece, start_line, direction, end_line)); case PieceType.CANNON: case PieceType.ROOK: case PieceType.PAWN: id = this.get_identifier(start); if (direction == MoveDirection.SIDEWARD) { return(ChessMove.to_audio_name( id, player, piece, start_line, direction, end_line)); } return(ChessMove.to_audio_name( id, player, piece, start_line, direction, delta)); case PieceType.KING: if (direction == MoveDirection.SIDEWARD) { return(ChessMove.to_audio_name( player, piece, start_line, direction, end_line)); } return(ChessMove.to_audio_name( player, piece, start_line, direction, delta)); case PieceType.KNIGHT: id = this.get_identifier(start); return(ChessMove.to_audio_name( id, player, piece, start_line, direction, end_line)); } }
/// <summary> /// 相三进五型 /// </summary> /// <returns></returns> public static String to_audio_name ( ChessColour player, PieceType piece, VerticalLine start, MoveDirection direction, VerticalLine end ) { if (player == ChessColour.NONE || piece == PieceType.NONE) { throw new ArgumentOutOfRangeException("越界!"); } return(($"{player.ToString()[0]}{(char)piece}{start.value}" + $"{direction.to_audio_string()}{end.value}").ToLower()); }
/// <summary> /// 前炮进一型或炮五进一型 /// </summary> /// <returns></returns> public static String to_audio_name ( PieceIdentifier id, ChessColour player, PieceType piece, VerticalLine start, MoveDirection direction, CoordinateDelta delta ) { if (id == PieceIdentifier.NONE) { return(to_audio_name( player, piece, start, direction, delta)); } if (player == ChessColour.NONE || piece == PieceType.NONE) { throw new ArgumentOutOfRangeException("越界!"); } return(($"{id.to_audio_string()}{player.ToString()[0]}{(char)piece}" + $"{direction.to_audio_string()}{Math.Abs(delta.y)}").ToLower()); }