diff --git a/Pontu/include/model/Game.h b/Pontu/include/model/Game.h index 787b907..346e070 100644 --- a/Pontu/include/model/Game.h +++ b/Pontu/include/model/Game.h @@ -1,7 +1,7 @@ /** * \file Game.h * \brief Management of a Game - * \author Théotime Maillarbaux + * \author Théotime Maillarbaux, Jacques Thomas * \date 29/11/2021 */ @@ -11,6 +11,7 @@ #include "model/Player.h" #include "model/Board.h" #include +#include /** * \enum Phase @@ -41,5 +42,39 @@ typedef struct { */ Game newGame(const int nbPlayers, const char* pseudos[]); +/** + * \brief Move a piece to an island + * \param[in] p the piece to move + * \param[in] i island target + * \return True if the piece can be move otherwise false + */ + +bool movePiece(Piece p, Island i); + + +/** + * \brief Check if the the island is attainable from the piece's position (no player on the island) + * \param[in] p the piece to move + * \param[in] i island target + * \return True if the island is attainable (no player on the island) otherwise false + */ +bool checkIsland(Piece p, Island i); + + +/** + * \biref Check if there is a bridge at (coord->x; coord->y) + * \param[in] coords Coords to test + * \param[in] board Actual game board + * \return True if there is a bridge. Else return false. + */ +bool checkBridge(Coord* coords, Board* board); + +/** + * \brief Remove bridge from board at (coord->x; coord->y) + * \param[in] coords Bridge's coords to remove + * \param[in] board Actual game board + * \return True on succsess. Else return false. + */ +bool rmBridge(Coord* coords, Board* board); #endif //PARTIE_H diff --git a/Pontu/include/model/Island.h b/Pontu/include/model/Island.h index 8b0b246..dee0caa 100644 --- a/Pontu/include/model/Island.h +++ b/Pontu/include/model/Island.h @@ -1,7 +1,7 @@ /** *\file Island.h *\brief Island's model - *\author Jacques + *\author Jacques Thomas *\date 29/11/2021 */ diff --git a/Pontu/include/model/Piece.h b/Pontu/include/model/Piece.h index 2948d6d..535cf43 100644 --- a/Pontu/include/model/Piece.h +++ b/Pontu/include/model/Piece.h @@ -1,7 +1,7 @@ /** *\file Piece.h *\brief Piece's model - *\author Jacques + *\author Jacques Thomas *\date 29/11/2021 */ diff --git a/Pontu/src/model/Board.c b/Pontu/src/model/Board.c index c427b6f..da68406 100644 --- a/Pontu/src/model/Board.c +++ b/Pontu/src/model/Board.c @@ -5,7 +5,7 @@ Board newBoard(const int nbPlayers) { int nbPiecesPerPlayer = (nbPlayers == 4) ? 2 : 3; int pieceIndex = 0; - // Init pieces + // Init pieces for each player for (int player_i = 0; player_i < nbPlayers; player_i++) { for (int piece_i = 0; piece_i < nbPiecesPerPlayer; piece_i++) { board.arrPieces[pieceIndex] = newPiece(player_i); @@ -19,8 +19,12 @@ Board newBoard(const int nbPlayers) { for (int vy = 0; vy < 4; vy++) { for (int vx = 0; vx < 5; vx++) { board.vBridges[vy][vx] = true; - board.hBridges[vx][vy] = false; + board.hBridges[vx][vy] = true; } } return board; } + + + + diff --git a/Pontu/src/model/Game.c b/Pontu/src/model/Game.c index dac2c7f..f978391 100644 --- a/Pontu/src/model/Game.c +++ b/Pontu/src/model/Game.c @@ -24,3 +24,44 @@ Game newGame(const int nbPlayers, const char* pseudos[]) { return g; } + +bool movePiece(Piece p, Island i) +{ + return checkIsland(p,i) && checkBridge(p,i); //Otherwise call one function before one other +} + +//Not yet over +bool checkIsland(Piece p, Island i) +{ + bool check; + int diff; + if(p.island.x==i.x) //piece and island are on the same x axe + { + diff=p.island.y-i.y; + return -1x%2 == 1) && (coords->y%2 == 0)) + { + return board->hBridge[coord->y][coord->x]; + } + if((coords->x%2 == 0) && (coords->y%2 == 1)) + { + return board->vBridge[coord->y][coord->x]; + } + return false; +} + +