Skip to content

Commit

Permalink
#537 Tries to calculate route from blackhole ascension portal.
Browse files Browse the repository at this point in the history
There are issues: Veins cannot more diagonally, missing tiles.
Closed portal tile is wrong.
  • Loading branch information
tuomount committed Nov 27, 2023
1 parent 07c382c commit 0450f61
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions src/main/java/org/openRealmOfStars/starMap/StarMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ && locateSolarSystem(sx, sy) == null) {
}
}
// Planetary Ascension portal
int ascensionPlanetIndex = DiceGenerator.getRandom(planetList.size() - 1);
// Create random deep space anchors
loop = 0;
int numberOfAnchors = config.getMaxPlayers() * 3;
Expand Down Expand Up @@ -735,8 +736,22 @@ && locateSolarSystem(sx, sy) == null) {
}
// No need to have generator after creation
nameGenerator = null;
generateAscensionPortal(planetList.get(ascensionPlanetIndex).getX(),
planetList.get(ascensionPlanetIndex).getY());
revealWholeMap(players.getPlayerInfoByIndex(0));
}

/**
* Reveal whole map. This should be used only for debuggin.
* @param info PlayerInfo who sees everything.
*/
public void revealWholeMap(final PlayerInfo info) {
for (int y = 0; y < maxY; y++) {
for (int x = 0; x < maxX; x++) {
info.setSectorVisibility(x, y, PlayerInfo.VISIBLE_VEINS);
}
}
}
/**
* Generate Ascension portal to map and ascension veins.
*
Expand All @@ -751,13 +766,13 @@ public void generateAscensionPortal(final int x, final int y) {
int[] sax = new int[4];
int[] say = new int[4];
sax[0] = cx;
sax[0] = cy - 2;
say[0] = cy - 2;
sax[1] = cx + 2;
sax[1] = cy;
say[1] = cy;
sax[2] = cx;
sax[2] = cy + 2;
say[2] = cy + 2;
sax[3] = cx - 2;
sax[3] = cy;
say[3] = cy;
int best = -1;
double bestDist = 999;
for (int i = 0; i < sax.length; i++) {
Expand All @@ -773,14 +788,19 @@ public void generateAscensionPortal(final int x, final int y) {
int sy = say[best];
AStarSearch search = new AStarSearch(this, sx, sy, x, y);
if (search.doSearch()) {
search.doRoute();
int count = 0;
Tile tile = Tiles.getTileByName(TileNames.ASCENSION_VEIN_NSWE1);
do {
PathPoint point = search.getMove();
tiles[point.getX()][point.getY()] = tile.getIndex();
tileInfo[point.getX()][point.getY()] = new SquareInfo(
SquareInfo.TYPE_ASCENSION_VEIN, count);
search.nextMove();
if (point != null) {
tiles[point.getX()][point.getY()] = tile.getIndex();
tileInfo[point.getX()][point.getY()] = new SquareInfo(
SquareInfo.TYPE_ASCENSION_VEIN, count);
search.nextMove();
} else {
break;
}
} while (!search.isLastMove());
}
}
Expand Down

0 comments on commit 0450f61

Please sign in to comment.