private boolean canDoubleJump(GameObj obj) { doubleJumpSpots = new ArrayList<Tuple<Integer, Integer>>(); if (obj.isTile()) { return false; } int x = obj.getX(); int y = obj.getY(); if (obj.isQueen()) { return doubleJumpProcess(obj, x + 2, y + 2) || doubleJumpProcess(obj, x - 2, y + 2) || doubleJumpProcess(obj, x + 2, y - 2) || doubleJumpProcess(obj, x - 2, y - 2); } else { if (turn.equals(Color.RED)) { return doubleJumpProcess(obj, x + 2, y - 2) || doubleJumpProcess(obj, x - 2, y - 2); } else { return doubleJumpProcess(obj, x + 2, y + 2) || doubleJumpProcess(obj, x - 2, y + 2); } } }
private boolean doubleJumpProcess(GameObj obj, int xtrans, int ytrans) { if (xtrans >= 8 || xtrans < 0 || ytrans >= 8 || ytrans < 0) { return false; } int x = obj.getX(); int y = obj.getY(); if (Math.abs(x - xtrans) != 2 && Math.abs(y - ytrans) != 2) { return false; } int medx = (x + xtrans) / 2; int medy = (y + ytrans) / 2; if (BOARD[xtrans][ytrans].isTile() && BOARD[medx][medy].isChecker() && !BOARD[medx][medy].getColor().equals(turn)) { doubleJumpSpots.add(new Tuple<Integer, Integer>(xtrans, ytrans)); return true; } else { return false; } }