mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Raise exception instead of returning magical number from 'arc anoid'
Summary: how do I python Test Plan: help Reviewers: alanh Reviewed By: alanh CC: aran Differential Revision: https://secure.phabricator.com/D3245
This commit is contained in:
parent
6b0af26b94
commit
c0c78c2ff4
1 changed files with 11 additions and 7 deletions
|
@ -128,6 +128,9 @@ class Ship:
|
||||||
win.addch(curses.ACS_RTEE)
|
win.addch(curses.ACS_RTEE)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
class PowerOverwhelmingException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
def main(stdscr):
|
def main(stdscr):
|
||||||
global height, width, ship
|
global height, width, ship
|
||||||
|
|
||||||
|
@ -139,7 +142,10 @@ def main(stdscr):
|
||||||
height, width = stdscr.getmaxyx()
|
height, width = stdscr.getmaxyx()
|
||||||
|
|
||||||
if height < 15 or width < 30:
|
if height < 15 or width < 30:
|
||||||
return 1
|
raise PowerOverwhelmingException(
|
||||||
|
"Your computer is not powerful enough to run 'arc anoid'. "
|
||||||
|
"It must support at least 30 columns and 15 rows of next-gen "
|
||||||
|
"full-color 3D graphics.")
|
||||||
|
|
||||||
status = curses.newwin(1, width, 0, 0)
|
status = curses.newwin(1, width, 0, 0)
|
||||||
height -= 1
|
height -= 1
|
||||||
|
@ -202,11 +208,9 @@ def main(stdscr):
|
||||||
status.refresh()
|
status.refresh()
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
|
||||||
res = curses.wrapper(main)
|
try:
|
||||||
if res == 1:
|
curses.wrapper(main)
|
||||||
print ("Your computer is not powerful enough to run 'arc anoid'. "
|
|
||||||
"It must support at least 30 columns and 15 rows of next-gen "
|
|
||||||
"full-color 3D graphics.")
|
|
||||||
else:
|
|
||||||
print ('You destroyed %s blocks out of %s with %s deaths.' %
|
print ('You destroyed %s blocks out of %s with %s deaths.' %
|
||||||
(Block.killed, Block.total, Ball.killed))
|
(Block.killed, Block.total, Ball.killed))
|
||||||
|
except PowerOverwhelmingException as e:
|
||||||
|
print e
|
||||||
|
|
Loading…
Reference in a new issue