From e9241dcb90b8db4e5b947c0fc704f9c80f4f8777 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 2 Feb 2019 05:18:42 -0800 Subject: [PATCH] [Wilds] Make "arc anoid" system requirements more accurate Summary: Fixes T8693. Ref T13098. On a 30x15 terminal, the we can only fit "Score: X/12 * Deaths: Y" on the top line if both `X` and `Y` are less than 10, so they can render with a single character. As soon as the player breaks more than 9 blocks or dies more than 9 times, we need an extra character to render the score. This causes an off-screen write to curses and crashes. Raise the minimum requirement to 32 columns so we can render "12/12" and up to "99" deaths. Then, change the display logic to show "99" if you die more than 99 times. (At this resolution we always generate a board with 12 blocks, even if the terminal is very very tall, so we don't need to deal with a case where the "Score" might read "101/200".) Test Plan: - Beat the game on a 32x15 terminal. - Changed logic to award me 1000 deaths per actual death. - Died on a 32x15 terminal. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13098, T8693 Differential Revision: https://secure.phabricator.com/D20085 --- scripts/breakout.py | 18 ++++++++++----- src/workflow/ArcanistAnoidWorkflow.php | 31 +++++++++++++------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/scripts/breakout.py b/scripts/breakout.py index c8c8b188..0b473b84 100755 --- a/scripts/breakout.py +++ b/scripts/breakout.py @@ -141,11 +141,11 @@ def main(stdscr): height, width = stdscr.getmaxyx() - if height < 15 or width < 30: + if height < 15 or width < 32: 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.") + 'Your computer is not powerful enough to run "arc anoid". ' + 'It must support at least 32 columns and 15 rows of next-gen ' + 'full-color 3D graphics.') status = curses.newwin(1, width, 0, 0) height -= 1 @@ -194,7 +194,15 @@ def main(stdscr): status.addstr('%s/%s ' % (Block.killed, Block.total), curses.A_BOLD) status.addch(curses.ACS_VLINE) status.addstr(' DEATHS: ', curses.A_BOLD | curses.color_pair(4)) - status.addstr('%s ' % Ball.killed, curses.A_BOLD) + + # See T8693. At the minimum display size, we only have room to render + # two characters for the death count, so just display "99" if the + # player has more than 99 deaths. + display_deaths = Ball.killed + if (display_deaths > 99): + display_deaths = 99 + + status.addstr('%s ' % display_deaths, curses.A_BOLD) status.addch(curses.ACS_LTEE) if Block.killed == Block.total: diff --git a/src/workflow/ArcanistAnoidWorkflow.php b/src/workflow/ArcanistAnoidWorkflow.php index 9dbad9d1..c573915b 100644 --- a/src/workflow/ArcanistAnoidWorkflow.php +++ b/src/workflow/ArcanistAnoidWorkflow.php @@ -1,29 +1,30 @@ newWorkflowInformation() + ->setHelp($help); } - public function getCommandHelp() { - return phutil_console_format(<<