Skip to content

Commit

Permalink
feature: move extra letters limit var to config
Browse files Browse the repository at this point in the history
  • Loading branch information
viliusddd committed Jun 5, 2024
1 parent a1ac402 commit 95d12c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export const specialKeys = [
'ArrowRight', '§', 'Tab',
]
export const timerTime = 60 // in seconds
export const extraLimit = 5 // the limit of incorrect letters at the end of word
3 changes: 2 additions & 1 deletion src/key.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {getBBox} from './utils.js'
import {extraLimit} from './config.js'

/**
* Checks if user input matches letters and goes back and forth the words.
Expand Down Expand Up @@ -161,7 +162,7 @@ export default class Key {
)

if (cursorX > (displayBBox.x + displayBBox.width)) return
if (this.activeWord.querySelectorAll('.extra').length === 5) return
if (this.activeWord.querySelectorAll('.extra').length === extraLimit) return

const div = document.createElement('div')
div.classList.add('letter', 'incorrect', 'extra')
Expand Down

0 comments on commit 95d12c3

Please sign in to comment.