diff --git a/LICENSE.txt b/LICENSE.txt
index ce5c81d..b22ea5e 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2017 JW
+Copyright (c) 2017 Roel Cabrera
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/bossgle.js b/bossgle.js
index b33bf48..124f75e 100644
--- a/bossgle.js
+++ b/bossgle.js
@@ -1,171 +1,161 @@
-
-$(document).ready(function () {
-
- var lettersHTML = '';
- var totalScore = 0;
- var totalWords = 0;
- var wordHash = {};
-
- // Set initial random letters.
- randomLetters();
-
- if (timer() === 0) {
- console.log('Game Ended');
+var score = 0;
+var letterContainer = [];
+var letters = [];
+var active_letters = [];
+var word_list = [];
+var word_count = [];
+var count = 60;
+
+//random letter generator
+function randomLetters() {
+ var num = Math.floor(Math.random() * 26);
+ var letter = String.fromCharCode(num + 65);
+ return letter;
+}
+//displays letters
+function display_letters() {
+ $('#letter-container').html(active_letters.join(''));
+}
+// score updates
+function update_score(add_me) {
+ var $score = $('#totalScore');
+ $score.html(parseInt($score.html()) + add_me);
+}
+//correct word counter
+function update_word_count() {
+ var $count = $('#wordCount');
+ word_count.push($count);
+ $count.html(word_count.length);
+}
+// Reset Board
+//function reset_game() {
+// active_letters.length = 0;
+// display_letters();
+// $('.flex-item.box').removeClass('box-disabled');
+//}
+$(function () {
+ $('.flex-item.box').on('click', function (e) {
+ if ($(this).hasClass('box-disabled')) return;
+ //If the jquery wrapped object that this element
+ active_letters.push(this.innerHTML);
+ console.log(active_letters);
+ display_letters();
+ $(this).addClass('box-disabled');
+ }).each(function (i, item) {
+ var $this = $(item),
+ letter = randomLetters();
+ //this function handles the initial setup.
+ while (letters.indexOf(letter) != -1) {
+ letter = randomLetters();
}
-
- // The 16 boxes are in the list section.
- $('.aligner-item').click(function () {
-
- var idElement = document.getElementById(this.id);
-
- if (!idElement.disabled) {
- var content = idElement.innerHTML;
-
- idElement.style.backgroundColor = 'red';
-
- lettersHTML += content;
- $('#letters').html(lettersHTML);
-
- // Disable clicked button.
- idElement.disabled = true;
- }
-
- });
-
- // Clear the letter field.
- $('#clear').on('click', function () {
- resetBoxes();
- $('#letters').html('Selected Letters');
- lettersHTML = '';
- });
-
- // Submit the letter field and add to word list.
- $('#submit').on('click', function () {
- if (lettersHTML.length > 0) {
- if (!(lettersHTML in wordHash)) {
- // document.getElementById('chosen-words').innerHTML += lettersHTML + '
';
-
- // Check if word has at least three letters.
- // If so update word score and total score.
- var oneWordScore = 0;
- if (lettersHTML.length > 2) {
- oneWordScore = checkWord(lettersHTML);
- totalScore += oneWordScore;
- }
-
- document.getElementById('score-tally').innerHTML = totalScore;
-
- // Add key/value to word hash.
- wordHash[lettersHTML] = oneWordScore;
-
- // Convert hash to 2 arrays. One for keys and the other for values.
- var keys = Object.keys(wordHash);
- var values = keys.map(function (v) { return wordHash[v]; });
-
- // Clear words and scores before reversing them.
- document.getElementById('chosen-words').innerHTML = '';
- document.getElementById('word-score').innerHTML = '';
-
- // Reverse words and scores.
- for (var i = keys.length - 1; i >= 0; i--) {
- document.getElementById('chosen-words').innerHTML += keys[i] + '
';
- document.getElementById('word-score').innerHTML += values[i] + '
';
- }
-
- $('#letters').html('
');
- lettersHTML = '';
-
- // Reset the box colors.
- resetBoxes();
- }
- }
-
- // Clear the log html string. Always at the end!
- lettersHTML = '';
- });
-
- // Reset board.
- $('#reset').on('click', function () {
- $('#word-score').html('');
- $('#chosen-words').html('');
- $('#letters').html('Selected Letters');
- $('#score-tally').html('');
- lettersHTML = '';
- totalScore = 0;
- resetBoxes();
- randomLetters();
- wordHash = {};
- });
-
+ letters.push(letter);
+ $this.html(letter);
});
+});
-function checkWord(word) {
-
- var wordScore = 0;
- var wordCase;
-
- // The 1000 word dictionary is in lowere case except 'I'.
- // Cover this condition.
- if (word !== 'I') {
- wordCase = word.toLowerCase();
- } else {
- wordCase = word;
- }
-
- if (isBasicWord(wordCase)) {
- wordScore = 9 * (word.length);
- }
-
- return wordScore;
+for (var i = 0; i < $('.flex-item').length; i++) {
+ item = $('.flex-item')[i];
}
-function randomLetters() {
-
- var num;
- var char;
-
- for (var i = 1; i < 17; i++) {
- // Random letter ascii code between 65 and 90 (A-Z).
- // Max (excluded) = 91, Min (included) = 65.
- num = Math.floor(Math.random() * (91 - 65)) + 65;
+//clear and un disable the previously chosen letters
+$(function () {
+ $('.btn-danger').on('click', function () {
+ active_letters.length = 0;
+ display_letters();
+ console.log(active_letters);
+ $('.flex-item.box').removeClass('box-disabled');
+ });
+});
+
+
+//the submit button does a whole lot of stuff.
+//first it un disables all the disabled letter boxes
+$(function () {
+ $('.btn-primary').on('click', function (e) {
+ var word = active_letters.join('').toLowerCase();
+ console.log(word, isBasicWord(word));
+ var wordUp = word.toUpperCase();
+ var checkDouble = word_list.indexOf(wordUp)
+ $('.flex-item.box').removeClass('box-disabled');
+ // then it checks if there is a word submitted
+ if (word <= 0) {
+ active_letters.length = [];
+ display_letters();
+ //checks to see if the submitted word is listed already and if listed will receive no points
+ } else if (checkDouble >= 0) {
+ active_letters.length = [];
+ display_letters();
+ word_list.unshift(wordUp);
+ var score = 0;
+ var new_items = $('
Make words by clicking the letters!
-