Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // FIXME::: CHANGE HERE FOR VIDEO!!!!
- public List<Position> getValidPositions() {
- List<Position> list = initialisePositions();
- list.removeIf(p -> !isPositionAllowed(p));
- return list;
- }
- private List<Position> initialisePositions() {
- List<Position> list = new ArrayList<>();
- Position C = new Position(r, c);
- Position N = new Position(r - 1, c);
- Position NE = new Position(r - 1, c + 1);
- Position E = new Position(r, c + 1);
- Position SE = new Position(r + 1, c + 1);
- Position S = new Position(r + 1, c);
- Position SW = new Position(r + 1, c - 1);
- Position W = new Position(r, c - 1);
- Position NW = new Position(r - 1, c - 1);
- list.addAll(Arrays.asList(C, N, NE, E, SE, S, SW, W, NW));
- return list;
- }
- private boolean isPositionAllowed(Position p) {
- return p.getRow() >= 0 && p.getRow() < GameConstants.WORLDSIZE &&
- p.getColumn() >= 0 && p.getColumn() < GameConstants.WORLDSIZE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement