From 0450f6166dc9143615caeb7c4b4ae91302f27dfb Mon Sep 17 00:00:00 2001 From: Tuomo Untinen Date: Tue, 14 Nov 2023 22:55:05 +0200 Subject: [PATCH] #537 Tries to calculate route from blackhole ascension portal. There are issues: Veins cannot more diagonally, missing tiles. Closed portal tile is wrong. --- .../org/openRealmOfStars/starMap/StarMap.java | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/openRealmOfStars/starMap/StarMap.java b/src/main/java/org/openRealmOfStars/starMap/StarMap.java index 4bac8f80b..61c940f74 100644 --- a/src/main/java/org/openRealmOfStars/starMap/StarMap.java +++ b/src/main/java/org/openRealmOfStars/starMap/StarMap.java @@ -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; @@ -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. * @@ -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++) { @@ -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()); } }