rename references
This commit is contained in:
@ -0,0 +1,64 @@
|
||||
package minesweeper.settings;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class GameSettings {
|
||||
|
||||
/**
|
||||
* 9x9/10
|
||||
*/
|
||||
final static public GameSettings BEGINNER = new GameSettings(9, 9, 10, "Beginner");
|
||||
/**
|
||||
* 16x16/40
|
||||
*/
|
||||
final static public GameSettings ADVANCED = new GameSettings(16, 16, 40, "Advanced");
|
||||
/**
|
||||
* 30x16/99
|
||||
*/
|
||||
final static public GameSettings EXPERT = new GameSettings(30, 16, 99, "Expert");
|
||||
|
||||
final static private List<GameSettings> standardSettings = Arrays.asList(BEGINNER, ADVANCED, EXPERT);
|
||||
|
||||
final public int width;
|
||||
final public int height;
|
||||
final public int mines;
|
||||
final public String name;
|
||||
|
||||
private GameSettings(int width, int height, int mines) {
|
||||
this(width, height, mines, "Custom");
|
||||
}
|
||||
|
||||
private GameSettings(int width, int height, int mines, String name) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.mines = mines;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static GameSettings create(int width, int height, int mines) {
|
||||
|
||||
for (GameSettings game: standardSettings) {
|
||||
if (game.width == width && game.height == height && game.mines == mines) {
|
||||
return game;
|
||||
}
|
||||
}
|
||||
|
||||
return new GameSettings(width, height, mines, "Custom");
|
||||
|
||||
}
|
||||
|
||||
public String description() {
|
||||
|
||||
return name + " (" + width + "," + height + "," + mines + ")";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
return width + "x" + height + "/" + mines;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package minesweeper.settings;
|
||||
|
||||
public enum GameType {
|
||||
|
||||
/**
|
||||
* Game starts with a guaranteed zero
|
||||
*/
|
||||
EASY("Zero"),
|
||||
|
||||
/**
|
||||
* Game starts with a guaranteed safe position (which could be a zero)
|
||||
*/
|
||||
STANDARD("Safe"),
|
||||
|
||||
/**
|
||||
* No guaranteed safe start (could be a mine)
|
||||
*/
|
||||
HARD("Unsafe");
|
||||
|
||||
|
||||
public final String name;
|
||||
|
||||
private GameType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user