File tree Expand file tree Collapse file tree 3 files changed +15
-8
lines changed Expand file tree Collapse file tree 3 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ function expandChord(beatPosition: BeatPosition) {
192192 } else {
193193 const chordData = { chord: getChord (beatPosition ), ... beatPosition }
194194 targetedChordId .value = ` ${chordData .measure }-${chordData .beat } `
195- console . log ( targetedChordId . value )
195+
196196 expandedChords .value .push (chordData )
197197
198198 let direction: ' previous' | ' next' = ' next'
Original file line number Diff line number Diff line change 11import Chord from '@/models/chord'
22
33const chords : { [ key : string ] : Chord } = {
4+ // [string, fret, finger]
45 F : new Chord ( 'F' , [
56 [ 1 , 1 , 1 ] ,
67 [ 2 , 3 , 4 ] ,
Original file line number Diff line number Diff line change @@ -14,12 +14,20 @@ export default class Chord {
1414 this . generateGrip ( )
1515 }
1616
17- private sameStringOrFingerIsUsedTwice = ( ) => {
17+ private warnIfSameStringOrFingerIsUsedTwice = ( ) => {
1818 const strings = this . fingerPositions ?. map ( p => p [ 0 ] )
19- const fingers = this . fingerPositions ?. map ( p => p [ 2 ] )
20- const isUniqueSet = ( arr = [ ] ) => new Set ( arr ) . size == arr . length
2119
22- return ( ! isUniqueSet ( strings ) || ! isUniqueSet ( fingers ) )
20+ if ( new Set ( strings ) . size !== strings . length ) {
21+ console . warn ( `Same string is used twice in ${ this . label } ` )
22+ }
23+
24+ if ( this . fingerPositions . some ( ( p1 ) => ! ! this . fingerPositions . find ( ( p2 ) => {
25+ const [ fret , finger ] = [ 1 , 2 ]
26+
27+ return p1 [ finger ] == p2 [ finger ] && p1 [ fret ] !== p2 [ fret ]
28+ } ) ) ) {
29+ console . warn ( `Same finger is used on different frets in ${ this . label } ` )
30+ }
2331 }
2432
2533 private generateFingerData = ( string ) => {
@@ -38,9 +46,7 @@ export default class Chord {
3846 }
3947
4048 private generateGrip = ( ) => {
41- if ( this . sameStringOrFingerIsUsedTwice ( ) ) {
42- console . warn ( `Same finger or string is used twice in ${ this . label } ` )
43- }
49+ this . warnIfSameStringOrFingerIsUsedTwice ( )
4450
4551 this . grip = Object . assign ( { } , ...this . availableStrings . map ( this . generateFingerData ) )
4652 }
You can’t perform that action at this time.
0 commit comments