Add CheckBridge

merge-requests/1/merge
Allan POINT 4 years ago
parent 419e51867a
commit 6d63c6a402

@ -11,6 +11,7 @@
#include "model/Player.h"
#include "model/Board.h"
#include <SDL2/SDL_pixels.h>
#include <stdbool.h>
/**
* \enum Phase
@ -42,4 +43,20 @@ typedef struct {
Game newGame(const int nbPlayers, const char* pseudos[]);
/**
* \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

@ -24,3 +24,16 @@ Game newGame(const int nbPlayers, const char* pseudos[]) {
return g;
}
bool checkBridge(Coord* coords, Board* board)
{
if((coords->x%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;
}

Loading…
Cancel
Save