Game description here:http://www.google.com/url?sa=t&source=web&ct=res&cd=11&url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FBreakthru_(board_game)&ei=dXeTSZH9KJmatwe2i_DiCw&usg=AFQjCNGMFXvDxyuxmi8PrdyGneGpX5SNRA&sig2=pdq6w2j03qSNW-9gQio83g


Variables/functions needed to be known:
m_count: turns taken (0,1,2)
x,y starting coordinates of a piece
h,v destination of said piece
get() returns integer 0,1,2 [empty,gold,silver]
sideSwitch() resets m_count to 1 and turn to the opposite player.
___

Problem:
First pieces started disappearing: fixed
game wasn't ending when flagship was captured unknown..logic added though.

Now my gold pieces won't move
and my turn won't update.((check statement always reveal m_count as zero))

bool CBreakThru::move(int x, int y, int h, int v) 
{
	int count = 0;
	if( h <11 && v <11)
	{
		if(m_board[x][y]->get() == m_turn)
		{
			if( (x == h) ^ (y ==v))
			{
				if(m_board[x][y]->isFlagship() == true && m_count == 0)
				{
                  if((x<h)|| (y<v))
				  {
					for( int j=x;j<=h;j++)
					{

						for( int f=y;f<=v;f++)
						{

							if( m_board[j][f]->get() != 0)
							{
								count++;
							}
						}
					}
				  }else
				  {
					for( int j=x;j>=h;j--)
					{

						for( int f=y;f>=v;f--)
						{

							if( m_board[j][f]->get() != 0)
							{
								count++;
							}
						}
					}
				  }
					if( count == 0)
					{
						delete m_board[h][v];
						m_board[h][v] = m_board[x][y];

						m_board[x][y] = new CPiece;
						 m_count = 2;
						sideSwitch();
                       
						m_x = h;
						m_y = v;
						isGameOver();
						getPieces();
						return true;

					}else{
						cout<<"unable to make move path is not clear."<<endl;
							return false;
					}


				}else
				{

					if((x<h)|| (y<v))
				  {
					for( int j=x;j<=h;j++)
					{

						for( int f=y;f<=v;f++)
						{

							if( m_board[j][f]->get() != 0)
							{
								count++;
							}
						}
					}
				  }else
				  {
					for( int j=x;j>=h;j--)
					{

						for( int f=y;f>=v;f--)
						{

							if( m_board[j][f]->get() != 0)
							{
								count++;
							}
						}
					}
					if( count == 0)
					{
						m_lastmove[0]=x;
						m_lastmove[1]=y;
						m_lastmove[2]=h;
						m_lastmove[3]=v;
						delete m_board[h][v];
						m_board[h][v] = m_board[x][y];



						m_board[x][y] = new CPiece;
						m_count+=1;
						cout<<"SO I herd you liek mudkipz"<<endl;
						if(m_count == 2)
						{
							sideSwitch();
							isGameOver();
							getPieces();
							return true;
						}else
						{
							getPieces();
							return true;
						}
					}

				}
			}else
			{
				//attack move
				if( m_count == 0 && (x!= h && y!= v))
				{
					if( (h == x+1 || v == y+1) || (h == x-1 || v == y-1))
					{
						if(m_board[h][v]->get() != 0 && (m_board[h][v]->get() != m_board[x][y]->get()) )
						{m_lastmove[0]=x;
						m_lastmove[1]=y;
						m_lastmove[2]=h;
						m_lastmove[3]=v;
						delete m_board[h][v];
						m_board[h][v] = m_board[x][y];
						cout<<"wtf"<<endl;
						m_left--;
						m_count =2;
						m_board[x][y] = new CPiece;

						if( m_turn == 1)
						{
							m_gold--;
						}else
						{
							m_silver--;
						}
						sideSwitch();
						getPieces();
						return true;
						}
					}
				}
			}
		}else
		{
			cout<< "That is not your piece"<<endl;
			return false;
		}
	}

Can you read so fantastically indented program source?
Alas, I can't do it :(

I don't know how you'd like it formatted but here is a completely unformatted source:

bool CBreakThru::move(int x, int y, int h, int v) 
{
int count = 0;
if( h <11 && v <11)
{
if(m_board[x][y]->get() == m_turn)
{
if( (x == h) ^ (y ==v))
{
if(m_board[x][y]->isFlagship() == true && m_count == 0)
{
if((x<h)|| (y<v))
 {
for( int j=x;j<=h;j++)
{
for( int f=y;f<=v;f++)
{
if( m_board[j][f]->get() != 0)
{
count++;
}
}
}
}else
 {
for( int j=x;j>=h;j--)
{
for( int f=y;f>=v;f--)
{
if( m_board[j][f]->get() != 0)
{
count++;
}
}
}
 }
if( count == 0)
{
delete m_board[h][v];
m_board[h][v] = m_board[x][y];

m_board[x][y] = new CPiece;
 m_count = 2;
sideSwitch();
   
m_x = h;
m_y = v;
isGameOver();
getPieces();
return true;
}else{
cout<<"unable to make move path is not clear."<<endl;
return false;
}

}else
{
if((x<h)|| (y<v))
 {
for( int j=x;j<=h;j++)
{
for( int f=y;f<=v;f++)
{
if( m_board[j][f]->get() != 0)
{
count++;
}
}
}
 }else
 {
for( int j=x;j>=h;j--)
{
for( int f=y;f>=v;f--)
{
if( m_board[j][f]->get() != 0)
{
count++;
}
}
}
if( count == 0)
{
m_lastmove[0]=x;
m_lastmove[1]=y;
m_lastmove[2]=h;
m_lastmove[3]=v;
delete m_board[h][v];
m_board[h][v] = m_board[x][y];



m_board[x][y] = new CPiece;
m_count+=1;
cout<<"SO I herd you liek mudkipz"<<endl;
if(m_count == 2)
{
sideSwitch();
isGameOver();
getPieces();
return true;
}else
{
getPieces();
return true;
}
}

}
}else
{
//attack move
if( m_count == 0 && (x!= h && y!= v))
{
if( (h == x+1 || v == y+1) || (h == x-1 || v == y-1))
{
if(m_board[h][v]->get() != 0 && (m_board[h][v]->get() != m_board[x][y]->get()) )
{
m_lastmove[0]=x;
m_lastmove[1]=y;
m_lastmove[2]=h;
m_lastmove[3]=v;
delete m_board[h][v];
m_board[h][v] = m_board[x][y];
cout<<"wtf"<<endl;
m_left--;
m_count =2;
m_board[x][y] = new CPiece;

if( m_turn == 1)
{
m_gold--;
}else
{
m_silver--;
}
sideSwitch();
getPieces();
return true;
}
}
}
}
}else
{
cout<< "That is not your piece"<<endl;
return false;
}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.