Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Minor Overhaul and Refactor
This pull request adds quite a bit complexity to the code base but enables greater flexibility for adding additional game modes. As is, the boilerplate addresses some open and closed issues, and implements a robust state management system. In some regards, how game modes are built has become simpler and follows a straightforward pattern of usage that's reminiscent to the original branch, while adding many UI/UX enhancements.
That being said, some features have been dropped, making this a breaking revision. I do not intend to keep it that way and would like to reimplement those features with some help. Hopefully the lack of comments and increased complexity doesn't scare contributors away. I apologize in advance for that, which is why this description is so long winded. I will greatly appreciate any feedback, suggestions, and overall insight anyone can give.
Breaking Changes (Dropped Features)
I fully intend to bring back text-based results that can be copied to the clipboard. I'd like to do so in a way that's simply structured, intuitive, easily digestible, and accessible. The goal is to address the known issue of the emoji results.
Possible Solutions
I looked into ways to convert HTML into images that could be copied to clipboard or downloaded. For now, I only have two ideas that would keep this repo dependency free.
New Class Features
Warning
Due to browser CORS policies, module imports must be server via a development server. I recommend using an IDE that can serve pages on localhost.
Note
All the duplicated feature code was consolidated into 3 classes:
WordGen,Prompts, andKeyboard.WordGen
Behavior
The word list generator's behavior remains relatively unchanged. Most changes removed duplication by adding options to the main feature methods.
Constructor
Important
The
WordGenclass now accepts an optionalSeedparameter passed through the constructor. The currentDate.toLocalString()is used by default.WordGen( )WordGen( Seed: string )Properties
stringWordGen( ).seedstringWordGen( ).seedDateWordGen( ).dateDate.toLocalString()of todaynumberWordGen.EPOCMethods
Tip
difficultyparameter can be of type'easy','medium', or'hard'. Default is'medium'Caution
amountparameter can be any number. Default is 5Please be aware of out-of-range amounts. I'll address this in a future update.
string[]chooseWords( )'medium'words with a length of 5string[]chooseWords(difficulty: string)string[]chooseWords(difficulty: string, amount: number)string[]shuffle( )'medium'difficulty settingstring[]shuffle(difficulty: string)Keyboard
Behavior
Letter inputs and backspace are captured on
mousedownandkeydownevents, while submit or enter, is captured onmouseupandkeyupevents. All events captured callpreventDefault()to block expected browser behaviors. Input events from the keyboard are matched by ReGex, as before, to block any non-character inputs, with the exception of backspace and enter. Letter inputs insert the character to an output string, raising achangeevent. Backspace removes the last character of the output string, also raising achangeevent. Submit or enter raises ansubmitevent. (More information on events below).Constructor
Important
The
Keyboardclass accepts an emptyDOM Elementwhich it will populate.Keyboard ( keyboard: HTMLDivElement )Events
Note
Deleting all characters will return an empty string.
'change'on('change', callback(event))output: string'submit'on('submit', callback(event))output: stringMethods
Note
All onscreen keys exhibit a combination of states defined by the default CSS behavior or defined classes, DOM attributes, and styles pragmatically toggled. Different states are used to remedy user pain points and mitigate potential user error.
voidenableInput( )voidclear( )Prompts
Behavior
The new behavior of the Prompts class is fairly complex, but it uses the previous implementation's ideas as a base line. Most of the changes made ensure proper state management, enhanced UI/UX, and a better-defined data model for evaluation results.
I'll refrain from explaining all nuanced behaviors, but I will list some technical and functional highlights.
Constructor
Important
The
Promptsclass accepts an emptyDOM Elementwhich it will populate.Prompts( Prompts: HTMLDivElement )Events
'load'onLoad( callback(event))difficulty: string'ready'onReady(callback())void'select'on('select', callback(event))selectedPlayer: PromptButton, selectedWord: string'play'on('play', callback(event))activePlayer: PromptButton, activeWord: string'stopped'on('stopped', callback(event))stoppedPlayer: PromptButton, activeWord: string'ended'on('ended', callback(event))ctivePlayer: PromptButton, activeWord: string'evaluate'on('evaluate', callback(event))result : prompt result'complete'on('complete', callback(event))results: prompts resultsMethods
voidaddWords(level:string, ...words: string[] )levelshould be hanged todifficultyfor consistency and clarityvoidevaluatePrompt( submission: string )voidclear( )Other Changes
Changes to results page look
Changes to results data model
{ "Daily #52: EASY": [ { "word": "razz", "submission": "razz", "isCorrect": true }, { "word": "forever", "submission": "forever", "isCorrect": true }, { "word": "imagined", "submission": "imagined", "isCorrect": true }, { "word": "behold", "submission": "behold", "isCorrect": true }, { "word": "frankly", "submission": "frankly", "isCorrect": true } ], "Daily #52: MEDIUM": [ { "word": "relentlessly", "submission": "relentlessly", "isCorrect": true }, { "word": "wattage", "submission": "wattage", "isCorrect": true }, { "word": "anabolic", "submission": "anabolic", "isCorrect": true }, { "word": "elicitation", "submission": "illicitation", "isCorrect": false }, { "word": "severely", "submission": "serverely", "isCorrect": false } ], "Daily #52: HARD": [ { "word": "massacres", "submission": "masecres", "isCorrect": false }, { "word": "dexterity", "submission": "dexterity", "isCorrect": true }, { "word": "heirloom", "submission": "aerloom", "isCorrect": false }, { "word": "verisimilitude", "submission": "ver", "isCorrect": false }, { "word": "scallion", "submission": "scallion", "isCorrect": true } ] }Project structure modifications
Folder Changes
/levelOneNew,/levelTwoNew, and/levelThreeNewto/easy,/medium, and/hard, respectively./corefolder in/assets/scripts/dictionaryfolder in/assets/scripts/coreFile Structure Changes
/scripts/core/dictionaryeasy.js- Exports const array of all easy wordsmedium.js- Exports const array of all medium wordshard.js- Exports const array of all hard wordskeyboard.js- ExportsKeyboardclassprompts.js- ExportsPromptsclassutils.js- Exportscyrb128andsfc32const functionsword-gen.js- ExportsWordGenclassword-list.js- Re-exports word const arraysdaily_challange.jspractice.jsresults.jsspelloff.jsyoutube.js