From 246e604a070f7539838fd246c0405db2752da8d2 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 31 May 2021 23:04:17 -0700 Subject: [PATCH] Correct an issue when winning "arc anoid" with certain terminal dimensions Summary: See PHI2085. Python 3 is stricter about integers and floats than Python 2 was, and we can end up passing a float where an integer was expected if the player wins "arc anoid" using a terminal with certain (most?) character dimensions. Test Plan: - Modified "arcanoid.py" to win instantly. - Adjusted terminal window to 80x24, ran "arc anoid", reproduced crash. - Ran "python2 arcanoid.py" and observed old victory animation behavior. - Applied patch. - Ran "arc anoid" and observed identical victory animation behavior. Differential Revision: https://secure.phabricator.com/D21667 --- support/arcanoid/arcanoid.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/support/arcanoid/arcanoid.py b/support/arcanoid/arcanoid.py index 55d191a7..6d99d5e0 100755 --- a/support/arcanoid/arcanoid.py +++ b/support/arcanoid/arcanoid.py @@ -212,11 +212,16 @@ def main(stdscr): i = int(time.time() / 0.8) for x in range(width): for y in range(6): - game.addch(height / 2 + y - 3 + (x / 8 + i) % 2, x, - curses.ACS_BLOCK, - curses.A_BOLD | curses.color_pair(colors[y])) - game.addstr(height / 2, (width - len(message)) / 2, message, - curses.A_BOLD | curses.color_pair(7)) + game.addch( + int(height / 2 + y - 3 + (x / 8 + i) % 2), + x, + curses.ACS_BLOCK, + curses.A_BOLD | curses.color_pair(colors[y])) + game.addstr( + int(height / 2), + int((width - len(message)) / 2), + message, + curses.A_BOLD | curses.color_pair(7)) game.refresh() status.refresh()