Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix round info #37

Merged
merged 3 commits into from
Nov 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions dojo_toolkit/dojo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from threading import Thread

from six import moves
Expand Down Expand Up @@ -46,31 +47,34 @@ def stop(self):
self.is_running = False

def await_pilot_exchange(self):
print('Awaiting the pilot and co-pilot to enter their positions.')
print('Press <Enter> when they are ready')
moves.input()

def round_start(self):
self.timer.start()
self.sound_player.play_start()
self.round_started = True

print('Round started! {} minutes left...'.format(self.round_time))

def round_info(self):
if self.timer.ellapsed_time == 60:
self.notifier.notify('60 seconds...')
print('Round finished in 60 seconds')
if self.timer.ellapsed_time == self.timer.duration - 60:
self.notifier.notify('60 seconds to round finish...')
print('Round is going to finish in 60 seconds')
self.info_notified = True

def round_finished(self):
self.notifier.notify('Time Up', timeout=15 * 1000)
self.sound_player.play_timeup()
self.round_started = False
print('Round finished!\n')

def dojo(self):
while self.is_running:
print('Awaiting the pilot and co-pilot to enter their positions.')
print('Press <Enter> when they are ready')
self.await_pilot_exchange()
self.round_start()
print('Round started! {} minutes left...'.format(self.round_time))
while self.timer.is_running:
self.round_info()
time.sleep(0.8)
self.round_finished()
print('Round finished!')
1 change: 1 addition & 0 deletions tests/test_dojo.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_dojo_round_info_without_notification(mocked_dojo):


def test_dojo_round_info_with_notification(mocked_dojo):
mocked_dojo.timer.duration = 120
mocked_dojo.timer.ellapsed_time = 60
mocked_dojo.round_info()
assert mocked_dojo.notifier.notify.called
Expand Down