// Match3 Board - Version 1.0
// Created: 28/10/2017 11:46:51
// John Ryland (jryland@xiaofrog.com)
// InvertedLogic, (C) Copyright 2017
#pragma once
#include <stdint.h>
struct Board
{
int m_width, m_height;
int *m_board; // Tile ID
};
struct BoardPosition
{
uint8_t x, y;
};
struct BoardMatch
{
BoardPosition pos;
uint8_t offsets[5];
uint8_t lengths[5];
};
// Various constructors - TODO: rename all create* functions to init*
bool createBoard(Board& a_board, int a_width, int a_height);
bool generateRandomBoard(Board& a_board, int a_width, int a_height, int a_numTileTypes);
bool generateBoardWithNoMatch3s(Board& a_board, int a_width, int a_height, int a_numTileTypes);
bool generatePlayableBoard(Board& a_board, int a_width, int a_height, int a_numTileTypes);
// Free up board allocations
void destroyBoard(Board& a_board);
// For debugging
void printBoard(const Board& a_board);
// Is the board set up with existing matches - possibly this won't be needed eventually
bool hasAMatch3(const Board& a_board);
bool getMatch3(const Board& a_board, int& x1, int& y1, int& x2, int& y2, int& x3, int& y3);
bool getMatches(const Board& a_board, BoardMatch& a_matches);
// Assumes no match3 on the board - they have been cleared
bool hasMoveAvailable(const Board& a_board);
// Returns true if swapping the tiles will create a match
bool canSwapTiles(const Board& a_board, int x1, int y1, int x2, int y2);