Permalink
Browse files

Emty captured points counter

  • Loading branch information...
1 parent 215f0f1 commit 2e55e793e412a0e5b4d50ebb0f7ea2864486d342 @Ignotus committed Aug 24, 2012
Showing with 16 additions and 4 deletions.
  1. +2 −1 dottable.cpp
  2. +13 −3 include/stepqueue.hpp
  3. +1 −0 stepqueue.cpp
View
@@ -174,6 +174,7 @@ namespace KDots
if (isInPolygon (polygon, newPoint) && polygon->isFilled ())
{
itr->capture ();
+ m_steps->addEmptyCaptured ();
break;
}
}
@@ -188,7 +189,7 @@ namespace KDots
void DotTable::continueStep ()
{
const auto& allPoints = m_steps->getAllPoints ();
- if (allPoints.size () == m_graph->width () * m_graph->height ())
+ if (allPoints.size () + m_steps->emtyCapturedCount () == m_graph->width () * m_graph->height ())
{
const int first = m_steps->getMarks (FIRST);
const int second = m_steps->getMarks (SECOND);
View
@@ -34,7 +34,7 @@ namespace KDots
{
Owner m_firstOwner;
std::vector<Point> m_firstPoints, m_secondPoints, m_points;
- int m_first, m_second;
+ std::size_t m_first, m_second, m_emptyCaptured;
protected:
Owner m_owner;
bool m_captured;
@@ -54,7 +54,7 @@ namespace KDots
inline void clear ()
{
- m_first = m_second = 0;
+ m_first = m_second = m_emptyCaptured = 0;
m_owner = m_firstOwner;
m_captured = false;
m_firstPoints.clear ();
@@ -64,13 +64,23 @@ namespace KDots
void addPoint (const Point& point);
void addCaptured ();
+
+ inline void addEmptyCaptured ()
+ {
+ ++m_emptyCaptured;
+ }
+
+ inline std::size_t emtyCapturedCount () const
+ {
+ return m_emptyCaptured;
+ }
inline Owner getCurrentOwner () const
{
return m_owner;
}
- inline int getMarks (Owner owner) const
+ inline std::size_t getMarks (Owner owner) const
{
return owner == FIRST ? m_first : m_second;
}
View
@@ -31,6 +31,7 @@ namespace KDots
: m_firstOwner (firstPlayer)
, m_first (0)
, m_second (0)
+ , m_emptyCaptured (0)
, m_owner (firstPlayer)
, m_captured (false)
{

0 comments on commit 2e55e79

Please sign in to comment.