Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

MarkMask Class Reference

Inheritance diagram for MarkMask:

Inheritance graph
[legend]
Collaboration diagram for MarkMask:

Collaboration graph
[legend]

Detailed Description

Marks and unmasks object from game field.

Definition at line 14 of file MarkMask.h.

Public Member Functions

 MarkMask (Cube *model, Field *field)
Cube::t_models getResist (Dir::eDir dir) const
 Return others which resist us to move this direction.
Cube::t_models getPlacedResist (const V2 &loc) const
 Return others which resist at given location.
void mask ()
 Write our position to the field.
void unmask ()
 Clear our position from the field.
Dir::eDir getBorderDir () const
 Returns dir to out of room.


Constructor & Destructor Documentation

MarkMask::MarkMask Cube model,
Field field
 

Definition at line 18 of file MarkMask.cpp.

00019 {
00020     m_model = model;
00021     m_field = field;
00022 }


Member Function Documentation

Dir::eDir MarkMask::getBorderDir  )  const
 

Returns dir to out of room.

The direction must be without resist.

Returns:
return dir or DIR_NO when model is not at the border.

Definition at line 104 of file MarkMask.cpp.

00105 {
00106     V2 loc = m_model->getLocation();
00107     const Shape *shape = m_model->shape();
00108     Shape::const_iterator end = shape->marksEnd();
00109     for (Shape::const_iterator i = shape->marksBegin(); i != end; ++i) {
00110         V2 mark = loc.plus(*i);
00111         if (mark.getX() == 0 && isBorderDir(Dir::DIR_LEFT)) {
00112             return Dir::DIR_LEFT;
00113         }
00114         else if (mark.getX() == m_field->getW() - 1 &&
00115                 isBorderDir(Dir::DIR_RIGHT))
00116         {
00117             return Dir::DIR_RIGHT;
00118         }
00119         else if (mark.getY() == 0 && isBorderDir(Dir::DIR_UP)) {
00120             return Dir::DIR_UP;
00121         }
00122         else if (mark.getY() == m_field->getH() - 1 &&
00123                 isBorderDir(Dir::DIR_DOWN))
00124         {
00125             return Dir::DIR_DOWN;
00126         }
00127     }
00128 
00129     return Dir::DIR_NO;
00130 }

Cube::t_models MarkMask::getPlacedResist const V2 loc  )  const
 

Return others which resist at given location.

Pointers to NULL and own model are not included.

Returns:
unique pointers, not NULL

Definition at line 46 of file MarkMask.cpp.

00047 {
00048     Cube::t_models models;
00049     const Shape *shape = m_model->shape();
00050     Shape::const_iterator end = shape->marksEnd();
00051     for (Shape::const_iterator i = shape->marksBegin(); i != end; ++i) {
00052         V2 mark = loc.plus(*i);
00053 
00054         Cube *resist = m_field->getModel(mark);
00055         if (NULL != resist && m_model != resist) {
00056             models.push_back(resist);
00057         }
00058     }
00059 
00060     std::sort(models.begin(), models.end());
00061     Cube::t_models::iterator last = std::unique(models.begin(), models.end());
00062     models.erase(last, models.end());
00063 
00064     return models;
00065 }

Cube::t_models MarkMask::getResist Dir::eDir  dir  )  const
 

Return others which resist us to move this direction.

Pointers to NULL and own model are not included.

Returns:
unique pointers, not NULL

Definition at line 31 of file MarkMask.cpp.

00032 {
00033     V2 shift = Dir::dir2xy(dir);
00034     V2 shift_loc = shift.plus(m_model->getLocation());
00035 
00036     return getPlacedResist(shift_loc);
00037 }

void MarkMask::mask  ) 
 

Write our position to the field.

Definition at line 71 of file MarkMask.cpp.

00072 {
00073     writeModel(m_model);
00074 }

void MarkMask::unmask  ) 
 

Clear our position from the field.

Definition at line 80 of file MarkMask.cpp.

00081 {
00082     writeModel(NULL);
00083 }


The documentation for this class was generated from the following files:
Generated on Wed Jun 1 09:55:50 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2