fix: having mark and same raised gesture

previously didn't check everyone, and person with mark and gesture is
last in the circle
This commit is contained in:
efim
2023-11-22 05:03:14 +00:00
parent 017cf465da
commit 077537a1e3
2 changed files with 62 additions and 19 deletions

View File

@@ -129,7 +129,7 @@ func (r *Room) PersonToStandUpFromTable(p PersonId) {
// - if the gesture is of lover priority and there is a mark for the gesture level
// should be counted from the mark
func (r *Room) NextSpeakerIndex() (nextSpeakerIndex int, found bool, countedFromIndex int) {
// if a current speaker - after removing the hand, we need to find next speaker
// if a current speaker - before removing the hand, we need to find next speaker
// from highest hand gesture to lowest, until one is found
currentSpeakerGesture, currentSpeakerFound := r.ParticipantHands[r.CurrentSpeaker]
@@ -143,9 +143,14 @@ gestureIteration:
log.Printf("searching for gesture %s", gesture.String())
startIndex := r.gestureSearchStartIndex(gesture, currentSpeakerGesture)
participantsCount := len(r.Paricipants)
for i := 1; i < participantsCount; i++ {
inGestureParticipantIteration:
for i := 1; i <= participantsCount; i++ {
checkIndex := (startIndex + i) % participantsCount
checkPerson := r.Paricipants[checkIndex]
if checkPerson == r.CurrentSpeaker {
// current speaker still has thair gesture up
continue inGestureParticipantIteration
}
checkGesture, isFound := r.ParticipantHands[checkPerson]
if isFound && checkGesture == gesture {
nextSpeakerIndex = slices.Index(r.Paricipants, checkPerson)
@@ -188,8 +193,8 @@ func (r *Room) gestureSearchStartIndex(gesture, curSpeakerGesture HandGesture) i
}
// if no mark found - count from the speaker
}
log.Printf("> selecting person from which to start. cur speaker %s, for gestrue %s, got person %d",
curSpeakerGesture.String(), gesture.String(), personFromWhichToStartSearch)
log.Printf("> selecting person from which to start. cur speaker %d with gesture %s, for gestrue %s, got person %d",
r.CurrentSpeaker, curSpeakerGesture.String(), gesture.String(), personFromWhichToStartSearch)
indexFromWhichToStart := slices.Index(r.Paricipants, personFromWhichToStartSearch)
return indexFromWhichToStart