/** * method that will be called when mouse releases * @param point , the point mouse release at */ public void onMouseRelease(Location point) { isGrabbed = false; if(!success){ for(Piece p: bp){ //if correctly matched if(p.contains(grabbedPiece.getCenter()) && p.equals(grabbedPiece)){ grabbedPiece.hide(); p.show(); p.showHighlight(Color.GREEN); lockedBP[p.getId()] = true; //check if all pieces are matched boolean check = true; for(boolean b: lockedBP){ check = check && b; } if(check){ success = true; for(Piece piece: bp){ piece.hideHighlight(); } text.show(); } } } } }
/** * Object based constructor. * * @param state Board state as object values. * @param piece Playing player piece. * @param colunm Column to be played. * @param rank Example rank. */ public Example(Piece[][] state, Piece piece, int colunm, int rank) { this(piece.getId(), colunm, rank); this.state = new int[state.length][]; for (int i = 0; i < state.length; i++) { this.state[i] = new int[state[i].length]; for (int j = 0; j < state[i].length; j++) { this.state[i][j] = state[i][j].getId(); } } }
public boolean sane() { final Set<Integer> hash = new HashSet<Integer>(); for (final Piece[] row : pieces) { for (final Piece piece : row) { if (hash.contains(piece.getId())) { return false; } } } return true; }