|
@@ -258,16 +258,17 @@ public class DijkstraMagic {
|
|
|
|
|
|
for(int x = 0; x < map.getWidth(); x++) {
|
|
|
for(int y = 0; y < map.getHeight(); y++) {
|
|
|
+ weightMap[x][y] = new Node2D(map.getTile(x, y).getEnergyCost(player));
|
|
|
+ weightMap[x][y].setType(map.getTile(x, y).getType());
|
|
|
+
|
|
|
if(map.getTile(x, y).getId() == TOWN_ID || map.getTile(x, y).getId() == START_ID) {
|
|
|
towns.add(new Coord(x, y));
|
|
|
+ weightMap[x][y].setTown(true);
|
|
|
}
|
|
|
else if(map.getTile(x, y).getId() == PORT_ID) {
|
|
|
ports.add(new Coord(x, y));
|
|
|
}
|
|
|
|
|
|
- weightMap[x][y] = new Node2D(map.getTile(x, y).getEnergyCost(player));
|
|
|
- weightMap[x][y].setType(map.getTile(x, y).getType());
|
|
|
-
|
|
|
if(map.getTile(x, y).isBlockingMovement(player)) {
|
|
|
weightMap[x][y].setBlocked(true);
|
|
|
}
|
|
@@ -320,18 +321,26 @@ public class DijkstraMagic {
|
|
|
}
|
|
|
|
|
|
private void printWeightMap() {
|
|
|
+ String ANSI_RESET = "\u001B[0m";
|
|
|
+ String ANSI_BLUE = "\u001B[34m";
|
|
|
+ String ANSI_CYAN = "\u001B[36m";
|
|
|
+ String ANSI_RED = "\u001B[31m";
|
|
|
+
|
|
|
for(int y = 0; y < weightMap[0].length; y++) {
|
|
|
for(int x = 0; x < weightMap.length; x++) {
|
|
|
int cost = weightMap[x][y].getWeight();
|
|
|
TileType type = weightMap[x][y].getType();
|
|
|
- if(type == TileType.PORT) {
|
|
|
- System.out.print("P ");
|
|
|
+ if(weightMap[x][y].isTown()) {
|
|
|
+ System.out.print(ANSI_RED + "T " + ANSI_RESET);
|
|
|
+ }
|
|
|
+ else if(type == TileType.PORT) {
|
|
|
+ System.out.print(ANSI_CYAN + "P " + ANSI_RESET);
|
|
|
}
|
|
|
else if(type == TileType.SHALLOW_WATER) {
|
|
|
- System.out.print("s ");
|
|
|
+ System.out.print(ANSI_BLUE + "s " + ANSI_RESET);
|
|
|
}
|
|
|
else if(type == TileType.DEEP_WATER) {
|
|
|
- System.out.print("d ");
|
|
|
+ System.out.print(ANSI_BLUE + "d " + ANSI_RESET);
|
|
|
}
|
|
|
else {
|
|
|
System.out.print(cost + " ");
|