Compare commits

..

No commits in common. "91e0e3137f686cdb29197ee1ed6f306c18ea7071" and "c0503f5446581482fc77c4c6b099072f2a0eaf4b" have entirely different histories.

5 changed files with 68 additions and 71 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.boardSizesWidth[widthIndex] * BoardSize.boardSizesHeight[widthIndex]]; this.blockDisplays = new UUID[BoardSize.boardSizes[widthIndex] * BoardSize.boardSizes[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.boardSizesWidth[widthIndex] * BoardSize.boardSizesHeight[widthIndex]]; this.blockDisplays = new UUID[BoardSize.boardSizes[widthIndex] * BoardSize.boardSizes[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,8 +149,7 @@ 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 sizeWidth = BoardSize.boardSizesWidth[widthIndex]; int size = BoardSize.boardSizes[widthIndex];
int sizeHeight = BoardSize.boardSizesHeight[widthIndex];
World world = location.getWorld(); World world = location.getWorld();
for(UUID id : blockDisplays) { for(UUID id : blockDisplays) {
@ -192,9 +191,9 @@ public class MinecleanerArena {
Location loc = location.clone(); Location loc = location.clone();
for(int fx = 0; fx < sizeHeight; fx++) { for(int fx = 0; fx < size; fx++) {
final int fxf = fx; final int fxf = fx;
for(int fz = 0; fz < sizeWidth; fz++) { for(int fz = 0; fz < size; 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,
@ -220,7 +219,7 @@ public class MinecleanerArena {
if(blockDisplay != null) { if(blockDisplay != null) {
blockDisplays[fxf * sizeWidth + fzf] = blockDisplay.getUniqueId(); blockDisplays[fxf + fzf * size] = blockDisplay.getUniqueId();
} }
} }
} }
@ -272,10 +271,9 @@ 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 sizeWidth = BoardSize.boardSizesWidth[widthIndex]; int size = BoardSize.boardSizes[widthIndex];
int sizeHeight = BoardSize.boardSizesHeight[widthIndex];
UUID blockDisplayId = blockDisplays[x + y * sizeWidth]; UUID blockDisplayId = blockDisplays[x + y * size];
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;
@ -289,7 +287,7 @@ public class MinecleanerArena {
} }
public void startNewGame() { public void startNewGame() {
currentMinecleanerGame = new Game(plugin, BoardSize.boardSizesWidth[widthIndex], BoardSize.boardSizesHeight[widthIndex], BoardSize.mineCounter[widthIndex]); currentMinecleanerGame = new Game(plugin, BoardSize.boardSizes[widthIndex], BoardSize.mineCounter[widthIndex]);
currentMinecleanerGame.start(); currentMinecleanerGame.start();
removeStartHeads(); removeStartHeads();
flagsPlaced = 0; flagsPlaced = 0;
@ -315,15 +313,14 @@ public class MinecleanerArena {
} }
public void removePlayer() { public void removePlayer() {
int sizeWidth = BoardSize.boardSizesWidth[widthIndex]; int size = BoardSize.boardSizes[widthIndex];
int sizeHeight = BoardSize.boardSizesHeight[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 < sizeWidth; x++) { for(int x = 0; x < size; x++) {
for(int y = 0; y < sizeHeight; y++) { for(int y = 0; y < size; y++) {
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true); setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
} }
} }
@ -331,57 +328,63 @@ public class MinecleanerArena {
} }
public void showStartHeads() { public void showStartHeads() {
int width = BoardSize.boardSizesWidth[widthIndex]; int correction = 1;
int height = BoardSize.boardSizesHeight[widthIndex]; int xcorrection = 0;
if(widthIndex == 0) {
correction = 0;
}
if(widthIndex == 2) {
xcorrection = 1;
}
// MINE - // MINE -
setDiplayBlock(width/2-2 + 0, height/2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_M, true); setDiplayBlock(5+widthIndex+xcorrection, 2+widthIndex+correction, MinecleanerHeads.MINESWEEPER_LETTER_M, true);
setDiplayBlock(width/2-2 + 1, height/2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_I, true); setDiplayBlock(5+widthIndex+xcorrection, 3+widthIndex+correction, MinecleanerHeads.MINESWEEPER_LETTER_I, true);
setDiplayBlock(width/2-2 + 2, height/2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_N, true); setDiplayBlock(5+widthIndex+xcorrection, 4+widthIndex+correction, MinecleanerHeads.MINESWEEPER_LETTER_N, true);
setDiplayBlock(width/2-2 + 3, height/2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_E, true); setDiplayBlock(5+widthIndex+xcorrection, 5+widthIndex+correction, MinecleanerHeads.MINESWEEPER_LETTER_E, true);
setDiplayBlock(width/2-2 + 4, height/2 + 1, MinecleanerHeads.MINESWEEPER_LETTER_MINUS, true); setDiplayBlock(5+widthIndex+xcorrection, 6+widthIndex+correction, MinecleanerHeads.MINESWEEPER_LETTER_MINUS, true);
// SWEEPER // SWEEPER
setDiplayBlock(width/2-3 + 0, height/2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_S, true); setDiplayBlock(3+widthIndex+xcorrection, 1+widthIndex+correction, MinecleanerHeads.MINESWEEPER_LETTER_S, true);
setDiplayBlock(width/2-3 + 1, height/2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_W, true); setDiplayBlock(3+widthIndex+xcorrection, 2+widthIndex+correction, MinecleanerHeads.MINESWEEPER_LETTER_W, true);
setDiplayBlock(width/2-3 + 2, height/2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_E, true); setDiplayBlock(3+widthIndex+xcorrection, 3+widthIndex+correction, MinecleanerHeads.MINESWEEPER_LETTER_E, true);
setDiplayBlock(width/2-3 + 3, height/2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_E, true); setDiplayBlock(3+widthIndex+xcorrection, 4+widthIndex+correction, MinecleanerHeads.MINESWEEPER_LETTER_E, true);
setDiplayBlock(width/2-3 + 4, height/2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_P, true); setDiplayBlock(3+widthIndex+xcorrection, 5+widthIndex+correction, MinecleanerHeads.MINESWEEPER_LETTER_P, true);
setDiplayBlock(width/2-3 + 5, height/2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_E, true); setDiplayBlock(3+widthIndex+xcorrection, 6+widthIndex+correction, MinecleanerHeads.MINESWEEPER_LETTER_E, true);
setDiplayBlock(width/2-3 + 6, height/2 - 1, MinecleanerHeads.MINESWEEPER_LETTER_R, true); setDiplayBlock(3+widthIndex+xcorrection, 7+widthIndex+correction, MinecleanerHeads.MINESWEEPER_LETTER_R, true);
} }
public void removeStartHeads() { public void removeStartHeads() {
int width = BoardSize.boardSizesWidth[widthIndex]; int correction = 1;
int height = BoardSize.boardSizesHeight[widthIndex]; int xcorrection = 0;
if(widthIndex == 0) {
correction = 0;
}
if(widthIndex == 2) {
xcorrection = 1;
}
setDiplayBlock(5+widthIndex+xcorrection, 2+widthIndex+correction, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(5+widthIndex+xcorrection, 3+widthIndex+correction, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(5+widthIndex+xcorrection, 4+widthIndex+correction, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(5+widthIndex+xcorrection, 5+widthIndex+correction, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(5+widthIndex+xcorrection, 6+widthIndex+correction, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
// MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN setDiplayBlock(3+widthIndex+xcorrection, 1+widthIndex+correction, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
// MINE - setDiplayBlock(3+widthIndex+xcorrection, 2+widthIndex+correction, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(width/2-2 + 0, height/2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true); setDiplayBlock(3+widthIndex+xcorrection, 3+widthIndex+correction, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(width/2-2 + 1, height/2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true); setDiplayBlock(3+widthIndex+xcorrection, 4+widthIndex+correction, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(width/2-2 + 2, height/2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true); setDiplayBlock(3+widthIndex+xcorrection, 5+widthIndex+correction, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(width/2-2 + 3, height/2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true); setDiplayBlock(3+widthIndex+xcorrection, 6+widthIndex+correction, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(width/2-2 + 4, height/2 + 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true); setDiplayBlock(3+widthIndex+xcorrection, 7+widthIndex+correction, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
// SWEEPER
setDiplayBlock(width/2-3 + 0, height/2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(width/2-3 + 1, height/2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(width/2-3 + 2, height/2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(width/2-3 + 3, height/2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(width/2-3 + 4, height/2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(width/2-3 + 5, height/2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
setDiplayBlock(width/2-3 + 6, height/2 - 1, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
} }
public void removeBlockDisplays() { public void removeBlockDisplays() {
int sizeWidth = BoardSize.boardSizesWidth[widthIndex]; int size = BoardSize.boardSizes[widthIndex];
int sizeHeight = BoardSize.boardSizesHeight[widthIndex];
World world = location.getWorld(); World world = location.getWorld();
for(int fx = 0; fx < sizeWidth; fx++) { for(int fx = 0; fx < size; fx++) {
for(int fy = 0; fy < sizeHeight; fy++) { for(int fy = 0; fy < size; fy++) {
UUID blockDisplayUuid = blockDisplays[fx + fy * sizeWidth]; UUID blockDisplayUuid = blockDisplays[fx + fy * size];
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();
@ -540,9 +543,9 @@ public class MinecleanerArena {
int d1z = d0x; int d1z = d0x;
Location loc = location.clone(); Location loc = location.clone();
for(int fx = -1 - (BoardSize.boardSizesWidth[widthIndex]/3 - 3); fx < 2; fx++) { // boardWith/3 for(int fx = -1 - widthIndex; fx < 2; fx++) {
for(int fy = -1; fy < BoardSize.boardSizesHeight[widthIndex]/3 - 1; fy++) { // fy < boardHeight/3 - 1 for(int fy = -1; fy < 2 + widthIndex; fy++) {
loc.set(location.getX() + d1x * fx, location.getY() + fy, location.getZ() + d1z * fx); loc.set(location.getX() + d1x * fx, location.getY() + fy, location.getZ() + d1z * fx);
blocks.add(loc.clone()); blocks.add(loc.clone());
} }
@ -597,7 +600,7 @@ public class MinecleanerArena {
} }
public int getSize() { public int getSize() {
return BoardSize.boardSizesWidth[widthIndex]; return BoardSize.boardSizes[widthIndex];
} }
public long getCurrentGameStartTime() { public long getCurrentGameStartTime() {

View file

@ -73,7 +73,7 @@ public class MinecleanerListener implements Listener {
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(), blockzInt, blockxInt, 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.boardSizesWidth.length; i++) { for (int i = 0; i < BoardSize.boardSizes.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.boardSizesWidth.length; i++) { for(int i = 0; i < BoardSize.boardSizes.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,21 +1,15 @@
package de.lunarakai.minecleaner.game; package de.lunarakai.minecleaner.game;
public class BoardSize { public class BoardSize {
public static int[] boardSizesWidth = { public static int[] boardSizes = {
9, 9,
12, 12,
18, 15,
};
public static int[] boardSizesHeight = {
9,
12,
12,
}; };
public static int[] mineCounter = { public static int[] mineCounter = {
12, 12,
25, 25,
45, 50,
}; };
} }

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 height, int mineCount) { public Game(MinecleanerPlugin plugin, int width, int mineCount) {
this.plugin = plugin; this.plugin = plugin;
this.width = width; this.width = width;
this.height = height; this.height = width;
this.mineCount = mineCount; this.mineCount = mineCount;
this.floodedCells = new ArrayList<>(); this.floodedCells = new ArrayList<>();