Simplify the tests for a focused game cell

This commit is contained in:
Dave Pearson
2022-10-19 21:28:50 +01:00
parent 59fb6f1ec5
commit b3d8ebb2f4

View File

@@ -230,7 +230,7 @@ class Game(Screen):
def action_navigate(self, row: int, col: int) -> None: def action_navigate(self, row: int, col: int) -> None:
"""Navigate to a new cell by the given offsets.""" """Navigate to a new cell by the given offsets."""
if self.focused and isinstance(self.focused, GameCell): if isinstance(self.focused, GameCell):
self.set_focus( self.set_focus(
self.cell( self.cell(
(self.focused.row + row) % self.SIZE, (self.focused.row + row) % self.SIZE,
@@ -240,7 +240,7 @@ class Game(Screen):
def action_move(self) -> None: def action_move(self) -> None:
"""Make a move on the current cell.""" """Make a move on the current cell."""
if self.focused and isinstance(self.focused, GameCell): if isinstance(self.focused, GameCell):
self.focused.press() self.focused.press()
def on_mount(self) -> None: def on_mount(self) -> None: