first click should always be a zero
This commit is contained in:
parent
d2459bc793
commit
8ec019713c
2 changed files with 56 additions and 3 deletions
|
|
@ -36,6 +36,7 @@ public class MinecleanerArena {
|
||||||
private ArenaStatus arenaStatus = ArenaStatus.INACTIVE;
|
private ArenaStatus arenaStatus = ArenaStatus.INACTIVE;
|
||||||
private UUID[] blockDisplays;
|
private UUID[] blockDisplays;
|
||||||
// private UUID[] textDisplays;
|
// private UUID[] textDisplays;
|
||||||
|
private boolean hasMadeFirstClick = false;
|
||||||
|
|
||||||
private int flagsPlaced = 0;
|
private int flagsPlaced = 0;
|
||||||
|
|
||||||
|
|
@ -268,6 +269,7 @@ public class MinecleanerArena {
|
||||||
currentMinecleanerGame = new Game(plugin, BoardSize.boardSizes[widthIndex], BoardSize.mineCounter[widthIndex]);
|
currentMinecleanerGame = new Game(plugin, BoardSize.boardSizes[widthIndex], BoardSize.mineCounter[widthIndex]);
|
||||||
currentMinecleanerGame.start();
|
currentMinecleanerGame.start();
|
||||||
flagsPlaced = 0;
|
flagsPlaced = 0;
|
||||||
|
hasMadeFirstClick = false;
|
||||||
arenaStatus = ArenaStatus.PLAYING;
|
arenaStatus = ArenaStatus.PLAYING;
|
||||||
currentGameStartTime = System.currentTimeMillis();
|
currentGameStartTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
@ -340,6 +342,11 @@ public class MinecleanerArena {
|
||||||
Cell cell = currentMinecleanerGame.getCell(x, y);
|
Cell cell = currentMinecleanerGame.getCell(x, y);
|
||||||
if(!cell.isFlagged()) {
|
if(!cell.isFlagged()) {
|
||||||
Player player = this.currentPlayer;
|
Player player = this.currentPlayer;
|
||||||
|
|
||||||
|
if(!hasMadeFirstClick) {
|
||||||
|
currentMinecleanerGame.firstClick(x, y);
|
||||||
|
hasMadeFirstClick = true;
|
||||||
|
}
|
||||||
|
|
||||||
currentMinecleanerGame.reveal(x, y);
|
currentMinecleanerGame.reveal(x, y);
|
||||||
setBlockForCellType(x, y, cell);
|
setBlockForCellType(x, y, cell);
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,17 @@ public class Game {
|
||||||
gameover = false;
|
gameover = false;
|
||||||
|
|
||||||
generateCells();
|
generateCells();
|
||||||
generateMines();
|
//generateMines();
|
||||||
generateNumbers();
|
//generateNumbers();
|
||||||
|
|
||||||
board.draw(state, tilemap);
|
board.draw(state, tilemap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void firstClick(int xFirst, int yFirst) {
|
||||||
|
generateMines(xFirst, yFirst);
|
||||||
|
generateNumbers();
|
||||||
|
}
|
||||||
|
|
||||||
private void generateCells() {
|
private void generateCells() {
|
||||||
for (int x = 0; x < width; x ++) {
|
for (int x = 0; x < width; x ++) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
|
|
@ -62,11 +67,52 @@ public class Game {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateMines() {
|
private void generateMines(int xFirst, int yFirst) {
|
||||||
for (int i = 0; i < mineCount; i++) {
|
for (int i = 0; i < mineCount; i++) {
|
||||||
int x = (int) (Math.random() * width);
|
int x = (int) (Math.random() * width);
|
||||||
int y = (int) (Math.random() * height);
|
int y = (int) (Math.random() * height);
|
||||||
|
|
||||||
|
if(x == xFirst && y == yFirst) {
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(x == xFirst +1 && y == yFirst) {
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(x == xFirst +1 && y == yFirst -1) {
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(x == xFirst -1 && y == yFirst) {
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(x == xFirst && y == yFirst +1) {
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(x == xFirst && y == yFirst -1) {
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(x == xFirst +1 && y == yFirst +1) {
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(x == xFirst +1 && y == yFirst -1) {
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(x == xFirst -1 && y == yFirst -1) {
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(x == xFirst -1 && y == yFirst +1) {
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
while (state[x][y].type == Cell.CellType.Mine) {
|
while (state[x][y].type == Cell.CellType.Mine) {
|
||||||
x++;
|
x++;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue