1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-21 14:22:40 +01:00

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
This commit is contained in:
epriestley 2021-05-31 23:04:17 -07:00
parent be1a4a9142
commit 246e604a07

View file

@ -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()