public class BangBlock extends Block{
//Overview: BangBlock looks exactly like a normal Block
//	But if a Tank shoot a Shell at it, it will bounce back the Shell
//		in random Direction.

	public BangBlock(){
		super(false,2);
	}
	public void decreaseHP(int n){
		Direction dir = Direction.randomDirection4();
		shoot(dir);
	}
	public void shoot(Direction dir){
	//Modifies: Shell object
	//Effects: create a Shell object and shoot it in the current orient Direction.
		synchronized(getGrid()){
			int newx = getX()+dir.easterlyDirection();
			int newy = getY()-dir.northerlyDirection();
			if(getGrid().validLocation(newx,newy)){
				SimObject so = getGrid().getObjectAt(newx,newy);
				if(so != null){
					so.decreaseHP(1);
				} else {
					Shell bullet = new Shell(dir,1);
					try{
						getGrid().setObjectAt(newx,newy,bullet);
						bullet.init(newx,newy,getGrid());
						bullet.resumeObject();
					}catch(BadLocationException e){
						System.err.println("BadLocation for shell");
					}
				}
			}
		}
	}
}