## Forced moves trouble!!

Hey peeps,

ive been trying to implement a forced move functon in my game. I think the code makes sense, it should do what it says, but it never sets fm to "true" when it discovers a forced move. Either it doesn't enter the loop and carry out the code or its not setting forced move to true. Im very new to coding, so i may have made a silly mistake, but im not experienced enough to spot it. If anyone could it would be a great help, thank you.

sorry about the length of the code, im no where near good enough to optimize...

Code:
```bool Game::move(Square *dest, Draught *current){

bool fm = false;
bool valid = false;

Square * sq1 = current->getSquare();

if (dest->isOccupied()) return false;

vector<int> forcedMovesp1;
vector<int> forcedMovesp2;
vector<int>::const_iterator move;

if (cp==1){

for(int i=0; i<player1->getNDraughts(); i++){

Draught * d1 = player1->getDraught(i);
Square * d1s = d1->getSquare();

for(int j=0; j<player2->getNDraughts(); j++){

Draught * d2 = player2->getDraught(j);

if(d1s->getY() == 0 && d1s->getY() == 1){

Square * s = board->getSquare(d1s->getX()+1, d1s->getY() +1); 			// getting squares for top right
Square * o = board->getSquare(d1s->getX()+2, d1s->getY() +2);

Square * s1 = board->getSquare(d1s->getX()-1, d1s->getY() +1);			// getting squares for bottom right
Square * o1 = board->getSquare(d1s->getX()-2, d1s->getY() +2);

if ((d2->getSquare() == s) && !o->isOccupied()){					// checking if top right square is occupied

fm = true;
}

if ((d2->getSquare() == s1) && !o1->isOccupied()){					// checking if bottom right square is occupied

fm = true;
}
}

else if (sq1->getY() == 6 && sq1->getY() == 7){

Square * s = board->getSquare(d1s->getX()+1, d1s->getY()-1); 	// getting squares for top left focred move
Square * o = board->getSquare(d1s->getX()+2, d1s->getY()-2);

Square * s1 = board->getSquare(d1s->getX()-1, d1s->getY() -1);	// getting squares for bottom left
Square * o1 = board->getSquare(d1s->getX()-2, d1s->getY() -2);

if ((d2->getSquare() == s) && !o->isOccupied()){			// checking if top right square is occupied

fm = true;

}

if ((d2->getSquare() == s1) && !o1->isOccupied()){			// checking if bottom right square is occupied

fm = true;

}

}

else if (sq1->getY() == 2 && sq1->getY() == 3 && sq1->getY() == 4 && sq1->getY() == 5) {  //rest of squares on the row

Square * s = board->getSquare(d1s->getX()+1, d1s->getY()-1);  // getting squares for top left focred move
Square * o = board->getSquare(d1s->getX()+2, d1s->getY()-2);

Square * s1 = board->getSquare(d1s->getX()+1, d1s->getY() +1); // getting squares for top right
Square * o1 = board->getSquare(d1s->getX()+2, d1s->getY() +2);

Square * s2 = board->getSquare(d1s->getX()-1, d1s->getY() -1);	// getting squares for bottom left
Square * o2 = board->getSquare(d1s->getX()-2, d1s->getY() -2);

Square * s3 = board->getSquare(d1s->getX()-1, d1s->getY() +1);	// getting squares for bottom right
Square * o3 = board->getSquare(d1s->getX()-2, d1s->getY() +2);

if ((d2->getSquare() == s) && !o->isOccupied()){			// checking if top left square is occupied

fm = true;
}

if ((d2->getSquare() == s1) && !o1->isOccupied()){			// checking if top right square is occupied

fm = true;
}

if (current->isKing()){
if ((d2->getSquare() == s2) && !o2->isOccupied()){		// checking if bottom left square is occupied
fm = true;
}

}

if (current->isKing()){
if ((d2->getSquare() == s3) && !o3->isOccupied()){		// checking if bottom right square is occupied
fm = true;
}
}

}
}
if (fm) {

forcedMovesp1.push_back(i);
}
}
if (fm){

for (move = forcedMovesp1.begin(); move != forcedMovesp1.end(); ++move){
if (sq1->getDraught() == move) {

if (sq1->getX()!=dest->getX()-2) {}
else if ((sq1->getY()!=dest->getY()+2) && (sq1->getY()!=dest->getY()-2)) {}		// check if move made by player is valid
else if (current->isKing()){
if(sq1->getX()!=dest->getX()+2){}

else

{valid = true;}
}
else {
valid = true;
}
}

else {

cout << "Invalid selection" <<endl;
}
}
}

/* END OF FORCED MOVE CHECK FOR P1
NOW CHECK FOR STANDARD MOVES FOR P1*/

if (fm == false){
if (sq1->getX()!=dest->getX()-1){}		// Checking conditon for P1
else if ((sq1->getY()!=dest->getY()+1) && (sq1->getY()!=dest->getY()-1)){}
else if (current->isKing()){
if (sq1->getX()!=dest->getX()+1){}
else

{valid = true;}	// for the king
}

else {
valid = true; // standard piece
}

}
}
/* END OF PLAYER 1 STANDARD MOVES CHECK
NOW BEGIN CHECK FOR PLAYER 2*/

/* START P2 FORCED MOVE CHECK */

else{

cout << "player2" <<endl;

for(int i=0; i<player2->getNDraughts(); i++){

Draught * d1 = player2->getDraught(i);
Square * d1s = d1->getSquare();

for(int j=0; j<player1->getNDraughts(); j++){

Draught * d2 = player1->getDraught(j);

if(d1s->getX() == 0 && d1s->getX() == 1){

Square * s = board->getSquare(d1s->getX()-1, d1s->getY() +1); 			// getting squares for top right
Square * o = board->getSquare(d1s->getX()-2, d1s->getY() +2);

Square * s1 = board->getSquare(d1s->getX()+1, d1s->getY() +1);			// getting squares for bottom right
Square * o1 = board->getSquare(d1s->getX()+2, d1s->getY() +2);

if ((d2->getSquare() == s) && !o->isOccupied()){					// checking if top right square is occupied

fm = true;
}

if ((d2->getSquare() == s1) && !o1->isOccupied()){					// checking if bottom right square is occupied

fm = true;
}
}

else if (sq1->getX() == 6 && sq1->getX() == 7){

Square * s = board->getSquare(d1s->getX()-1, d1s->getY()-1); 	// getting squares for top left focred move
Square * o = board->getSquare(d1s->getX()-2, d1s->getY()-2);

Square * s1 = board->getSquare(d1s->getX()+1, d1s->getY() -1);	// getting squares for bottom left
Square * o1 = board->getSquare(d1s->getX()+2, d1s->getY() -2);

if ((d2->getSquare() == s) && !o->isOccupied()){			// checking if top right square is occupied

fm = true;

}

if ((d2->getSquare() == s1) && !o1->isOccupied()){			// checking if bottom right square is occupied

fm = true;

}

}

else if (sq1->getX() == 2 && sq1->getX() == 3 && sq1->getX() == 4 && sq1->getX() == 5) {  //rest of squares on the row

Square * s = board->getSquare(d1s->getX()+1, d1s->getY()-1);  // getting squares for top left focred move
Square * o = board->getSquare(d1s->getX()+2, d1s->getY()-2);

Square * s1 = board->getSquare(d1s->getX()+1, d1s->getY() +1); // getting squares for bottom right
Square * o1 = board->getSquare(d1s->getX()+2, d1s->getY() +2);

Square * s2 = board->getSquare(d1s->getX()-1, d1s->getY() -1);	// getting squares for top right
Square * o2 = board->getSquare(d1s->getX()-2, d1s->getY() -2);

Square * s3 = board->getSquare(d1s->getX()-1, d1s->getY() +1);	// getting squares for bottom left
Square * o3 = board->getSquare(d1s->getX()-2, d1s->getY() +2);

if ((d2->getSquare() == s) && !o->isOccupied()){			// checking if top left square is occupied

fm = true;
}

if ((d2->getSquare() == s1) && !o1->isOccupied()){			// checking if top right square is occupied

fm = true;
}

if (current->isKing()){
if ((d2->getSquare() == s2) && !o2->isOccupied()){		// checking if bottom left square is occupied
fm = true;
}

}

if (current->isKing()){
if ((d2->getSquare() == s3) && !o3->isOccupied()){		// checking if bottom right square is occupied
fm = true;
}
}

}
}

if (fm) {

forcedMovesp2.push_back(i);
}
}

if (fm){

for (move = forcedMovesp2.begin(); move != forcedMovesp2.end(); ++move){
std::cout << "move" << move<<endl;
if (sq1->getDraught() == move) {

if (sq1->getX()!=dest->getX()+2) {}
else if ((sq1->getY()!=dest->getY()+2) && (sq1->getY()!=dest->getY()-2)) {}		// check if move made by player is valid
else if (current->isKing()){
if(sq1->getX()!=dest->getX()-2){}

else

{valid = true;}
}
else {
valid = true;
}
}
}
}

/* END OF FORCED MOVE CHECK
START STANDARD MOVE CHECK*/

if(fm == false){
if (sq1->getX()!=dest->getX()+1){}		// Checking condition for P2
else if ((sq1->getY()!=dest->getY()-1) && (sq1->getY()!=dest->getY()+1)){}
else if (current->isKing()){
if (sq1->getX()!=dest->getX()-1){}
else

{valid = true;}
}
else {
valid = true;
}
}

}

if (valid){
Square * s = current->getSquare();
s->setDraught(NULL);

current->setSquare(dest);		//Making the move
dest->setDraught(current);

if (cp == 1)				//Changing players after the move
{cp = 2;}
else
{cp = 1;}
std::cout << "cp =" << cp<<endl;
std::cout << "fm =" << fm<<endl;
std::cout << "val =" << valid<<endl;
}

else 	{std::cout << "cp =" << cp<<endl;
std::cout << "fm =" << fm<<endl;
std::cout << "val =" << valid<<endl;

std::cout<<"Illegal Move"<<endl;}

return valid;```