private void attack() {
        if (LocationManager.getLoc(cursor).isEmpty()) {
            JOptionPane.showMessageDialog(gui, "No Unit Present");
            return;
        }
        if (LocationManager.getLoc(cursor).getUnit().getTeam() != turn) {
            JOptionPane.showMessageDialog(gui, "Cannot Control this unit");
            return;
        }
        if (LocationManager.getLoc(cursor).getUnit().isAttackDone()) {
            JOptionPane.showMessageDialog(gui, "Unit already attacked this turn");
            return;
        }
        buttonCursor.y = -1;

        Unit attacker = LocationManager.getLoc(cursor).getUnit();
        if (attacker.isRanged()) {
            for (Location loc : LocationManager.getLoc(cursor).getAjacent()) {
                rangedRecur(loc, attacker.getRange() - 1);
            }
        } else {
            for (Location loc : LocationManager.getLoc(cursor).getAjacent()) {
                if (!loc.isEmpty()) {
                    Unit defender = loc.getUnit();
                    if (defender.getTeam() != turn) {
                        selectLocs.add(new Point(loc.getLoc()));
                    }

                }
            }
        }
        if (selectLocs.isEmpty()) {
            JOptionPane.showMessageDialog(gui, "No attacks available");
            return;
        }
        attacking = true;
        unitLoc = new Point(cursor.x, cursor.y);
    }