00001 00008 /* 00009 This file is part of Teapot Colony Wars. 00010 00011 Teapot Colony Wars is free software: you can redistribute it and/or modify 00012 it under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 2 of the License, or 00014 (at your option) any later version. 00015 00016 Teapot Colony Wars is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 GNU General Public License for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with Teapot Colony Wars. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 00025 #ifndef VISUALCONTEXT_H 00026 #define VISUALCONTEXT_H 00027 00028 #include <vector> 00029 #include <list> 00030 00031 #include "MoveCommand.h" 00032 00033 class World; 00034 class Cell; 00035 class Worshiper; 00036 class WorshiperInfo; 00037 class MoveIterator; 00038 00042 class VisualContext 00043 { 00044 protected: 00045 00046 friend class World; 00047 00049 World * _world; 00050 00052 Worshiper * _worshiper; 00053 00055 int _i; 00056 00058 int _j; 00059 00066 Cell* getCell(std::pair<int,int> p) const; 00067 00074 Cell* getCell(move_command cmd) const; 00075 00082 Cell* getCell(const MoveIterator& i) const; 00083 00093 std::vector<unsigned int> getPheromones(Cell * c) const; 00094 00103 std::list<WorshiperInfo> getWorshipers(Cell * c) const; 00104 00111 bool haveFood(Cell * c) const; 00112 00113 public: 00114 00122 VisualContext(World * w, int i, int j); 00123 00127 virtual ~VisualContext(); 00128 00134 void setWorshiper(Worshiper * w); 00135 00143 bool legal(int i, int j) const; 00144 00151 bool legal(std::pair<int,int> p) const; 00152 00159 bool legal(const MoveIterator& i) const; 00160 00170 std::vector<unsigned int> getPheromones(move_command cmd) const; 00171 00181 std::vector<unsigned int> getPheromones(const MoveIterator& i) const; 00182 00191 std::list<WorshiperInfo> getWorshipers(move_command cmd) const; 00192 00201 std::list<WorshiperInfo> getWorshipers(const MoveIterator& i) const; 00202 00209 bool haveFood(move_command cmd) const; 00210 00217 bool haveFood(const MoveIterator& i) const; 00218 00225 bool reachable(move_command cmd) const; 00226 00233 bool reachable(const MoveIterator& i) const; 00234 00241 move_command opposite(move_command cmd) const; 00242 00249 move_command opposite(const MoveIterator& i) const; 00250 00256 MoveIterator beginMove() const; 00257 00263 MoveIterator endMove() const; 00264 00270 unsigned int nbMovements() const; 00271 }; 00272 00273 #endif // VISUALCONTEXT_H