From fab061b07ab05aec325d3e8a0b0e701551120d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Benencia?= Date: Tue, 31 Mar 2015 16:48:03 -0300 Subject: add square getters and setters --- Makefile | 7 +++++-- include/square.h | 12 ++++++++++++ lib/square.c | 21 +++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 include/square.h create mode 100644 lib/square.c diff --git a/Makefile b/Makefile index 59ff03b..b51d597 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,11 @@ CC = gcc CFLAGS = -Wall -Iinclude/ OUTPUT = main MAIN = main.c -DEPS = include/types.h include/board.h include/print.h include/piece.h include/coordinate.h include/move.h include/input.h include/game.h -OBJ = lib/board.o lib/print.o lib/piece.o lib/coordinate.o lib/move.o lib/input.o lib/game.o +DEPS = include/types.h include/board.h include/print.h include/piece.h \ + include/coordinate.h include/move.h include/input.h include/game.h \ + include/square.h +OBJ = lib/board.o lib/print.o lib/piece.o lib/coordinate.o lib/move.o \ + lib/input.o lib/game.o lib/square.o %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) diff --git a/include/square.h b/include/square.h new file mode 100644 index 0000000..254a1e9 --- /dev/null +++ b/include/square.h @@ -0,0 +1,12 @@ +#ifndef _SQUARE +#define _SQUARE + +#include "types.h" + +Color square_get_color(Square); +Piece* square_get_piece(Square); + +Square square_set_color(Square, Color); +Square square_set_piece(Square, Piece*); + +#endif diff --git a/lib/square.c b/lib/square.c new file mode 100644 index 0000000..d7b2d59 --- /dev/null +++ b/lib/square.c @@ -0,0 +1,21 @@ +#include "square.h" + +Color square_get_color(Square s) { + return s.color; +} + +Piece* square_get_piece(Square s) { + return s.piece; +} + +Square square_set_color(Square s, Color c) { + s.color = c; + + return s; +} + +Square square_set_piece(Square s, Piece* p) { + s.piece = p; + + return s; +} -- cgit v1.2.3