00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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