ColonyCell Class Reference

#include <ColonyCell.h>

Inheritance diagram for ColonyCell:

Inheritance graph
[legend]
Collaboration diagram for ColonyCell:

Collaboration graph
[legend]

Public Member Functions

 ColonyCell (Colony *colony, unsigned int i, unsigned int j)
 Constructor.
virtual ~ColonyCell ()
 Empty Destructor.
unsigned int getHeight ()
 Return the z position of the Cell in the World.
unsigned int getWidth ()
 Return the x position of the Cell in the World.
ColonygetColony ()
 Return the Colony associated with that Cell.
virtual bool reachable (Worshiper *w)
 Is the Cell reachable ?
virtual CellmakeActions ()
 Make the actions needed by the Cell for one iteration.

Protected Member Functions

virtual void getColors (GLubyte &red, GLubyte &green, GLubyte &blue)
 Return the color the Cell has to be display with.

Protected Attributes

Colony_colony
unsigned int _i
unsigned int _j

Detailed Description

< A Cell related to a Colony

Definition at line 38 of file ColonyCell.h.


Constructor & Destructor Documentation

ColonyCell::ColonyCell ( Colony colony,
unsigned int  i,
unsigned int  j 
)

Constructor.

Parameters:
colony the colony of the ColonyCell
i the z position of the Cell in the World
j the x position of the Cell in the World

Definition at line 42 of file ColonyCell.cpp.

References _colony, and Colony::addCell().

00042                                                                      :
00043     ReachableCell(), _colony(colony), _i(i), _j(j) {
00044   _colony->addCell(this);
00045 }

Here is the call graph for this function:


Member Function Documentation

void ColonyCell::getColors ( GLubyte &  red,
GLubyte &  green,
GLubyte &  blue 
) [protected, virtual]

Return the color the Cell has to be display with.

Parameters:
red the red part of the display color
green the green part of the display color
blue the blue part of the display color

Reimplemented from Cell.

Definition at line 33 of file ColonyCell.cpp.

References _colony, and Colony::getColor().

00033                                                                       {
00034   GLubyte *colors;
00035 
00036   colors = _colony->getColor();
00037   red   = colors[0];
00038   green = colors[1];
00039   blue  = colors[2];
00040 }

Here is the call graph for this function:

unsigned int ColonyCell::getHeight (  ) 

Return the z position of the Cell in the World.

Returns:
the value of _i

Definition at line 51 of file ColonyCell.cpp.

References _i.

00051                                    {
00052   return _i;
00053 }

unsigned int ColonyCell::getWidth (  ) 

Return the x position of the Cell in the World.

Returns:
the value of _j

Definition at line 55 of file ColonyCell.cpp.

References _j.

00055                                   {
00056   return _j;
00057 }

Colony * ColonyCell::getColony (  ) 

Return the Colony associated with that Cell.

Returns:
the value of _colony

Definition at line 59 of file ColonyCell.cpp.

References _colony.

Referenced by World::fight().

00059                               {
00060   return _colony;
00061 }

Here is the caller graph for this function:

bool ColonyCell::reachable ( Worshiper w  )  [virtual]

Is the Cell reachable ?

Parameters:
w the Worshiper that try to access to the Cell
Returns:
true if the Worshiper can access to the Cell, false otherwise

Reimplemented from ReachableCell.

Definition at line 63 of file ColonyCell.cpp.

References _colony, and Worshiper::getColony().

00063                                        {
00064   return (w->getColony() == _colony);
00065 }

Here is the call graph for this function:

Cell * ColonyCell::makeActions (  )  [virtual]

Make the actions needed by the Cell for one iteration.

Returns:
a pointer to the new Cell which should replace this one

Reimplemented from ReachableCell.

Definition at line 67 of file ColonyCell.cpp.

References _colony, Colony::addSurvivor(), ReachableCell::getPeople(), ReachableCell::makeActions(), and ReachableCell::removeWorshiper().

00067                               {
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 }

Here is the call graph for this function:


Field Documentation

Colony* ColonyCell::_colony [protected]

The colony associated with that ColonyCell

Definition at line 43 of file ColonyCell.h.

Referenced by ColonyCell(), getColony(), getColors(), makeActions(), and reachable().

unsigned int ColonyCell::_i [protected]

z position of the ColonyCell in the World

Definition at line 46 of file ColonyCell.h.

Referenced by getHeight().

unsigned int ColonyCell::_j [protected]

x position of the ColonyCell in the World

Definition at line 48 of file ColonyCell.h.

Referenced by getWidth().


The documentation for this class was generated from the following files:
Generated on Sat Feb 2 22:23:10 2008 for Teapot Colony Wars by  doxygen 1.5.4