|
|
|
@ -71,6 +71,7 @@ Position notation_tile_to_position(TileNotation notation) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Converts notated tile into its string representation
|
|
|
|
|
char* notation_tile_to_string(TileNotation tile) { |
|
|
|
|
char* notation = (char*) malloc(sizeof(char) * 2); |
|
|
|
|
if (!notation) { |
|
|
|
@ -83,6 +84,8 @@ char* notation_tile_to_string(TileNotation tile) {
|
|
|
|
|
return notation; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Converts notated tile into its string representation on dest
|
|
|
|
|
void notation_tile_to_string_cpy(TileNotation tile, char* dest) { |
|
|
|
|
if (!dest) { |
|
|
|
|
return; |
|
|
|
@ -96,6 +99,7 @@ void notation_tile_to_string_cpy(TileNotation tile, char* dest) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Converts notated tile string into its corresponding structure
|
|
|
|
|
TileNotation notation_tile_from_string(const char* tile_string) { |
|
|
|
|
if (!tile_string) { |
|
|
|
|
return notation_tile_new('a', 1); |
|
|
|
@ -109,6 +113,7 @@ TileNotation notation_tile_from_string(const char* tile_string) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Creates a new notation tile from given file and rank.
|
|
|
|
|
TileNotation notation_tile_new(char file, unsigned int rank) { |
|
|
|
|
TileNotation tile; |
|
|
|
|
tile.file = file; |
|
|
|
@ -118,7 +123,7 @@ TileNotation notation_tile_new(char file, unsigned int rank) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Converts
|
|
|
|
|
// Converts position to a notated position
|
|
|
|
|
TileNotation notation_tile_from_pos(Position pos) { |
|
|
|
|
TileNotation tile;
|
|
|
|
|
switch (pos.row) { |
|
|
|
@ -263,6 +268,7 @@ Piece notation_piece_from_char(char character) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Converts notated move into its string representation
|
|
|
|
|
char* notation_move_to_string(MoveNotation move) { |
|
|
|
|
char* move_notation = (char*) malloc(sizeof(char) * 10); |
|
|
|
|
if (!move_notation) { |
|
|
|
@ -371,7 +377,16 @@ MoveNotation* notation_move_from_string(const char* move_string) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MoveNotation notation_move_new(Piece piece, TileNotation origin, TileNotation target, int move_type); |
|
|
|
|
// Creates a new move notation from provided arguments
|
|
|
|
|
MoveNotation notation_move_new(Piece piece, TileNotation origin, TileNotation target, int move_type) { |
|
|
|
|
MoveNotation move_new; |
|
|
|
|
move_new.piece = piece; |
|
|
|
|
move_new.origin = origin; |
|
|
|
|
move_new.target = target; |
|
|
|
|
move_new.move_type = move_type; |
|
|
|
|
|
|
|
|
|
return move_new; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Converts move notation to a move
|
|
|
|
|