This commit is contained in:
LunarAkai 2024-03-27 01:32:11 +01:00
commit 5c1e595759
5 changed files with 34 additions and 24 deletions

View file

@ -78,7 +78,7 @@ public class MinecleanerArena {
this.name = Preconditions.checkNotNull(arenaSection.getString("name")); this.name = Preconditions.checkNotNull(arenaSection.getString("name"));
this.location = Preconditions.checkNotNull(arenaSection.getLocation("location")); this.location = Preconditions.checkNotNull(arenaSection.getLocation("location"));
this.widthIndex = Preconditions.checkNotNull(arenaSection.getInt("fieldwidth")); this.widthIndex = Preconditions.checkNotNull(arenaSection.getInt("fieldwidth"));
this.blockDisplays = new UUID[BoardSize.boardSizes[widthIndex] * BoardSize.boardSizes[widthIndex]]; this.blockDisplays = new UUID[BoardSize.boardSizesWidth[widthIndex] * BoardSize.boardSizesHeight[widthIndex]];
// this.textDisplays = new UUID[1]; // this.textDisplays = new UUID[1];
BlockFace orientation = BlockFace.NORTH; BlockFace orientation = BlockFace.NORTH;
@ -113,7 +113,7 @@ public class MinecleanerArena {
this.name = Preconditions.checkNotNull(name, "name"); this.name = Preconditions.checkNotNull(name, "name");
this.location = Preconditions.checkNotNull(location, "location"); this.location = Preconditions.checkNotNull(location, "location");
this.widthIndex = Preconditions.checkNotNull(widthIndex, ("fieldwidth")); this.widthIndex = Preconditions.checkNotNull(widthIndex, ("fieldwidth"));
this.blockDisplays = new UUID[BoardSize.boardSizes[widthIndex] * BoardSize.boardSizes[widthIndex]]; this.blockDisplays = new UUID[BoardSize.boardSizesWidth[widthIndex] * BoardSize.boardSizesHeight[widthIndex]];
//this.textDisplays = new UUID[1]; //this.textDisplays = new UUID[1];
Preconditions.checkArgument(Math.abs(orientation.getModX()) + Math.abs(orientation.getModZ()) == 1, "no cardinal direction"); Preconditions.checkArgument(Math.abs(orientation.getModX()) + Math.abs(orientation.getModZ()) == 1, "no cardinal direction");
@ -149,7 +149,8 @@ public class MinecleanerArena {
* Bei Größen WidthIndex 1 + 2 -> Mitte = ein Block nach Links unten versetzt * Bei Größen WidthIndex 1 + 2 -> Mitte = ein Block nach Links unten versetzt
*/ */
public void generateBlockDisplays() { public void generateBlockDisplays() {
int size = BoardSize.boardSizes[widthIndex]; int sizeWidth = BoardSize.boardSizesWidth[widthIndex];
int sizeHeight = BoardSize.boardSizesHeight[widthIndex];
World world = location.getWorld(); World world = location.getWorld();
for(UUID id : blockDisplays) { for(UUID id : blockDisplays) {
@ -191,9 +192,9 @@ public class MinecleanerArena {
Location loc = location.clone(); Location loc = location.clone();
for(int fx = 0; fx < size; fx++) { for(int fx = 0; fx < sizeHeight; fx++) {
final int fxf = fx; final int fxf = fx;
for(int fz = 0; fz < size; fz++) { for(int fz = 0; fz < sizeWidth; fz++) {
final int fzf = fz; final int fzf = fz;
loc.set(location.getX() - 0.016 + eastWestGapFixX + southGapFixX - (d1x * fz) / 3.0 + d0x * 0.55 + d1x * 1.847, loc.set(location.getX() - 0.016 + eastWestGapFixX + southGapFixX - (d1x * fz) / 3.0 + d0x * 0.55 + d1x * 1.847,
@ -219,7 +220,7 @@ public class MinecleanerArena {
if(blockDisplay != null) { if(blockDisplay != null) {
blockDisplays[fxf + fzf * size] = blockDisplay.getUniqueId(); blockDisplays[fxf * sizeHeight + fzf] = blockDisplay.getUniqueId();
} }
} }
} }
@ -271,9 +272,10 @@ public class MinecleanerArena {
} }
private void setDiplayBlock(int x, int y, MinecleanerHeads head, boolean applyUsualRotation) { private void setDiplayBlock(int x, int y, MinecleanerHeads head, boolean applyUsualRotation) {
int size = BoardSize.boardSizes[widthIndex]; int sizeWidth = BoardSize.boardSizesWidth[widthIndex];
int sizeHeight = BoardSize.boardSizesHeight[widthIndex];
UUID blockDisplayId = blockDisplays[x + y * size]; UUID blockDisplayId = blockDisplays[x * sizeHeight + y];
Entity blockDisplay = blockDisplayId != null ? location.getWorld().getEntity(blockDisplayId) : null; Entity blockDisplay = blockDisplayId != null ? location.getWorld().getEntity(blockDisplayId) : null;
if(blockDisplay instanceof ItemDisplay) { if(blockDisplay instanceof ItemDisplay) {
ItemDisplay display = (ItemDisplay) blockDisplay; ItemDisplay display = (ItemDisplay) blockDisplay;
@ -287,7 +289,7 @@ public class MinecleanerArena {
} }
public void startNewGame() { public void startNewGame() {
currentMinecleanerGame = new Game(plugin, BoardSize.boardSizes[widthIndex], BoardSize.mineCounter[widthIndex]); currentMinecleanerGame = new Game(plugin, BoardSize.boardSizesWidth[widthIndex], BoardSize.boardSizesHeight[widthIndex], BoardSize.mineCounter[widthIndex]);
currentMinecleanerGame.start(); currentMinecleanerGame.start();
removeStartHeads(); removeStartHeads();
flagsPlaced = 0; flagsPlaced = 0;
@ -313,14 +315,15 @@ public class MinecleanerArena {
} }
public void removePlayer() { public void removePlayer() {
int size = BoardSize.boardSizes[widthIndex]; int sizeWidth = BoardSize.boardSizesWidth[widthIndex];
int sizeHeight = BoardSize.boardSizesWidth[widthIndex];
this.arenaStatus = ArenaStatus.INACTIVE; this.arenaStatus = ArenaStatus.INACTIVE;
this.currentPlayer = null; this.currentPlayer = null;
this.currentMinecleanerGame = null; this.currentMinecleanerGame = null;
for(int x = 0; x < size; x++) { for(int x = 0; x < sizeWidth; x++) {
for(int y = 0; y < size; y++) { for(int y = 0; y < sizeHeight; y++) {
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true); setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
} }
} }
@ -379,12 +382,13 @@ public class MinecleanerArena {
} }
public void removeBlockDisplays() { public void removeBlockDisplays() {
int size = BoardSize.boardSizes[widthIndex]; int sizeWidth = BoardSize.boardSizesWidth[widthIndex];
int sizeHeight = BoardSize.boardSizesHeight[widthIndex];
World world = location.getWorld(); World world = location.getWorld();
for(int fx = 0; fx < size; fx++) { for(int fx = 0; fx < sizeWidth; fx++) {
for(int fy = 0; fy < size; fy++) { for(int fy = 0; fy < sizeHeight; fy++) {
UUID blockDisplayUuid = blockDisplays[fx + fy * size]; UUID blockDisplayUuid = blockDisplays[fx * sizeHeight + fy];
Entity blockDisplayEntity = blockDisplayUuid != null ? world.getEntity(blockDisplayUuid) : null; Entity blockDisplayEntity = blockDisplayUuid != null ? world.getEntity(blockDisplayUuid) : null;
if(blockDisplayEntity instanceof Display blockdisplay) { if(blockDisplayEntity instanceof Display blockdisplay) {
blockDisplayEntity.remove(); blockDisplayEntity.remove();
@ -600,7 +604,7 @@ public class MinecleanerArena {
} }
public int getSize() { public int getSize() {
return BoardSize.boardSizes[widthIndex]; return BoardSize.boardSizesWidth[widthIndex];
} }
public long getCurrentGameStartTime() { public long getCurrentGameStartTime() {

View file

@ -72,7 +72,7 @@ public class MinecleanerListener implements Listener {
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) { if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
hasRightClicked = true; hasRightClicked = true;
} }
//player.sendMessage("Arena click! " + blockxInt + " " + blockzInt + " Right Clicked: " + hasRightClicked); player.sendMessage("Arena click! " + blockxInt + " " + blockzInt + " Right Clicked: " + hasRightClicked);
plugin.getManager().handleFieldClick(e.getPlayer(), blockxInt, blockzInt, hasRightClicked); plugin.getManager().handleFieldClick(e.getPlayer(), blockxInt, blockzInt, hasRightClicked);
} }
} }

View file

@ -237,7 +237,7 @@ public class MinecleanerManager {
HashMap<Integer, PlayerStatisticsQueryKey> kSizeTotalGamesPlayed = new HashMap<>(); HashMap<Integer, PlayerStatisticsQueryKey> kSizeTotalGamesPlayed = new HashMap<>();
HashMap<Integer, PlayerStatisticsQueryKey> kSizeTotalGamesPlayedMonth = new HashMap<>(); HashMap<Integer, PlayerStatisticsQueryKey> kSizeTotalGamesPlayedMonth = new HashMap<>();
for (int i = 0; i < BoardSize.boardSizes.length; i++) { for (int i = 0; i < BoardSize.boardSizesWidth.length; i++) {
PlayerStatisticsQueryKey qk; PlayerStatisticsQueryKey qk;
StatisticKey statisticKeyGames = statisticsGames.get(i); StatisticKey statisticKeyGames = statisticsGames.get(i);
keys.add(qk = new PlayerStatisticsQueryKey(pStatistics, statisticKeyGames, QueryType.SCORE)); keys.add(qk = new PlayerStatisticsQueryKey(pStatistics, statisticKeyGames, QueryType.SCORE));
@ -276,7 +276,7 @@ public class MinecleanerManager {
HashMap<Integer, Integer> sizeTotalGamesPlayed = new HashMap<>(); HashMap<Integer, Integer> sizeTotalGamesPlayed = new HashMap<>();
HashMap<Integer, Integer> sizeTotalGamesPlayedMonth = new HashMap<>(); HashMap<Integer, Integer> sizeTotalGamesPlayedMonth = new HashMap<>();
for(int i = 0; i < BoardSize.boardSizes.length; i++) { for(int i = 0; i < BoardSize.boardSizesWidth.length; i++) {
sizeWonGames.put(i, c.getOrDefault(kWonGamesPlayedSize.get(i), 0)); sizeWonGames.put(i, c.getOrDefault(kWonGamesPlayedSize.get(i), 0));
sizeWonGamesMonth.put(i, c.getOrDefault(kWonGamesPlayedSizeMonth.get(i), 0)); sizeWonGamesMonth.put(i, c.getOrDefault(kWonGamesPlayedSizeMonth.get(i), 0));
sizeTimeRecord.put(i, c.getOrDefault(kSizeTimeRecord.get(i), null)); sizeTimeRecord.put(i, c.getOrDefault(kSizeTimeRecord.get(i), null));

View file

@ -1,10 +1,16 @@
package de.lunarakai.minecleaner.game; package de.lunarakai.minecleaner.game;
public class BoardSize { public class BoardSize {
public static int[] boardSizes = { public static int[] boardSizesWidth = {
9, 9,
12, 12,
15, 18,
};
public static int[] boardSizesHeight = {
9,
12,
12,
}; };
public static int[] mineCounter = { public static int[] mineCounter = {

View file

@ -20,10 +20,10 @@ public class Game {
private int floodedFlaggedCellsCounter; private int floodedFlaggedCellsCounter;
private ArrayList<Cell> explodedCells; private ArrayList<Cell> explodedCells;
public Game(MinecleanerPlugin plugin, int width, int mineCount) { public Game(MinecleanerPlugin plugin, int width, int height, int mineCount) {
this.plugin = plugin; this.plugin = plugin;
this.width = width; this.width = width;
this.height = width; this.height = height;
this.mineCount = mineCount; this.mineCount = mineCount;
this.floodedCells = new ArrayList<>(); this.floodedCells = new ArrayList<>();