import java.util.Vector;
import java.awt.Point;

/**
  *The generic PlayingField
  */
class PlayingField extends ArcadeGameObject{
	protected ArcadeGameMatch _match;
	protected ArcadeGame _game;
	protected Vector list;

	/**
	  *Constructor
	  *@param aGame the game to which the Game belongs
	  */
	public PlayingField(ArcadeGame aGame){
		_game = aGame;
		list = new Vector(10);
	}

	/**
	  *The method checks all the stationary objects in the PlayingField
	  *to see if a collision has occurred
	  *@param mPiece The piece that has moved
	  *pre: A MovablePiece has changed position and is informing the PlayingField
	  */
	public void moved(MovablePiece mPiece) throws Collision{

		ArcadeGamePiece aPiece;
			if(!list.isEmpty()){
			for(int i=0; i< list.size(); i++){	
				aPiece = (ArcadeGamePiece)list.elementAt(i);
				if(aPiece.isContained(mPiece.getPosition())){
					throw  new Collision(mPiece,aPiece,mPiece.getPosition());
				}
			}

		}

	}

	/**
	  *The piece will be deleted
	  *@param mPiece the MovablePiece that is to be deleted
	  *post: The MovablePiece has been removed from the PlayingField
	  */
	public void deleted(MovablePiece mPiece){
		_match.deleted(mPiece);
	}

};
