From cb6aae6c2b050ddc7f7c64db508aef7c537cd96b Mon Sep 17 00:00:00 2001 From: MarcUs7i Date: Mon, 28 Oct 2024 18:41:32 +0100 Subject: [PATCH] Declared all functions --- assignment/chess.c | 10 +++++++- assignment/chess.h | 50 ++++++++++++++++++++++++++++++++++++++ assignment/chess_printer.c | 1 + assignment/test_chess.c | 1 + 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/assignment/chess.c b/assignment/chess.c index daab039..64b1e7a 100644 --- a/assignment/chess.c +++ b/assignment/chess.c @@ -1,7 +1,15 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Klasse + * HTBLA-Leonding / 2IHIF * --------------------------------------------------------- * Description: * Implementation of basic chess functions. * ---------------------------------------------------------- */ + +#include +#include +#include + +#include "chess.h" +#include "chess_printer.h" + diff --git a/assignment/chess.h b/assignment/chess.h index 338ca64..3888e60 100644 --- a/assignment/chess.h +++ b/assignment/chess.h @@ -5,3 +5,53 @@ * Basic chess functions. * ---------------------------------------------------------- */ + +#ifndef ___CHESS_H +#define ___CHESS_H + +#include +#include + +#include "chess_printer.h" + +#define CHESSBOARD_LENGTH 8 +typedef struct ChessSquare ChessBoard[CHESSBOARD_LENGTH][CHESSBOARD_LENGTH]; + +typedef enum { + Pawn, + Knight, + Bishop, + Rook, + Queen, + King, + NoPiece +} PieceType; + +typedef enum { + White, + Black, + NO_COLOR +} Color; + +typedef enum { + NormalMove, + CaptureMove +} MoveType; + +struct ChessPiece { + PieceType type; + Color color; +}; + +struct ChessSquare { + bool is_occupied; + struct ChessPiece piece; +}; + +typedef char File; +typedef int Rank; + +struct ChessPiece get_piece(ChessBoard chess_board, File file, Rank rank); +bool squares_share_pawns_move(Color color, MoveType move, File filePiece1, Rank rankPiece1, File filePiece2, Rank rankPiece2); + +#endif \ No newline at end of file diff --git a/assignment/chess_printer.c b/assignment/chess_printer.c index 70e6577..8fe3e34 100644 --- a/assignment/chess_printer.c +++ b/assignment/chess_printer.c @@ -7,6 +7,7 @@ */ #include #include +#include #include "chess_printer.h" #include "chess.h" diff --git a/assignment/test_chess.c b/assignment/test_chess.c index 182559f..e2cb837 100644 --- a/assignment/test_chess.c +++ b/assignment/test_chess.c @@ -5,6 +5,7 @@ * Test functions for chess. * ---------------------------------------------------------- */ +#include #include "shortcut.h" #include "test_chess.h" #include "chess.h"