Skip to content
Snippets Groups Projects
Commit ac894ab6 authored by Bolla Péter's avatar Bolla Péter
Browse files

Rook movements in void Chess::Move(int oi, int ti) function

parent 8d39a339
Branches
No related tags found
No related merge requests found
......@@ -186,8 +186,102 @@ void Chess::Move(int oi, int ti)
{
for(int d = 1; d<abs(dc)-1 && allempty; d++)
{
if(Table[oi+d].occupied) allempty = false;
}
if(allempty)
{
if(!Table[ti].occupied)
{
//Move
}
else if(CanCapture(oi, ti))
{
//Capture
}
else{
//Don't move
}
}
else{
//Don't move
}
}
else if(dc >0) //Move to the left
{
for(int d = 1; d<abs(dc)-1 && allempty; d++)
{
if(Table[oi-d].occupied) allempty = false;
}
if(allempty)
{
if(!Table[ti].occupied)
{
//Move
}
else if(CanCapture(oi, ti))
{
//Capture
}
else{
//Don't move
}
}
else{
//Don't move
}
}
else if(dc == 0)
{
if(dr < 0)//Move up
{
for(int d = 1; d<abs(dc)-1 && allempty; d++)
{
if(Table[oi+d*8].occupied) allempty = false;
}
if(allempty)
{
if(!Table[ti].occupied)
{
//Move
}
else if(CanCapture(oi, ti))
{
//Capture
}
else{
//Don't move
}
}
else{
//Don't move
}
}
else if(dr >0) //Move down
{
for(int d = 1; d<abs(dc)-1 && allempty; d++)
{
if(Table[oi-8*d].occupied) allempty = false;
}
if(allempty)
{
if(!Table[ti].occupied)
{
//Move
}
else if(CanCapture(oi, ti))
{
//Capture
}
else{
//Don't move
}
}
else{
//Don't move
}
}
else{
//Don't move
}
}
break;
......@@ -305,6 +399,7 @@ void Chess::Move(int oi, int ti)
//Don't move
}
}
break;
}
else{
//Don't move
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment