#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

#include "raylib.h"

#define PIECE_SIZE 4;

typedef struct square_s{
    int posX;
    int posY;

    Color color;

} square_s;
typedef square_s* Square;

typedef struct Grid{
    Square** grid;

    int width;
    int height;
} Grid;

typedef struct Piece{
    Square* squares;
    int size;
} Piece;

Grid gridInit();
Grid initSquares(Grid g);
Piece pieceInit();

bool gameOver(Grid grid);
int height(Grid g);
int heightColumn(Square* column, int size);

bool canMove(Piece piece, Grid grid);
bool canMoveSquare(Square sq, Grid g);

void move(Piece piece);
void moveSquare(Square sq);

void addPieceToGrid(Piece piece, Grid grid);
void addSquareToGrid(Square sq, Grid g);

int randInt(int lower, int upper);
Square getSquare(char* line, int index);
Piece getPieceFromLine(char* line);
Piece* getPiecesData();
Piece generePiece(Piece* pieceList);

void displaySquare(Square sq, int pIndex, int pListIndex);
void displayPiece(Piece p, int pListIndex);
void displayPieceList(Piece* pList, int size);

void gameInstructions(Grid grid, Piece* pList);