-
Notifications
You must be signed in to change notification settings - Fork 1
Description
(Moved from pypewpew/pewpew-m4-v8#1)
The current menu (main.py) does not restart when a game exits by throwing pew.GameOver
(as Othello does), but drops you into the console with a traceback, leaving no way out except a power cycle.
This turns out to be nontrivial to fix when the goal is to keep the del sys.modules['pew']
, which seems a sensible thing to do to free up memory for non-pew
games. My first naive attempt to stow away GameOver
in a variable before deleting pew
does not work, because then the GameOver
we are trying to catch comes from a different instance of the pew
module than the one thrown. What I think would work is to define the exception class in another module that can stay loaded and then doing from othermodule import GameOver
in pew.py
. That other module could be ugame
or stage
, assuming that because pew
is implemented on top of them they need to stay loaded anyway. And maybe a GameOver exception would be a useful thing to have in ugame
/stage
games anyway?