package sudoku.constraint;

import sudoku.structure.Sudoku;

public class DiagonalConstraint implements IConstraint {

	@Override
	public boolean canBePlaced(Sudoku s, int x, int y, int newSymbolIndex) {
		if (x == y) {
			for (int i = 0; i < s.getSize(); i++) {
				if (s.getCell(i, i).getSymbolIndex() == newSymbolIndex)
					return false;
			}
		} else if (s.getSize() - x == y) {
			for (int i = 0; i < s.getSize(); i++) {
				if (s.getCell(s.getSize() - i - 1, i).getSymbolIndex() == newSymbolIndex)
					return false;
			}
		}
		// not in diagonal
		return true;
	}

}
