Beispiel #1
0
		private ArrayList getMoves(XYLocation forPiece) 
		{
			ArrayList retVal = new ArrayList();

			if (this.isPlayer(B,forPiece))
			{
				//if the piece below is empty, add it
				if (this.isLegalPlace(forPiece.south()) && this.isEmpty(forPiece.south()))
					retVal.Add(forPiece.south());
				//if the south diagonals are white, add them
				if (this.isLegalPlace(forPiece.southwest()) && this.isPlayer(W,forPiece.southwest()))
					retVal.Add(forPiece.southwest());
				if (this.isLegalPlace(forPiece.southeast()) && this.isPlayer(W,forPiece.southeast()))
					retVal.Add(forPiece.southeast());
			}
			else
			{
				//if the piece above is empty, add it
				if (this.isLegalPlace(forPiece.north()) && this.isEmpty(forPiece.north()))
					retVal.Add(forPiece.north());
				//if the north diagonals are black, add them
				if (this.isLegalPlace(forPiece.northwest()) && this.isPlayer(B,forPiece.northwest()))
					retVal.Add(forPiece.northwest());
				if (this.isLegalPlace(forPiece.northeast()) && this.isPlayer(B,forPiece.northeast()))
					retVal.Add(forPiece.northeast());
			}

			return retVal;
		}