common/Field.hh

00001 /*
00002 ** TowBowlTactics, an adaptation of the tabletop game Blood Bowl.
00003 ** 
00004 ** Copyright (C) 2006, 2007 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 Position& pos) const;
00063 
00065   Position dirToPos(enum eDirection dir) const;
00066 
00069   void          setPlayer(const Position& pos, T* p);
00070 
00072   T*            getPlayer(const Position& pos) const;
00073 
00075   int           isPlacementValid(int team_id) const;
00076 
00078   bool          hasAdjacentEmptySquare(const Position& pos) const;
00079 
00081   PosList       getAdjacentEmptySquares(const Position& pos) const;
00082   
00084   bool          hasAdjacentPlayer(const Position& pos) const;
00085 
00087   bool          hasAdjacentPlayer(const Position& pos, enum eStatus s, int team_id) const;
00088   
00090   std::vector<T*>  getAdjacentPlayers(const Position& pos) const;
00091   
00093   std::vector<T*>  getAdjacentPlayers(const Position& pos, enum eStatus s, int team_id) const;
00094 
00098   int           getNbTackleZones(int team_id, const Position& pos) const;
00099 
00100 protected:
00101   T*            tab_[COLS * ROWS];
00102 };
00103 
00104 # include "Field.hxx"
00105 
00106 #endif /* !FIELD_HH_ */

Generated on Sat Jun 23 16:07:23 2007 for Stechec/TBT by  doxygen 1.4.7