-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new exercise: left hand random 2-3-4 fingers
Fixes #16
- Loading branch information
1 parent
291718f
commit 6dae144
Showing
7 changed files
with
111 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[MESSAGES CONTROL] | ||
disable=W0703, R0902, R0903, R1716, R0801, C0200, R0916 | ||
disable=W0703, R0902, R0903, R1716, R0801, C0200, R0916, R0914 |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" Module for human hand """ | ||
from typing import List | ||
from copy import copy | ||
from random import randint | ||
|
||
class Finger: | ||
""" Finger class """ | ||
def __init__(self, number: int, name: str): | ||
self.number = number | ||
self.name = name | ||
|
||
class Hand: | ||
""" Hand class """ | ||
def __init__(self): | ||
self.fingers = [ | ||
Finger(1, "Index"), | ||
Finger(2, "Middle"), | ||
Finger(3, "Ring"), | ||
Finger(4, "Pinky"), | ||
Finger(5, "Thumb") | ||
] | ||
|
||
def get_random_fret_fingers(self, quantity: int = 0) -> List[Finger]: | ||
""" Returns a random list of fretting fingers """ | ||
output = [] | ||
candidates = copy(self.fingers) | ||
candidates.pop(4) | ||
|
||
if quantity > 0: | ||
output_quantity = quantity | ||
else: | ||
output_quantity = randint(0, len(candidates)-1) | ||
|
||
while len(output) < output_quantity and len(candidates) > 0: | ||
random_index = randint(0, len(candidates)-1) | ||
random_finger = candidates.pop(random_index) | ||
output.append(random_finger) | ||
|
||
return output |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
""" Lazy fingers module | ||
This module contains exercises for left hand fingers 2, 3, 4 | ||
""" | ||
from random import randint | ||
from model import exercise, exercise_step | ||
from model.guitar import Guitar | ||
from practice.abstract_practice import AbstractPractice | ||
from body.hand import Hand | ||
|
||
|
||
class LazyFingers(AbstractPractice): | ||
""" Lazy fingers exercise class """ | ||
|
||
_TITLE = "Lazy fingers" | ||
_SUBTITLE = "Work your lazy fingers" | ||
_BASS_STRINGS = 4 | ||
_GUITAR_STRINGS = 6 | ||
|
||
def get_exercise(self, quantity: int, guitar: Guitar) -> exercise.Exercise: | ||
""" Returns lazy fingers exercises """ | ||
random_steps = [] | ||
|
||
if guitar == Guitar.KEYS: | ||
return None | ||
if guitar == Guitar.BASS: | ||
string_count = LazyFingers._BASS_STRINGS | ||
else: | ||
string_count = LazyFingers._GUITAR_STRINGS | ||
|
||
for quantity_pos in range(quantity): # pylint: disable=W0612 | ||
random_finger_count = randint(2, 4) | ||
random_fingers = Hand().get_random_fret_fingers(random_finger_count) | ||
strings = [] | ||
fingers = [] | ||
|
||
while len(random_fingers) > 0: | ||
random_finger_index = randint(0, len(random_fingers)-1) | ||
random_finger = random_fingers.pop(random_finger_index) | ||
fingers.append(random_finger) | ||
random_string = randint(1, string_count) | ||
strings.append(random_string) | ||
|
||
sorted(strings, key=lambda string: string) | ||
sorted(fingers, key=lambda finger: finger.number) | ||
|
||
pattern = "" | ||
for pattern_index in range(len(strings)): | ||
if pattern == "": | ||
pattern += " " | ||
pattern += "S" + str(strings[pattern_index]) | ||
pattern += " " + fingers[pattern_index].name | ||
|
||
random_step = exercise_step.ExerciseStep( | ||
"Follow the pattern", | ||
pattern | ||
) | ||
|
||
random_steps.append(random_step) | ||
|
||
output = exercise.Exercise(self._TITLE, self._SUBTITLE, random_steps) | ||
return output |
This file contains 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