Skip to content

Commit

Permalink
Move function within the method that uses it.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsitton committed Sep 17, 2015
1 parent 833e530 commit d8beb20
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions fofix/game/guitarscene/instruments/Guitar.py
Expand Up @@ -501,7 +501,32 @@ def controlsMatchNotes(self, controls, notes):

return True


def controlsMatchNotes3(self, controls, notes, hopo = False):


def matchNotes(chordTuple, requiredKeys):
print requiredKeys
if len(chordTuple) > 1: #Chords must match exactly
for n in range(self.strings):
if (n in requiredKeys and not (controls.getState(self.keys[n]) or controls.getState(self.keys[n+5]))) or (n not in requiredKeys and (controls.getState(self.keys[n]) or controls.getState(self.keys[n+5]))):
return False
else: #Single Note must match that note
requiredKey = requiredKeys[0]
if not controls.getState(self.keys[requiredKey]) and not controls.getState(self.keys[requiredKey+5]):
return False


#myfingershurt: this is where to filter out higher frets held when HOPOing:
if hopo == False or self.hopoStyle == 2 or self.hopoStyle == 3:
#Check for higher numbered frets if not a HOPO or if GH2 strict mode
for n, k in enumerate(self.keys):
if (n > requiredKey and n < 5) or (n > 4 and n > requiredKey + 5):
#higher numbered frets cannot be held
if controls.getState(k):
return False
return True

# no notes?
if not notes:
return False
Expand All @@ -523,23 +548,22 @@ def controlsMatchNotes3(self, controls, notes, hopo = False):
self.missedNotes = []
self.missedNoteNums = []
twochord = 0

for chord in chordlist:
# matching keys?
requiredKeys = [note.number for time, note in chord]
requiredKeys = self.uniqify(requiredKeys)
requiredKeys = self.uniqify([note.number for time, note in chord])

if len(requiredKeys) > 2 and self.twoChordMax == True:
twochord = 0
for n, k in enumerate(self.keys):
if controls.getState(k):
twochord += 1
if twochord == 2:
skipped = len(requiredKeys) - 2
requiredKeys = [min(requiredKeys), max(requiredKeys)]
else:
twochord = 0

if (self.controlsMatchNote3(controls, chord, requiredKeys, hopo)):
if (matchNotes(chord, requiredKeys)):
if twochord != 2:
for time, note in chord:
note.played = True
Expand Down Expand Up @@ -578,29 +602,6 @@ def uniqify(self, seq):
result.append(marker)
return result

def controlsMatchNote3(self, controls, chordTuple, requiredKeys, hopo):
if len(chordTuple) > 1:
#Chords must match exactly
for n in range(self.strings):
if (n in requiredKeys and not (controls.getState(self.keys[n]) or controls.getState(self.keys[n+5]))) or (n not in requiredKeys and (controls.getState(self.keys[n]) or controls.getState(self.keys[n+5]))):
return False
else:
#Single Note must match that note
requiredKey = requiredKeys[0]
if not controls.getState(self.keys[requiredKey]) and not controls.getState(self.keys[requiredKey+5]):
return False


#myfingershurt: this is where to filter out higher frets held when HOPOing:
if hopo == False or self.hopoStyle == 2 or self.hopoStyle == 3:
#Check for higher numbered frets if not a HOPO or if GH2 strict mode
for n, k in enumerate(self.keys):
if (n > requiredKey and n < 5) or (n > 4 and n > requiredKey + 5):
#higher numbered frets cannot be held
if controls.getState(k):
return False

return True

def startPick(self, song, pos, controls):
if not song:
Expand All @@ -623,6 +624,7 @@ def startPick(self, song, pos, controls):
return True
return False


def startPick3(self, song, pos, controls, hopo = False):
if not song:
return False
Expand Down

0 comments on commit d8beb20

Please sign in to comment.