feat: tests and bugfix for 'lower hand'

This commit is contained in:
efim
2023-11-11 08:03:39 +00:00
parent 89982d5c39
commit 517fda2512
5 changed files with 223 additions and 39 deletions

View File

@@ -66,7 +66,7 @@ gestureIteration:
startIndex := r.gestureSearchStartIndex(gesture, currentSpeakerGesture)
participantsCount := len(r.Paricipants)
for i := 1; i < participantsCount; i++ {
checkIndex := startIndex + i%participantsCount
checkIndex := (startIndex + i) % participantsCount
checkPerson := r.Paricipants[checkIndex]
checkGesture, isFound := r.ParticipantHands[checkPerson.Id]
if isFound && checkGesture == gesture {
@@ -111,19 +111,22 @@ func (r *Room) gestureSearchStartIndex(gesture, curSpeakerGesture HandGesture) i
return 0
}
var personFromWhichToStartSearch PersonId
var personFromWhichToStartSearch PersonId = r.CurrentSpeaker
// if searched guesture is higher or same as current speaker, start from speaker
if gesture >= curSpeakerGesture {
personFromWhichToStartSearch = r.CurrentSpeaker
}
// if searched gesture is of lower priority from current speaker, check marks to return to, or use speaker level
gestureMark, found := r.Marks[gesture]
if found {
personFromWhichToStartSearch = gestureMark
if gesture < curSpeakerGesture {
gestureMark, found := r.Marks[gesture]
if found {
personFromWhichToStartSearch = gestureMark
}
// if no mark found - count from the speaker
}
// if no mark found - count from the speaker
personFromWhichToStartSearch = r.CurrentSpeaker
log.Printf("> selecting person from which to start. cur speaker %s, for gestrue %s, got person %d",
curSpeakerGesture.String(), gesture.String(), personFromWhichToStartSearch)
indexFromWhichToStart := slices.IndexFunc(r.Paricipants, func(p Person) bool {
return p.Id == personFromWhichToStartSearch