Browse Source

Don't use FileNotFoundError for other errors

master
Samuel Sloniker 3 years ago
parent
commit
de5850351b
  1. 8
      worm.py

8
worm.py

@ -21,6 +21,10 @@ class RanIntoSomethingError(QuitGameError):
pass pass
class IsFullScreen(BaseException):
pass
def draw_worm(): def draw_worm():
for location in worm_locations: for location in worm_locations:
print(do_move(*reversed(location)) + term.bright_blue('o'), end='') print(do_move(*reversed(location)) + term.bright_blue('o'), end='')
@ -189,12 +193,12 @@ x_offset = (term.width - width) // 2
info_1, info_2 = info.get_infos(term, do_move, height, width, x_offset) info_1, info_2 = info.get_infos(term, do_move, height, width, x_offset)
try: try:
if args.full_screen: if args.full_screen:
raise FileNotFoundError() #TODO: this is not pythonic raise IsFullScreen()
with open(gamesave_path) as f: with open(gamesave_path) as f:
save = json.load(f) save = json.load(f)
worm_locations, worm_head, last_dir, score, size, bonus_location, bonus_points, do_automove, do_help = save worm_locations, worm_head, last_dir, score, size, bonus_location, bonus_points, do_automove, do_help = save
except FileNotFoundError: except (FileNotFoundError, IsFullScreen):
size = 7 size = 7
worm_locations = [[i+10, worm_y] for i in range(size)] worm_locations = [[i+10, worm_y] for i in range(size)]
worm_head = [size+10, worm_y] worm_head = [size+10, worm_y]

Loading…
Cancel
Save