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,13 +129,16 @@ public class Board{
}
yShift = rand.nextInt(3) - 1;
}
this.thiefMoves++;
this.thief.setCoordinates(this.thief.getX() + xShift, this.thief.getY() + yShift);
if( isTakenByPolice(this.thief.getX() + xShift, this.thief.getY() + yShift) ){
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) ){
return false;
}else{
break;
return false;
}else{
break;
}
}
}
// Move Polices
......@@ -158,17 +162,19 @@ public class Board{
}
yShift = rand.nextInt(3) - 1;
}
if( !isTakenByPolice(p.getX() + xShift, p.getY() + yShift) ){
if( xShift != 0 || yShift != 0 ){
if( !isTakenByPolice(p.getX() + xShift, p.getY() + yShift) ){
p.setCoordinates(p.getX() + xShift, p.getY() + yShift);
if( isThiefInRange(p.getX(), p.getY()) ){
p.setCoordinates(p.getX() + xShift, p.getY() + yShift);
if( isThiefInRange(p.getX(), p.getY()) ){
for( Police police : this.polices ){
police.setTarget(this.thief);
for( Police police : this.polices ){
police.setTarget(this.thief);
}
}
this.policeMoves++;
break;
}
this.policeMoves++;
break;
}
}
}else{// Move based on thought :D
......@@ -224,15 +230,17 @@ public class Board{
}
yShift = rand.nextInt(3) - 1;
}
if( !isTakenByPolice(p.getX() + xShift, p.getY() + yShift) ){
if( xShift != 0 || yShift != 0 ){
if( !isTakenByPolice(p.getX() + xShift, p.getY() + yShift) ){
p.setCoordinates(p.getX() + xShift, p.getY() + yShift);
this.policeMoves++;
if( p.getY() == prevY && p.getX() == prevX ){
p.setCoordinates(p.getX() + xShift, p.getY() + yShift);
this.policeMoves++;
if( p.getY() == prevY && p.getX() == prevX ){
return false;
return false;
}
break;
}
break;
}
}
}
......
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