
/*****************************************************
 **                                                 **
 **     CSC444F - Software Engineering              **
 **     Board Management and Scoring Module         **
 **                                                 **
 **     Team name:   NoName[tm]                     **
 **     Members:     Ian Chesal, Jacob Dalton,      **
 **                  Peter Yeung, Ketan Padalia     **
 **                                                 **
 *****************************************************/



/**** NOTE ****
 *
 * This header file is made available to you in order to
 * make you aware of the interface that will be required
 * to integrate with our code, as well as to spur healthy
 * discussion on the best possible interfaces.
 * You are free to distribute this and only this file to
 * others as long as it is distributed exactly as is,
 * free of charge and with this note as well as the NoName[tm]
 * banner at the top of the file or printout.
 *
 **************/



/* FILE: bms.h
 *
 * This file exports all the routines that are provided
 * as part of the Board Management and Scoring module
 * bms.c.
 */


/************ Types and defines exported to other modules *************/


#define BMS_INVALID -1
#define TRAYLENGTH 7

/* This value is used to mark uninitialized or invalid fields
 * in structures, etc.
 */


#define BOARD_X_SIZE 15
#define BOARD_Y_SIZE 15

/* These two defines describe the width and the height of the board in the game.
 * The board thus has coordinates of (0,0) in the bottom left corner, and
 * (BOARD_X_SIZE-1, BOARD_Y_SIZE-1) in the top right corner.
 *
 * NOTE - If these dimensions are not specified such that the board has
 * exactly 1 square in the center of the board (ie. the dimensions are odd),
 * the move legality checker will not work properly.
 */


#define BMS_MAX_MOVES_IN_LIST 7

/* This number is the maximum number of tiles that can be placed in
 * a move.
 */


typedef enum {
   BMS_SCORE_MULT_DOUBLE_LETTER, BMS_SCORE_MULT_TRIPLE_LETTER,
   BMS_SCORE_MULT_DOUBLE_WORD, BMS_SCORE_MULT_TRIPLE_WORD, BMS_SCORE_MULT_NONE,
   NUM_BMS_SCORE_MULTS
} e_score_mults;

/* This enumerated type describes the different types of score multipliers
 * that are allowed to exist on a tile on the board.
 */


typedef enum {
   BMS_PLACE_MOVE, BMS_SWAP_MOVE, NUM_BMS_MOVE_TYPES
} e_move_type;

/* This enumerated type describes the type of move being made.
 * The BMS module assumes that the moves passed to it are
 * PLACE_MOVEs.
 */


typedef struct {
   int x;
   int y;
} t_grid_loc;

/* This structure describes a grid location in (x,y) coordinates.
 * The coordinate system is assumed to be 0-based with (0,0)
 * located at the top-left corner of the board.
 */


typedef struct {
   signed char letter;
   t_grid_loc grid_ref;
   int move_base_value;
} t_move;

/* This structure describes a single move, which includes a letter tile
 * as well as a grid location where the tile is being moved.
 * move_base_value should be 0 when a blank tile is being sent in.
 */


typedef struct {
   t_move *moves;  /* [0..num_moves-1] */
   int num_moves;
   e_move_type move_type;
} t_move_list; 

/* This structure describes a list of num_moves moves that are being performed
 * together.
 */


typedef struct {
   signed char **words;	/* [0..num_words-1][0..strlen(words[iword])] */
   int num_words;
} t_word_list;

/* This structure describes a list of num_words words.
 */


/************ Exported subroutine declarations ********************/


/* The functionality of all of these routines can be found in the
 * software specs handed out in class.
 * Comments on the details of using these routines and the assumptions
 * made in our code can be found in the function-level comments in the
 * definitions of each of the routines.
 */

int AddBMove (t_move_list BMove);

void InitialiseBoard (void);

e_score_mults SquareScore (t_grid_loc GridRef);

int RemoveTile (t_grid_loc GridRef);

int CheckBMove (t_move_list BMove);

int ScoreBMove (t_move_list BMove);

t_word_list NewWords (t_move_list BMove);

int EmptySquare (t_grid_loc GridRef);

signed char TileSquare (t_grid_loc GridRef);

t_move_list LastMove (void);

void setLastMoveNULL(void);

void SetNewBoard(t_move a[][BOARD_Y_SIZE]);

void setLastMove(t_move_list *a);



