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 WORLD_H 00026 #define WORLD_H 00027 00028 #include <vector> 00029 #include <map> 00030 00031 #include "Drawable.h" 00032 #include "Coord.h" 00033 00034 class Cell; 00035 class Colony; 00036 class Move; 00037 class Worshiper; 00038 class Fight; 00039 00043 class World : public Drawable 00044 { 00045 protected: 00046 00047 friend class VisualContext; 00048 00050 unsigned int _width; 00051 00053 unsigned int _height; 00054 00056 Fight *_fightStrategy; 00057 00059 std::vector<Colony*> _colonies; 00060 00062 std::map<Worshiper*, coord_t> _commandes; 00063 00065 Cell **_map; 00066 00068 Move* _move; 00069 00070 // i : numéro de ligne, j : numéro de colonne 00078 inline Cell*& getCell(unsigned int i, unsigned int j) { 00079 return _map[i * _width + j]; 00080 } 00081 00085 void addNewWorshipers(); 00086 00093 void addPheromone(Cell *cell, Worshiper *w); 00094 00102 void addCommand(Worshiper *w, unsigned int i, unsigned int j); 00103 00107 void makeCommand(); 00108 00115 Cell* fight(Cell *cell); 00116 00122 void feed(Cell *cell); 00123 00124 public: 00125 00133 World(unsigned int width, unsigned int height, unsigned int nb_colonies); 00134 00138 virtual ~World(); 00139 00145 unsigned int getWidth(); 00146 00152 unsigned int getHeight(); 00153 00159 Move* getMove() const; 00160 00167 void addGodsGift(unsigned int i, unsigned int j); 00168 00172 void iteration(); 00173 00177 virtual void draw(); 00178 }; 00179 00180 #endif // WORLD_H