mirror of
https://github.com/fooflington/wordsearch.git
synced 2025-01-22 09:19:55 +00:00
Start allowing more than just Normal and Simple mode... crossword mode won't fill in the random letters.
This commit is contained in:
parent
3c18a2c831
commit
cc2c7eee29
@ -155,12 +155,14 @@ public class GridFactory {
|
||||
}
|
||||
|
||||
public static char[][] makeGrid(List<String> words, int height, int width) {
|
||||
return makeGrid(words, height, width, false);
|
||||
return makeGrid(words, height, width, Modes.NORMAL);
|
||||
}
|
||||
|
||||
public static char[][] makeGrid(List<String> words, int height, int width, boolean simple) {
|
||||
public static char[][] makeGrid(List<String> words, int height, int width, Modes mode) {
|
||||
char[][] grid = new char[height][width];
|
||||
|
||||
bool simple = (mode == Modes.SIMPLE || mode == Modes.CROSSWORD);
|
||||
|
||||
// Place words at random?
|
||||
for (String word : words) {
|
||||
int tries = 0;
|
||||
@ -180,12 +182,14 @@ public class GridFactory {
|
||||
}
|
||||
}
|
||||
|
||||
// Fill rest of grid
|
||||
for (int y=0; y<height; y++) {
|
||||
for (int x=0; x<width; x++) {
|
||||
if (grid[y][x] == Character.UNASSIGNED)
|
||||
// grid[y][x] = '_';
|
||||
grid[y][x] = getRandomChar();
|
||||
if(mode != Modes.CROSSWORD) {
|
||||
// Fill rest of grid
|
||||
for (int y=0; y<height; y++) {
|
||||
for (int x=0; x<width; x++) {
|
||||
if (grid[y][x] == Character.UNASSIGNED)
|
||||
// grid[y][x] = '_';
|
||||
grid[y][x] = getRandomChar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,11 @@
|
||||
|
||||
int height = Integer.parseInt(request.getParameter("height"));
|
||||
int width = Integer.parseInt(request.getParameter("width"));
|
||||
boolean simple = request.getParameter("simple") != null;
|
||||
Modes mode = Modes.NORMAL;
|
||||
if(request.getParameter("mode") != null) {
|
||||
if(request.getParameter("mode") == "SIMPLE") mode = Modes.SIMPLE;
|
||||
if(request.getParameter("mode") == "CROSSWORD") mode = Modes.CROSSWORD;
|
||||
}
|
||||
String name = StringEscapeUtils.escapeHtml(request.getParameter("name"));
|
||||
|
||||
if (request.getParameter("words").length() > 2048) { throw new Exception("Input too large"); }
|
||||
@ -25,7 +29,7 @@
|
||||
}
|
||||
Collections.sort(words);
|
||||
|
||||
char[][] grid = GridFactory.makeGrid(words, height, width, simple);
|
||||
char[][] grid = GridFactory.makeGrid(words, height, width, mode);
|
||||
|
||||
String csv = "";
|
||||
%>
|
||||
|
@ -25,7 +25,9 @@ Dining Room
|
||||
<br />
|
||||
<input type="number" name="height" min="3" max="50" value="15" />
|
||||
<input type="number" name="width" min="3" max="50" value="15" />
|
||||
<input type="checkbox" name="simple" value="yes">Simple [<span class="tooltip" title="In simple mode, words are only placed Left-to-Right or Top-to-Bottom">?</span>]</span>
|
||||
<input type="radio" name="mode" value="NORMAL" checked />Normal
|
||||
<input type="radio" name="mode" value="SIMPLE" />Simple[<span class="tooltip" title="In simple mode, words are only placed Left-to-Right or Top-to-Bottom">?</span>]
|
||||
<input type="radio" name="mode" value="CROSSWORD" />Crossword
|
||||
<input type="submit" value="Build!" />
|
||||
</form>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user