From bf6bbd5609cd125d8b3e5a7fbe6f2cd49146af49 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Mon, 19 Nov 2018 00:02:46 +0100 Subject: Add TODOs for various corrections --- src/Map.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/Map.java') diff --git a/src/Map.java b/src/Map.java index 7b178cf..a870604 100644 --- a/src/Map.java +++ b/src/Map.java @@ -3,15 +3,19 @@ import java.util.ArrayList; public class Map { private final Dimension size; + // TODO: is there a particular reason to not use a 2D array? private final Tile grid[]; private ArrayList actors = new ArrayList(); + // TODO: rename to selectedActor? private int actorIndex = -1; + // TODO: make selectedTile? Tile contains x and y members private int selectedX; private int selectedY; public Map(Dimension size) { this.size = size; + // TODO: replace with Dimension.height and Dimension.width which are integer public members this.grid = new Tile[(int) this.size.getWidth() * (int) this.size.getHeight()]; for (int x = 0; x < this.size.getWidth(); x++) { for (int y = 0; y < this.size.getHeight(); y++) { @@ -20,6 +24,7 @@ public class Map { } } + // pathfinding algorithm public ArrayList getPath(Actor actor, int x, int y) { ArrayList unsettled = new ArrayList(); ArrayList settled = new ArrayList(); @@ -46,10 +51,12 @@ public class Map { settled.add(i); } } + ArrayList out = new ArrayList(); Tile workingTile = this.getTile(x, y); double bestDistance = 1000000000; Tile bestTile = workingTile; + while (true) { for (Tile i : workingTile.getAdjacent(this)) { if (i.getDistance() < bestDistance) { @@ -69,6 +76,8 @@ public class Map { } public void update(ArrayList actorsList, Tile[] tileGrid) { + // TODO: if this is needed for something, implement copy constructors for Actor and Tile + // and delete this code for (Actor actor : actorsList) { Actor newActor = new Actor(actor.getName(), actor.getHP(), actor.isEnemy(), actor.getAgility()); newActor.place(actor.getX(), actor.getY()); @@ -83,6 +92,7 @@ public class Map { } } + // TODO: refractor to resetActorActions(); public void resetActors() { for (Actor actor : this.actors) { if (!actor.isEnemy()) { @@ -112,6 +122,8 @@ public class Map { return actor; } + // TODO: there is the Map cursor and the Mouse cursor, + // a solution to the naming shall be found public void setCursor(int x, int y) { this.getTile(this.selectedX, this.selectedY).setCursor(false); if (x == -1 && y == -1) { @@ -146,6 +158,7 @@ public class Map { this.actors.add(actor); } + // TODO: remove by introducing selectedTile member public void clearSelected() { for (Tile tile : this.grid) { tile.setSelected(false); -- cgit v1.2.1