src/ColonyCell.cpp

Go to the documentation of this file.
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 #include "ColonyCell.h"
00026 
00027 #include <list>
00028 
00029 #include "Constants.h"
00030 #include "Worshiper.h"
00031 #include "Colony.h"
00032 
00033 void ColonyCell::getColors(GLubyte &red, GLubyte &green, GLubyte &blue) {
00034   GLubyte *colors;
00035 
00036   colors = _colony->getColor();
00037   red   = colors[0];
00038   green = colors[1];
00039   blue  = colors[2];
00040 }
00041 
00042 ColonyCell::ColonyCell(Colony *colony, unsigned int i, unsigned int j) :
00043     ReachableCell(), _colony(colony), _i(i), _j(j) {
00044   _colony->addCell(this);
00045 }
00046 
00047 ColonyCell::~ColonyCell() {
00048 
00049 }
00050 
00051 unsigned int ColonyCell::getHeight() {
00052   return _i;
00053 }
00054 
00055 unsigned int ColonyCell::getWidth() {
00056   return _j;
00057 }
00058 
00059 Colony* ColonyCell::getColony() {
00060   return _colony;
00061 }
00062 
00063 bool ColonyCell::reachable(Worshiper *w) {
00064   return (w->getColony() == _colony);
00065 }
00066 
00067 Cell* ColonyCell::makeActions() {
00068   std::list<Worshiper*>* worshipers;
00069   std::list<Worshiper*>::iterator it, end;
00070 
00071   ReachableCell::makeActions();
00072 
00073   worshipers = getPeople();
00074   end = worshipers->end();
00075   for(it = worshipers->begin(); it != end; ++it) {
00076     if((*it)->getColony() == _colony) {
00077       _colony->addSurvivor(*it);
00078       removeWorshiper(*it);
00079       --it;
00080     }
00081   }
00082 
00083   return this;
00084 }

Generated on Sat Feb 2 22:22:54 2008 for Teapot Colony Wars by  doxygen 1.5.4