change demo url
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
Similar Words Game.
|
Similar Words Game.
|
||||||
============
|
============
|
||||||
A demo is on http://w.r0xy.it/
|
A demo is on https://similarwords.31337.it/
|
||||||
|
|
||||||
|
|
||||||
To create your own wordlist just edit ```createwordlist.js``` and run it with ```node```.
|
To create your own wordlist just edit ```createwordlist.js``` and run it with ```node```.
|
||||||
|
@@ -25,7 +25,8 @@ if (typeof(sw) == 'undefined') {
|
|||||||
|
|
||||||
var getKey = function(obj) {
|
var getKey = function(obj) {
|
||||||
var word = [];
|
var word = [];
|
||||||
for(var k in obj) word.push(k);
|
for ( var k in obj)
|
||||||
|
word.push(k);
|
||||||
return word[0];
|
return word[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -40,7 +41,10 @@ if (typeof(sw) == 'undefined') {
|
|||||||
similar.push(word);
|
similar.push(word);
|
||||||
similar = shuffle(similar);
|
similar = shuffle(similar);
|
||||||
|
|
||||||
return {word: word, similar: similar};
|
return {
|
||||||
|
word: word,
|
||||||
|
similar: similar
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var startGame = function(word) {
|
var startGame = function(word) {
|
||||||
@@ -59,15 +63,20 @@ if (typeof(sw) == 'undefined') {
|
|||||||
|
|
||||||
if (sw.finaltime > 33) {
|
if (sw.finaltime > 33) {
|
||||||
result = 'You can do better!';
|
result = 'You can do better!';
|
||||||
};
|
}
|
||||||
if (sw.finaltime > 36) {
|
if (sw.finaltime > 36) {
|
||||||
result = 'meh...';
|
result = 'meh...';
|
||||||
};
|
}
|
||||||
if (sw.wrongWords > 0 && sw.finaltime <= 32) {
|
if (sw.wrongWords > 0 && sw.finaltime <= 32) {
|
||||||
result = 'You are fast, but you made errors';
|
result = 'You are fast, but you made errors';
|
||||||
};
|
}
|
||||||
|
|
||||||
$("#main").empty().html('views/gameover.ejs', {result: result, time: sw.finaltime, wrong: sw.wrongWords, correct: sw.correctWords});
|
$("#main").empty().html('views/gameover.ejs', {
|
||||||
|
result: result,
|
||||||
|
time: sw.finaltime,
|
||||||
|
wrong: sw.wrongWords,
|
||||||
|
correct: sw.correctWords
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var startNewGame = function() {
|
var startNewGame = function() {
|
||||||
@@ -142,7 +151,7 @@ if (typeof(sw) == 'undefined') {
|
|||||||
}
|
}
|
||||||
$('.word-button').addClass('disabled');
|
$('.word-button').addClass('disabled');
|
||||||
|
|
||||||
var wrongWord = undefined;
|
var wrongWord;
|
||||||
if (sw.currentWord.word == el.html()) {
|
if (sw.currentWord.word == el.html()) {
|
||||||
sw.correctWords = sw.correctWords + 1;
|
sw.correctWords = sw.correctWords + 1;
|
||||||
sw.rounds += 1;
|
sw.rounds += 1;
|
||||||
@@ -171,7 +180,7 @@ if (typeof(sw) == 'undefined') {
|
|||||||
sw.time = 0;
|
sw.time = 0;
|
||||||
sw.finaltime = 0;
|
sw.finaltime = 0;
|
||||||
sw.gameover = false;
|
sw.gameover = false;
|
||||||
sw.currentWord;
|
sw.currentWord = '';
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
|
|
||||||
@@ -197,4 +206,3 @@ if (typeof(sw) == 'undefined') {
|
|||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@@ -19,7 +19,8 @@ fs.readFile(dict, 'utf8', function(err, data) {
|
|||||||
if (word.length > 6 && word.length < 10) {
|
if (word.length > 6 && word.length < 10) {
|
||||||
// console.log('using ' + word);
|
// console.log('using ' + word);
|
||||||
words.push(word);
|
words.push(word);
|
||||||
};
|
}
|
||||||
|
;
|
||||||
}
|
}
|
||||||
console.log('using ' + words.length + ' words out of the dictionary');
|
console.log('using ' + words.length + ' words out of the dictionary');
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ fs.readFile(dict, 'utf8', function(err, data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add to dictionary?
|
// add to dictionary?
|
||||||
if(matches.length >= 4) {
|
if (matches.length >= 6) {
|
||||||
console.log('using ' + word);
|
console.log('using ' + word);
|
||||||
var mw = {};
|
var mw = {};
|
||||||
mw[word] = matches;
|
mw[word] = matches;
|
||||||
@@ -67,6 +68,8 @@ fs.readFile(dict, 'utf8', function(err, data) {
|
|||||||
|
|
||||||
|
|
||||||
console.log('final result');
|
console.log('final result');
|
||||||
console.log(JSON.stringify(matchingWordlist));
|
console.log(JSON.stringify({
|
||||||
|
words: matchingWordlist
|
||||||
|
}));
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user