Field.hh

00001 /*
00002 ** TowBowlTactics, a turn-based strategy football game.
00003 ** 
00004 ** Copyright (C) 2006-2010 The TBT Team.
00005 ** 
00006 ** This program is free software; you can redistribute it and/or
00007 ** modify it under the terms of the GNU General Public License
00008 ** as published by the Free Software Foundation; either version 2
00009 ** of the License, or (at your option) any later version.
00010 ** 
00011 ** The complete GNU General Public Licence Notice can be found as the
00012 ** `NOTICE' file in the root directory.
00013 ** 
00014 ** The TBT Team consists of people listed in the `AUTHORS' file.
00015 */
00016 
00017 #ifndef FIELD_HH_
00018 # define FIELD_HH_
00019 
00020 # include "Constants.hh"
00021 
00032 enum eDirection {
00033   DIR_UNASSIGNED = 0,
00034 
00035   DIR_NORTHWEST,
00036   DIR_NORTH,
00037   DIR_NORTHEAST,
00038   DIR_EAST,
00039   DIR_SOUTHEAST,
00040   DIR_SOUTH,
00041   DIR_SOUTHWEST,
00042   DIR_WEST,
00043 
00044   DIR_LAST = DIR_WEST
00045 };
00046 
00053 template <typename T>
00054 class Field
00055 {
00056 public:
00057   Field();
00058   virtual ~Field();
00059 
00062   bool          intoField(const Coordinates& coord) const;
00063 
00065   Coordinates dirToCoord(enum eDirection dir) const;
00066 
00069   void          setPlayer(const Coordinates& coord, T* p);
00070 
00072   T*            getPlayer(const Coordinates& coord) const;
00073 
00076   int           getNbPlayersInOppositeHalf(int team_id) const;
00077 
00080   int           getNbPlayersInLeftWideZone(int team_id) const;
00081 
00084   int           getNbPlayersInRightWideZone(int team_id) const;
00085 
00088   int           getNbPlayersOnLineOfScrimmage(int team_id) const;
00089 
00092   int           getNbPlayersInEndZone(int team_id) const;
00093 
00096   int           getNbPlayersInMiddle(int team_id) const;
00097 
00099   int           isPlacementValid(int team_id) const;
00100 
00102   bool          hasAdjacentEmptySquare(const Coordinates& coord) const;
00103 
00105   CoordList       getAdjacentEmptySquares(const Coordinates& coord) const;
00106   
00108   bool          hasAdjacentPlayer(const Coordinates& coord) const;
00109 
00111   bool          hasAdjacentPlayer(const Coordinates& coord, enum eStatus s, int team_id) const;
00112   
00114   std::vector<T*>  getAdjacentPlayers(const Coordinates& coord) const;
00115   
00117   std::vector<T*>  getAdjacentPlayers(const Coordinates& coord, enum eStatus s, int team_id) const;
00118 
00122   int           getNbTackleZones(int team_id, const Coordinates& coord) const;
00123 
00127   int           getTackleZonesMalus(int team_id, const Coordinates& coord) const;
00128 
00134   bool          canAssist(const Coordinates& coord_assister, int team_id,
00135       enum eEffort effort, const Coordinates& coord_target) const;
00141   int           getNbAssister(const Coordinates& coord_assisted, int team_id,
00142       enum eEffort effort, const Coordinates& coord_target) const;
00148   int           getNbBlockDices(const Coordinates& coord_attacker, const Coordinates& coord_target) const;
00153   int           getFoulModifier(const Coordinates& coord_attacker, const Coordinates& coord_target) const;
00154 
00155 
00156 protected:
00157   T*            tab_[COLS * ROWS];
00158 };
00159 
00160 # include "Field.hxx"
00161 
00162 #endif /* !FIELD_HH_ */
Generated on Mon Apr 5 21:17:12 2010 for Stechec/TBT by  doxygen 1.6.3