/****************************************************************************
 Header file for Gameplay Module
 ****************************************************************************/

#ifndef SMGameplay_H
#define SMGameplay_H

// Event Definitions
#include "SMEvents.h"

//Children includes
#include "SMToDispenser.h"
#include "SMRequestBall.h"
#include "SMShoot.h"
#include "SMBeaconDetection.h"

// typedefs for the states
typedef enum { Play_DeterminingField, Play_ToDispenser, Play_AtDispenser} PlayState_t ;


// Public Function Prototypes

//state machine functions
Event_t RunPlaySM( Event_t CurrentEvent );
void StartPlaySM ( Event_t CurrentEvent );
PlayState_t QueryPlaySM ( void );

//other functions

/****************************************************************************
 Function
 SetColor

 Description
 Reads color switch and sets MyColor, MyHoop and DispenserNearHoop accordingly.
 ****************************************************************************/
void SetColor(void);

/****************************************************************************
Function
SetHalfCourt

Description
reads half court switch and sets HalfCourt indicator accordingly.
****************************************************************************/
void SetHalfCourt(void);

/****************************************************************************
 Function
 QueryPlayTimeout

 Returns
 1 if state timer has expired, 0 otherwsie
 ****************************************************************************/
unsigned char QueryPlayTimeout (void);

/****************************************************************************
 Function
 QueryToDispenserFlag

 Returns
 1 if the robot should make a transition from AtDispenser to ToDispenser, 0
 otherwise.

 Description
 If state is AtDispenser, and the dispenser is empty, then when we aren't
 shooting then the function returns 1 indicating we should move.
 ****************************************************************************/
unsigned char QueryToDispenserFlag(void);

/****************************************************************************
 Function
 QueryCurrentDispenserNumber

 Returns
 Number of current target dispenser
 ****************************************************************************/
unsigned char QueryCurrentDispenserNumber(void);

/****************************************************************************
 Function
 QueryCurrentDispenserBeacon

 Returns
 Beacon_t beacon of current dispenser
 ****************************************************************************/
Beacon_t QueryCurrentDispenserBeacon(void);

/****************************************************************************
 Function
 QueryLastDispenserNumber

 Returns
 Number of previous target dispenser
 ****************************************************************************/
unsigned char QueryLastDispenserNumber(void);

/****************************************************************************
 Function
 SetLastDispenserNumber

 Parameters
 unsigned char Number

 Description
 Allows the overriding of the last dispenser
 ****************************************************************************/
void SetLastDispenserNumber(unsigned char Number);

/****************************************************************************
 Function
 QueryMyHoop

 Returns
 Beacon_t beacon of my hoop
 ****************************************************************************/
Beacon_t QueryMyHoop (void);

/****************************************************************************
 Function
 QueryNearestHoop

 Parameters
 unsigned char Dispenser

 Returns
 Beacon_t beacon of hoop nearest to dispenser, for alignment
 ****************************************************************************/
Beacon_t QueryNearestHoop(unsigned char Dispenser);

/****************************************************************************
 Function
 QueryDispenserNearHoop

 Returns
 1 if current dispenser is near hoop, 0 otherwsie
 ****************************************************************************/
unsigned char QueryDispenserNearHoop(void);

/****************************************************************************
 Function
 QueryTrackingAngle

 Parameters
 unsigned chars LastDispenser, NextDispenser

 Returns
 signed char Angle - angle to set turret to to track between dispensers
 ****************************************************************************/
signed char QueryTrackingAngle(unsigned char LastDispenser, unsigned char NextDispenser);

/****************************************************************************
 Function
 QueryShotAngle

 Parameters
 unsigned char Dispenser

 Returns
 signed char Angle - angle to set turret to to shoot from Dispenser
 ****************************************************************************/
signed char QueryShotAngle(unsigned char Dispenser);
#endif /*SMGameplay_H */