|
|
|
@ -15,16 +15,22 @@
|
|
|
|
|
<script src="../entryui.js"></script>
|
|
|
|
|
<script >
|
|
|
|
|
class CrosswordUI extends AnagramEntryUI {
|
|
|
|
|
submitWord() {
|
|
|
|
|
submitWord(word) {
|
|
|
|
|
if (this.won) return;
|
|
|
|
|
let seenSpace = false;
|
|
|
|
|
for (let idx in this.letters) {
|
|
|
|
|
if (this.letters[idx] == '') seenSpace = true;
|
|
|
|
|
else if (seenSpace) return;
|
|
|
|
|
let guess;
|
|
|
|
|
if (word) {
|
|
|
|
|
guess = word;
|
|
|
|
|
} else {
|
|
|
|
|
let seenSpace = false;
|
|
|
|
|
for (let idx in this.letters) {
|
|
|
|
|
if (this.letters[idx] == '') seenSpace = true;
|
|
|
|
|
else if (seenSpace) return;
|
|
|
|
|
}
|
|
|
|
|
guess = this.letters.join('');
|
|
|
|
|
}
|
|
|
|
|
let guess = this.letters.join('');
|
|
|
|
|
let results = this.game.makeGuess(guess);
|
|
|
|
|
if (results === null) return;
|
|
|
|
|
this.saveGuess(guess);
|
|
|
|
|
|
|
|
|
|
this.updateCrossword(results);
|
|
|
|
|
|
|
|
|
@ -33,7 +39,7 @@
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < this.game.numLetters; i++) {
|
|
|
|
|
let letter = document.createElement('td');
|
|
|
|
|
letter.innerText = this.letters[i];
|
|
|
|
|
letter.innerText = guess[i] || '';
|
|
|
|
|
resultDisplay.appendChild(letter);
|
|
|
|
|
}
|
|
|
|
|
let link = document.createElement('a');
|
|
|
|
@ -122,17 +128,6 @@
|
|
|
|
|
return this.mayEnterLetterAt(letter, this.focusedTextbox);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newGame() {
|
|
|
|
|
let settings = this.getSettingsObjectFromForm();
|
|
|
|
|
if (settings === null) return;
|
|
|
|
|
|
|
|
|
|
let game;
|
|
|
|
|
do {
|
|
|
|
|
game = Crossword.generateRandom(settings);
|
|
|
|
|
} while (game === null && window.confirm('Unable to generate puzzle with the given difficulty settings. Try again?'));
|
|
|
|
|
if (game !== null) this.initialize(game);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get defaultSettings() {
|
|
|
|
|
let default_settings = {
|
|
|
|
|
'min_word_length': 4,
|
|
|
|
@ -196,11 +191,11 @@
|
|
|
|
|
ui.saveSettings();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (game === null) {
|
|
|
|
|
this.newGame();
|
|
|
|
|
} else {
|
|
|
|
|
this.initialize(game);
|
|
|
|
|
}
|
|
|
|
|
this.nextGame(game);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get gameClass() {
|
|
|
|
|
return Crossword;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initialize(game) {
|
|
|
|
@ -208,7 +203,7 @@
|
|
|
|
|
this.game = game;
|
|
|
|
|
let ui = this;
|
|
|
|
|
|
|
|
|
|
scrambleString(game.getFragment(), ['', 'A', 'B']).then(fragment => {
|
|
|
|
|
scrambleString(game.fragment, ['', 'A', 'B']).then(fragment => {
|
|
|
|
|
document.getElementById('permalink').href = '#' + fragment;
|
|
|
|
|
document.getElementById('permalink_input').value
|
|
|
|
|
= window.location.href.split('#')[0] + '#' + fragment;
|
|
|
|
@ -286,6 +281,8 @@
|
|
|
|
|
document.getElementById('bonus_words_found').innerText = 0;
|
|
|
|
|
document.getElementById('clues_total').innerText = game.clues.length;
|
|
|
|
|
document.getElementById('top_words_total').innerText = game.allTopWords.size - game.clues.length;
|
|
|
|
|
|
|
|
|
|
this.doPostInitialize();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -323,7 +320,9 @@
|
|
|
|
|
<a href="#" target="_blank" id="permalink">Permalink</a>
|
|
|
|
|
to current puzzle:
|
|
|
|
|
<input contenteditable id="permalink_input" />
|
|
|
|
|
<button id="copy_permalink">Copy</button>
|
|
|
|
|
<button id="copy_permalink">Copy</button><br />
|
|
|
|
|
<select id="available_games"></select>
|
|
|
|
|
<button id="switch_game">Switch Game</button>
|
|
|
|
|
<h2>Difficulty</h2>
|
|
|
|
|
<form id="difficulty" onsubmit="return false;">
|
|
|
|
|
Word length:
|
|
|
|
@ -386,7 +385,7 @@
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="endgame">
|
|
|
|
|
<button id="newgame">New Game</button>
|
|
|
|
|
<button id="newgame">Next Game</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="available_letters_display">
|
|
|
|
|
<button id="shuffle"></button>
|
|
|
|
|