Commit 7b5d88e2 authored by Omid Sayfun's avatar Omid Sayfun

No Movement bug fixed

parent 2bedad5a
package lab.game;
import java.util.*;
import java.util.concurrent.*;
import java.io.IOException;
......@@ -128,6 +129,8 @@ public class Board{
}
yShift = rand.nextInt(3) - 1;
}
if( xShift != 0 || yShift != 0 ){
this.thiefMoves++;
this.thief.setCoordinates(this.thief.getX() + xShift, this.thief.getY() + yShift);
if( isTakenByPolice(this.thief.getX() + xShift, this.thief.getY() + yShift) ){
......@@ -137,6 +140,7 @@ public class Board{
break;
}
}
}
// Move Polices
for(Police p : this.polices){
if( p.getTarget() == null){// Random Move
......@@ -158,6 +162,7 @@ public class Board{
}
yShift = rand.nextInt(3) - 1;
}
if( xShift != 0 || yShift != 0 ){
if( !isTakenByPolice(p.getX() + xShift, p.getY() + yShift) ){
p.setCoordinates(p.getX() + xShift, p.getY() + yShift);
......@@ -171,6 +176,7 @@ public class Board{
break;
}
}
}
}else{// Move based on thought :D
int xShiftThought = 0;
int yShiftThought = 0;
......@@ -224,6 +230,7 @@ public class Board{
}
yShift = rand.nextInt(3) - 1;
}
if( xShift != 0 || yShift != 0 ){
if( !isTakenByPolice(p.getX() + xShift, p.getY() + yShift) ){
p.setCoordinates(p.getX() + xShift, p.getY() + yShift);
......@@ -238,6 +245,7 @@ public class Board{
}
}
}
}
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment