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

Make That's All more intuitive #181

Merged
merged 3 commits into from
Apr 23, 2021
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
2 changes: 2 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## User-facing changes

- Make the behaviour of `That's All` more intuitive (i.e. calling `That's All` during rounds will
no longer cause Wheatley to ring one erroneous row of method).
- Start ringing at a custom row (using `--start-row <row>`). This doesn't work for CompLib
compositions.
- Ring arbitrary place notation on a given stage (using
Expand Down
Empty file modified run-checks.py
100644 → 100755
Empty file.
24 changes: 16 additions & 8 deletions wheatley/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self, tower: RingingRoomTower, row_generator: RowGenerator, do_up_d
self._tower.invoke_on_stop_touch.append(self._on_stop_touch)

self._is_ringing = False
self._is_ringing_rounds = True
self._is_ringing_rounds = False
self._is_ringing_opening_row = True
# This is used as a counter - once `Go` or `Look To` is received, the number of rounds left
# is calculated and then decremented at the start of every subsequent row until it reaches
Expand All @@ -79,7 +79,7 @@ def __init__(self, tower: RingingRoomTower, row_generator: RowGenerator, do_up_d
# value `None` is used to represent the case where we don't know when we will be starting
# the method (and therefore there it makes no sense to decrement this counter).
self._rounds_left_before_method: Optional[int] = None
self._should_start_ringing_rounds = False
self._rows_left_before_rounds: Optional[int] = None
self._should_stand = False

self._row_number = 0
Expand Down Expand Up @@ -206,7 +206,7 @@ def look_to_has_been_called(self, call_time: float) -> None:

# Clear all the flags and counters
self._should_stand = False
self._should_start_ringing_rounds = False
self._rows_left_before_rounds = None
# Set _rounds_left_before_method if we are ringing up-down-in (3 rounds for backstroke
# start; 2 for handstroke)
if not self._do_up_down_in:
Expand Down Expand Up @@ -259,7 +259,8 @@ def _on_single(self) -> None:

def _on_thats_all(self) -> None:
""" Callback called when a user calls 'That`s All'. """
self._should_start_ringing_rounds = True
# We set this to one, because we expect one clear row between the call and rounds
self._rows_left_before_rounds = 1

def _on_stand_next(self) -> None:
""" Callback called when a user calls 'Stand Next'. """
Expand Down Expand Up @@ -352,10 +353,17 @@ def start_next_row(self, is_first_row: bool) -> None:
if self._should_stand:
self._should_stand = False
self._is_ringing = False
# ... and "That's All" has been called, then start ringing rounds.
if self._should_start_ringing_rounds and not self._is_ringing_rounds:
self._should_start_ringing_rounds = False
self._is_ringing_rounds = True

# There are two cases for coming round:
# 1. Someone calls 'That's All' and rounds appears
# (or)
# 2. Someone calls 'That's All', one clear row has elapsed
if self._rows_left_before_rounds == 0 \
or (has_just_rung_rounds and self._rows_left_before_rounds is not None):
self._rows_left_before_rounds = None
self._is_ringing_rounds = True
if self._rows_left_before_rounds is not None:
self._rows_left_before_rounds -= 1

# If we've set `_is_ringing` to False, then no more rounds can happen so early return to
# avoid erroneous calls
Expand Down