Amélioration du code et des menus

This commit is contained in:
2024-12-06 21:18:17 +01:00
parent 0720699f10
commit 0d4106f562
6 changed files with 210 additions and 125 deletions

View File

@@ -1,8 +1,6 @@
package fr.monkhanny.dorfromantik.game;
import fr.monkhanny.dorfromantik.enums.Biome;
import fr.monkhanny.dorfromantik.enums.TileOrientation;
import java.awt.Point;
import java.util.*;
/**

View File

@@ -57,14 +57,12 @@ public class ScoreManager {
newPocket.addTile(tile);
pockets.add(newPocket);
biomeToPocketMap.put(biome, newPocket);
System.out.println("New pocket created with biome: " + biome);
}
}
}
// Recalculer le score après avoir ajouté la tuile
recalculateScore();
System.out.println("Current Score: " + currentScore);
}
/**
@@ -82,46 +80,6 @@ public class ScoreManager {
}
return null;
}
/**
* Finds a pocket connected to the given tile with the specified biome.
*
* @param tile The tile to check connections for.
* @param biome The biome to match.
* @return The connected pocket, or null if none found.
*/
private Pocket findConnectedPocket(Tile tile, Biome biome) {
for (Pocket pocket : pockets) {
if (pocket.getBiome() == biome) {
for (Tile pocketTile : pocket.getTiles()) {
if (pocketTile.isAdjacentTo(tile) && sharesBiome(tile, pocketTile, biome)) {
return pocket;
}
}
}
}
return null;
}
/**
* Checks if two tiles share a biome on any of their sides.
*
* @param tile1 The first tile.
* @param tile2 The second tile.
* @param biome The biome to match.
* @return True if the tiles share the given biome on a connecting side.
*/
private boolean sharesBiome(Tile tile1, Tile tile2, Biome biome) {
for (TileOrientation orientation : TileOrientation.values()) {
if (tile1.getBiome(orientation) == biome && tile2.getBiome(orientation.oppositeOrientation()) == biome) {
return true;
}
}
return false;
}
/**
* Recalculates the score based on the current pockets.