SPYSpheres
ZRGame.h
Go to the documentation of this file.
00001 #ifndef _ZR_GAME_H_
00002 #define _ZR_GAME_H_
00003 #pragma once
00004 
00005 extern "C" {
00006   #include "pads.h"
00007 }
00008 
00009 #include "Constants.h"
00010 #include "spheres_constants.h"
00011 #include "ZR_API.h"
00012 #include "ZRGameInternal.h"
00013 
00014 
00015 
00016 /** \file ZRGame.h
00017  * Contains documentation of functions specific to the player side of the game.
00018  * Use this documentation to learn about using the API functions available in the challenge.
00019  * General API operations for Zero Robotics are available under ZR_API.h.
00020  *
00021  * Access members of this file by using the syntax "game.functionname(inputs);"
00022  */
00023 
00024 //Forward declaration of the game implementation (not visible)
00025 class ZeroRoboticsGameImpl;
00026 
00027 //Forward declaration of API implementation
00028 class ZeroRoboticsAPIImpl;
00029 
00030 /** \class ZeroRoboticsGame
00031  *
00032  * The class of the game object that you will use. Contains publicly available member functions.
00033  */
00034 class ZeroRoboticsGame {
00035 
00036  public:
00037 
00038   /*!
00039    * Retrieves the singleton instance of the game API.  Users are not allowed to construct a game instance, so the
00040    * API must be retrieved through this interface.
00041    *
00042    * \return singleton of the game API
00043    */
00044   static ZeroRoboticsGame &instance();
00045 
00046 
00047   // DECLARATIONS FOR PUBLIC METHODS AND VARIALBES AVAILABLE TO USERS GO HERE
00048 
00049   /*!
00050    * Tells the player how much fuel remains.
00051    *
00052    * \return float indicating how many seconds of fuel remain.
00053    */
00054   float getFuelRemaining();
00055   
00056   /*!
00057    * Send a value from 0-255 to the other satellite.
00058    * 
00059    * \param inputMsg Unsigned Char to be sent to other satellite.
00060    */
00061   void sendMessage(unsigned char inputMsg);
00062   
00063   /*!
00064    * Recieve value from 0-255 from other satellite.
00065    *
00066    * \return An unsigned char containing a value from 0-255.
00067    */
00068   unsigned char receiveMessage();
00069   
00070   
00071   /**
00072    * Check if the camera is pointed towards the other satellite.
00073    * 
00074    * \return true if the camera is facing the other satellite, false otherwise.
00075    */
00076   bool isFacingOther();
00077   
00078   /**
00079    * Attempts to take a picture in the current position. 
00080    * The camera will be disabled for 3 seconds after an attempt, whether successful or not.
00081    * Costs 1.0 energy.
00082    *
00083    * \return The amount of points that the picture taken is worth.
00084    */
00085   float takePic();
00086   
00087   /**
00088    * Determines how many points a picture would give if taken immediately.
00089    * Does not actually take a picture. Costs 0.1 energy.
00090    * 
00091    * \return The amount of points that the picture is worth.
00092    */
00093   float getPicPoints();
00094   
00095   /**
00096    * Returns how many memory slots are currently in use.
00097    * 
00098    * \return The number of memory slots used.
00099    */
00100   int getMemoryFilled() const;
00101   
00102   /**
00103    * Returns the total number of memory slots available to the satellite.
00104    * This includes both used and unused slots.
00105    * 
00106    * \return Number of memory slots available.
00107    */
00108   int getMemorySize();
00109   
00110   /**
00111    * Attempts to upload pictures taken to Earth.
00112    * Will fail if not facing Earth (3D/Alliance).
00113    * Disables camera for three seconds upon sucessful upload.
00114    * Costs 1.0 energy.
00115    * 
00116    * \return The total score over the course of the game so far.
00117    */
00118   float uploadPics(void);
00119   
00120   /**
00121    * Makes sure the camera is on.
00122    * 
00123    * \return true if the camera is usable, false if not.
00124    */
00125   bool isCameraOn();
00126 
00127   /**
00128    * Tells how much energy the player has.
00129    * 
00130    * \return Amount of energy the player satellite currently has.
00131    */
00132   float getEnergy();
00133   
00134   /**
00135    * Tells how much energy the opponent has, at a cost of 0 energy.
00136    * 
00137    * \return Amount of energy the opponent satellite currently has.
00138    */
00139   float getOtherEnergy();
00140   
00141   
00142   /**
00143    * Returns true if the given coordinate is in the light zone.
00144    * 
00145    * \param pos An array of three floats in (x, y, z) order.
00146    * \return true if the coordinate is in light, false else.
00147    */
00148 
00149   bool posInLight(float pos[]);
00150 
00151   
00152   /**
00153    * Returns true if the given coordinate is in the dark zone.
00154    * 
00155    * \param pos An array of three floats in (x, y, z) order.
00156    * \return true if the coordinate is in dark, false else.
00157    */
00158   bool posInDark(float pos[]);
00159 
00160   /**
00161    * Returns true if the given coordinate is in a grey zone.
00162    * 
00163    * \param pos An array of three floats in (x, y, z) order.
00164    * \return true if the coordinate is in grey, false else.
00165    */
00166 
00167   bool posInGrey(float pos[]);
00168 
00169 /**
00170    * Returns 1 if the given coordinate is in the light, -1 if in the dark, and 0 otherwise.
00171    * 
00172    * \param pos An array of three floats in (x, y, z) order.
00173    * \return 1 if the given coordinate is in the light, -1 if in the dark, and 0 else.
00174    */
00175 
00176   int posInArea(float pos[]);
00177   
00178   /**
00179    * Determines where the center of the grey zone at the tail end of the light zone is. The tail end is at the lower Y-coordinate of the light zone, disregarding any portion that has wrapped around.
00180    * 
00181    * \return The y-coordinate of the light interface plane.
00182    */
00183   float getLightInterfacePosition();
00184   
00185   /**
00186    * Determines where the boundary between the dark zone and the grey zone is.
00187    * 
00188    * \return The y-coordinate of the plane between the dark zone and the grey zone.
00189    */
00190   float getDarkGreyBoundary();
00191   
00192   /**
00193    * Determines where the boundary between the light zone and the grey zone is.
00194    * 
00195    * \return The y-coordinate of the plane between the light zone and the grey zone.
00196    */
00197   float getLightGreyBoundary();
00198   
00199   /**
00200    * Determines how long until the light and dark zones next switch (2D/3D).
00201    * 
00202    * \return Number of seconds until the light switches.
00203    */
00204   float getLightSwitchTime();
00205   
00206   
00207   /**
00208    * Returns the number of total items in play, whether they have been picked up yet or not.
00209    * 
00210    * \return Number of total items.
00211    */
00212   int getNumItem();
00213 
00214   /**
00215    * Uses a held mirror item.
00216    * 
00217    * \return true if the item existed and was used, false otherwise.
00218    */
00219   
00220   bool useMirror();
00221 
00222   /**
00223    * Returns the amount of time left on your current mirror.
00224    * 
00225    * \return remaining time with a mirror up, zero if no mirror is up.
00226    */
00227 
00228   int getMirrorTimeRemaining();
00229 
00230   /**
00231    * Returns the number of mirrors currently held and available for use.
00232    * 
00233    * \return number of mirrors held by the player.
00234    */
00235 
00236   int getNumMirrorsHeld();
00237 
00238   /**
00239    * Copies the location of a given item into the given array.
00240    * 
00241    * \param pos A pointer to an array of size 3 which will be overwritten by the item location.
00242    * \param itemID The integer identifier of a given item.
00243    */
00244   void getItemLoc(float pos[], int itemID);
00245   
00246   /**
00247    * Tells who has a given item.
00248    * 
00249    * \param itemID The integer identifier of a given item.
00250    * \return 0 if you have picked up the specified item, 1 if the other player has, or -1 if no one has.
00251    */
00252   int hasItem(int itemID);
00253   
00254   /**
00255    * Returns what the item does.
00256    * 
00257    * Possible Item Types:
00258    *  - ITEM_TYPE_ADD_SCORE
00259    *  - ITEM_TYPE_ADD_ENERGY
00260    *  - ITEM_TYPE_MIRROR
00261    * 
00262    * \param itemID The integer identifier of a given item.
00263    * \return The corresponding item type to the given identifier.
00264    */
00265   int getItemType(int itemID);
00266   
00267   /**
00268    * Returns the player's current score.
00269    * 
00270    * \return Player satellite score.
00271    */
00272   float getScore();     //returns me.score
00273   
00274   /**
00275    * Returns the opponent's current score.
00276    */
00277   float getOtherScore();    //returns other.score
00278 
00279    /**
00280    * Returns the time.
00281    */
00282   int getCurrentTime();
00283 
00284   //state_vector getOtherState();
00285 
00286   /// Constructor for the game.  The provided references should be singleton instances.
00287   ZeroRoboticsGame(ZeroRoboticsGameImpl &impl, ZeroRoboticsAPIImpl &apiImpl) ;
00288 
00289 private:
00290   /// REQUIRED: reference to the game implementation, do not delete!
00291   ZeroRoboticsGameImpl &pimpl;
00292   ZeroRoboticsAPIImpl &apiImpl;
00293 };
00294 
00295 
00296 #endif