diff options
author | 2025-05-22 12:22:59 +0200 | |
---|---|---|
committer | 2025-05-22 12:28:13 +0200 | |
commit | 4c3cee6bf51ecba1cd03c457e3facc1947e9fedc (patch) | |
tree | 1abddb955e5a3904c3a90437cdffb6d4adfbf417 | |
parent | baa50758f6f98822db1e01eec3b8f0fc7577fdf5 (diff) | |
download | tris-4c3cee6bf51ecba1cd03c457e3facc1947e9fedc.tar.gz tris-4c3cee6bf51ecba1cd03c457e3facc1947e9fedc.zip |
Add the Board struct
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/main/game/domain/board.c | 45 | ||||
-rw-r--r-- | src/main/game/domain/board.h | 33 |
3 files changed, 80 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d0525d..1232136 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,8 @@ add_executable(tris src/main/engine/types.h src/main/game/cell.h src/main/game/cell.c + src/main/game/domain/board.c + src/main/game/domain/board.h src/main/engine/domain/color.c src/main/engine/domain/color.h) diff --git a/src/main/game/domain/board.c b/src/main/game/domain/board.c new file mode 100644 index 0000000..6859eae --- /dev/null +++ b/src/main/game/domain/board.c @@ -0,0 +1,45 @@ +/*- + * Copyright (C) 2025 Alessandro Iezzi <aiezzi AT alessandroiezzi PERIOD it> + * + * This file is part of Tris Game. + * + * Tris Game is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tris Game is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tris Game. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <stdlib.h> +#include <log.h> +#include "board.h" + +static Log *log = NULL; + +static void +init_log(void) +{ + if (log != NULL) return; + log = log_create("Board"); +} + +Board * +board_new(void) +{ + init_log(); + + Board *board = malloc(sizeof(Board)); + if (board == NULL) { + log_error(log, "Cannot allocate Board struct"); + exit(EXIT_FAILURE); + } + + return board; +} diff --git a/src/main/game/domain/board.h b/src/main/game/domain/board.h new file mode 100644 index 0000000..2d63809 --- /dev/null +++ b/src/main/game/domain/board.h @@ -0,0 +1,33 @@ +/*- + * Copyright (C) 2025 Alessandro Iezzi <aiezzi AT alessandroiezzi PERIOD it> + * + * This file is part of Tris Game. + * + * Tris Game is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Tris Game is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tris Game. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __GAME_BOARD_H__ +#define __GAME_BOARD_H__ + +#include "../../engine/domain/color.h" + +typedef struct { + Color *default_color; + Color *wining_color; + Color *draft_color; +} Board; + +Board *board_new(void); + +#endif /* __GAME_BOARD_H__ */ |