diff --git a/rooms/room.go b/rooms/room.go index c25c7d1..4982973 100644 --- a/rooms/room.go +++ b/rooms/room.go @@ -53,6 +53,7 @@ func (r *Room) RaiseHand(p PersonId, gesture HandGesture) Room { // - we should find next speaker // - assign room.CurrentSpeaker to next speaker or to PersonId(0) to indicate that noone is speaking // - if next speaker has gesture of higher priority - set Mark to current speaker for their gesture level +// when there is not next speaker, remove all marks func (r *Room) ReleaseHand(p PersonId) { // releasing a hand of a current speaker should result in selection of a new speaker log.Printf("about to release hand of %d in %+v", p, r) @@ -76,6 +77,7 @@ func (r *Room) ReleaseHand(p PersonId) { if !nextSpeakerFound { log.Printf("there is not next speaker, that's ok") r.CurrentSpeaker = PersonId(0) + r.Marks = make(map[HandGesture]PersonId) } else { // searching for the next speaker currentSpeakerGesture := handReleaseGesture diff --git a/rooms/room_release_hand_test.go b/rooms/room_release_hand_test.go index 07fd8f0..1c130f4 100644 --- a/rooms/room_release_hand_test.go +++ b/rooms/room_release_hand_test.go @@ -20,6 +20,7 @@ var releaseHandTests = []releaseHandTest{ releasingNonSpeakerHand, releaseToPersonWithHandAndMark, raisingLevelSetMarksWithoutOverridingExisting, + releaseAllMarksWhenNoSpeaker, } func TestRoomReleaseHand(t *testing.T) { @@ -314,3 +315,40 @@ var releaseToPersonWithHandAndMark releaseHandTest = releaseHandTest{ Marks: map[HandGesture]PersonId{}, }, } + +// there is a mark for Expand on person 2, mark for Change Topic on person 3 +// speaker is person 1 with Expand +// after hand release person nobody should be speaking, with all marks removed +var releaseAllMarksWhenNoSpeaker releaseHandTest = releaseHandTest{ + testName: "releaseAllMarksWhenNoSpeaker", + room: Room{ + Name: "test", + CurrentSpeaker: person1.Id, + Paricipants: []PersonId{ + person1.Id, + person2.Id, + person3.Id, + person4.Id, + }, + ParticipantHands: map[PersonId]HandGesture{ + person1.Id: Expand, + }, + Marks: map[HandGesture]PersonId{ + Expand: person2.Id, + ChangeTopic: person3.Id, + }, + }, + releasingParticipantId: person1.Id, + expected: Room{ + Name: "test", + CurrentSpeaker: PersonId(0), + Paricipants: []PersonId{ + person1.Id, + person2.Id, + person3.Id, + person4.Id, + }, + ParticipantHands: map[PersonId]HandGesture{}, + Marks: map[HandGesture]PersonId{}, + }, +}