From 8b187ec2b39f8f3723f2ec979981bdf55d86869d Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 26 Nov 2020 12:35:52 +0100 Subject: [PATCH 1/8] Use custom function to render a string message onto a pad --- squirrelbattle/display/display.py | 16 ++++++++++------ squirrelbattle/display/logsdisplay.py | 4 ++-- squirrelbattle/display/mapdisplay.py | 8 ++++---- squirrelbattle/display/menudisplay.py | 10 +++++----- squirrelbattle/display/statsdisplay.py | 12 ++++++------ 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/squirrelbattle/display/display.py b/squirrelbattle/display/display.py index 0cdba98..ecfb2ec 100644 --- a/squirrelbattle/display/display.py +++ b/squirrelbattle/display/display.py @@ -19,6 +19,9 @@ class Display: def newpad(self, height: int, width: int) -> Union[FakePad, Any]: return curses.newpad(height, width) if self.screen else FakePad() + def addstr(self, pad: Any, y: int, x: int, msg: str, *options) -> None: + return pad.addstr(y, x, msg, *options) + def init_pair(self, number: int, foreground: int, background: int) -> None: return curses.init_pair(number, foreground, background) \ if self.screen else None @@ -68,7 +71,7 @@ class VerticalSplit(Display): def display(self) -> None: for i in range(self.height): - self.pad.addstr(i, 0, "┃") + self.addstr(self.pad, i, 0, "┃") self.pad.refresh(0, 0, self.y, self.x, self.y + self.height - 1, self.x) @@ -88,7 +91,7 @@ class HorizontalSplit(Display): def display(self) -> None: for i in range(self.width): - self.pad.addstr(0, i, "━") + self.addstr(self.pad, 0, i, "━") self.pad.refresh(0, 0, self.y, self.x, self.y, self.x + self.width - 1) @@ -99,10 +102,11 @@ class Box(Display): self.pad = self.newpad(self.rows, self.cols) def display(self) -> None: - self.pad.addstr(0, 0, "┏" + "━" * (self.width - 2) + "┓") + self.addstr(self.pad, 0, 0, "┏" + "━" * (self.width - 2) + "┓") for i in range(1, self.height - 1): - self.pad.addstr(i, 0, "┃") - self.pad.addstr(i, self.width - 1, "┃") - self.pad.addstr(self.height - 1, 0, "┗" + "━" * (self.width - 2) + "┛") + self.addstr(self.pad, i, 0, "┃") + self.addstr(self.pad, i, self.width - 1, "┃") + self.addstr(self.pad, self.height - 1, 0, + "┗" + "━" * (self.width - 2) + "┛") self.pad.refresh(0, 0, self.y, self.x, self.y + self.height - 1, self.x + self.width - 1) diff --git a/squirrelbattle/display/logsdisplay.py b/squirrelbattle/display/logsdisplay.py index 368c036..304cf7b 100644 --- a/squirrelbattle/display/logsdisplay.py +++ b/squirrelbattle/display/logsdisplay.py @@ -17,7 +17,7 @@ class LogsDisplay(Display): messages = messages[::-1] self.pad.clear() for i in range(min(self.height, len(messages))): - self.pad.addstr(self.height - i - 1, self.x, - messages[i][:self.width]) + self.addstr(self.pad, self.height - i - 1, self.x, + messages[i][:self.width]) self.pad.refresh(0, 0, self.y, self.x, self.y + self.height - 1, self.x + self.width - 1) diff --git a/squirrelbattle/display/mapdisplay.py b/squirrelbattle/display/mapdisplay.py index e6cc278..571c527 100644 --- a/squirrelbattle/display/mapdisplay.py +++ b/squirrelbattle/display/mapdisplay.py @@ -15,11 +15,11 @@ class MapDisplay(Display): def update_pad(self) -> None: self.init_pair(1, self.pack.tile_fg_color, self.pack.tile_bg_color) self.init_pair(2, self.pack.entity_fg_color, self.pack.entity_bg_color) - self.pad.addstr(0, 0, self.map.draw_string(self.pack), - self.color_pair(1)) + self.addstr(self.pad, 0, 0, self.map.draw_string(self.pack), + self.color_pair(1)) for e in self.map.entities: - self.pad.addstr(e.y, self.pack.tile_width * e.x, - self.pack[e.name.upper()], self.color_pair(2)) + self.addstr(self.pad, e.y, self.pack.tile_width * e.x, + self.pack[e.name.upper()], self.color_pair(2)) def display(self) -> None: y, x = self.map.currenty, self.pack.tile_width * self.map.currentx diff --git a/squirrelbattle/display/menudisplay.py b/squirrelbattle/display/menudisplay.py index 3c4e5a1..8d03017 100644 --- a/squirrelbattle/display/menudisplay.py +++ b/squirrelbattle/display/menudisplay.py @@ -20,13 +20,13 @@ class MenuDisplay(Display): # Menu values are printed in pad self.pad = self.newpad(self.trueheight, self.truewidth + 2) for i in range(self.trueheight): - self.pad.addstr(i, 0, " " + self.values[i]) + self.addstr(self.pad, i, 0, " " + self.values[i]) def update_pad(self) -> None: for i in range(self.trueheight): - self.pad.addstr(i, 0, " " + self.values[i]) + self.addstr(self.pad, i, 0, " " + self.values[i]) # set a marker on the selected line - self.pad.addstr(self.menu.position, 0, ">") + self.addstr(self.pad, self.menu.position, 0, ">") def display(self) -> None: cornery = 0 if self.height - 2 >= self.menu.position - 1 \ @@ -79,8 +79,8 @@ class MainMenuDisplay(Display): def display(self) -> None: for i in range(len(self.title)): - self.pad.addstr(4 + i, max(self.width // 2 - - len(self.title[0]) // 2 - 1, 0), self.title[i]) + self.addstr(self.pad, 4 + i, max(self.width // 2 + - len(self.title[0]) // 2 - 1, 0), self.title[i]) self.pad.refresh(0, 0, self.y, self.x, self.height + self.y - 1, self.width + self.x - 1) menuwidth = min(self.menudisplay.preferred_width, self.width) diff --git a/squirrelbattle/display/statsdisplay.py b/squirrelbattle/display/statsdisplay.py index f47862e..bd20ede 100644 --- a/squirrelbattle/display/statsdisplay.py +++ b/squirrelbattle/display/statsdisplay.py @@ -21,21 +21,21 @@ class StatsDisplay(Display): .format(self.player.level, self.player.current_xp, self.player.max_xp, self.player.health, self.player.maxhealth) - self.pad.addstr(0, 0, string2) + self.addstr(self.pad, 0, 0, string2) string3 = "STR {}\nINT {}\nCHR {}\nDEX {}\nCON {}"\ .format(self.player.strength, self.player.intelligence, self.player.charisma, self.player.dexterity, self.player.constitution) - self.pad.addstr(3, 0, string3) + self.addstr(self.pad, 3, 0, string3) inventory_str = "Inventaire : " + "".join( self.pack[item.name.upper()] for item in self.player.inventory) - self.pad.addstr(8, 0, inventory_str) + self.addstr(self.pad, 8, 0, inventory_str) if self.player.dead: - self.pad.addstr(10, 0, "VOUS ÊTES MORT", - curses.A_BOLD | curses.A_BLINK | curses.A_STANDOUT - | self.color_pair(3)) + self.addstr(self.pad, 10, 0, "VOUS ÊTES MORT", + curses.A_BOLD | curses.A_BLINK | curses.A_STANDOUT + | self.color_pair(3)) def display(self) -> None: self.pad.clear() From f2318ed30863ae88fe85e8abcfd21ec7f782be74 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 26 Nov 2020 20:04:54 +0100 Subject: [PATCH 2/8] Truncate messages if they are too large --- squirrelbattle/display/display.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/squirrelbattle/display/display.py b/squirrelbattle/display/display.py index ecfb2ec..0a06c65 100644 --- a/squirrelbattle/display/display.py +++ b/squirrelbattle/display/display.py @@ -19,8 +19,21 @@ class Display: def newpad(self, height: int, width: int) -> Union[FakePad, Any]: return curses.newpad(height, width) if self.screen else FakePad() + def truncate(self, msg: str, height: int, width: int) -> str: + lines = msg.split("\n") + lines = lines[:height] + lines = [line[:width] for line in lines] + return "\n".join(lines) + def addstr(self, pad: Any, y: int, x: int, msg: str, *options) -> None: - return pad.addstr(y, x, msg, *options) + """ + Display a message onto the pad. + If the message is too large, it is truncated vertically and horizontally + """ + height, width = pad.getmaxyx() + msg = self.truncate(msg, height - y, width - x) + if msg.replace("\n", ""): + return pad.addstr(y, x, msg, *options) def init_pair(self, number: int, foreground: int, background: int) -> None: return curses.init_pair(number, foreground, background) \ From ca03caf3bacaa80cfa22c97bc61525e9c752bab1 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 26 Nov 2020 20:35:10 +0100 Subject: [PATCH 3/8] Don't render message on negative indexes --- squirrelbattle/display/display.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/squirrelbattle/display/display.py b/squirrelbattle/display/display.py index 0a06c65..d5e3078 100644 --- a/squirrelbattle/display/display.py +++ b/squirrelbattle/display/display.py @@ -20,6 +20,8 @@ class Display: return curses.newpad(height, width) if self.screen else FakePad() def truncate(self, msg: str, height: int, width: int) -> str: + height = max(0, height) + width = max(0, width) lines = msg.split("\n") lines = lines[:height] lines = [line[:width] for line in lines] @@ -31,8 +33,8 @@ class Display: If the message is too large, it is truncated vertically and horizontally """ height, width = pad.getmaxyx() - msg = self.truncate(msg, height - y, width - x) - if msg.replace("\n", ""): + msg = self.truncate(msg, height - y, width - x - 1) + if msg.replace("\n", "") and x >= 0 and y >= 0: return pad.addstr(y, x, msg, *options) def init_pair(self, number: int, foreground: int, background: int) -> None: From f2f34bfbc66486a6efda6763dace7b8ace3d88a5 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 26 Nov 2020 20:58:46 +0100 Subject: [PATCH 4/8] Don't refresh pads with invalid coordinates. The window should be fully resizable, closes #20 --- squirrelbattle/display/display.py | 33 ++++++++++++++++++++++---- squirrelbattle/display/logsdisplay.py | 4 ++-- squirrelbattle/display/mapdisplay.py | 3 ++- squirrelbattle/display/menudisplay.py | 5 ++-- squirrelbattle/display/statsdisplay.py | 2 +- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/squirrelbattle/display/display.py b/squirrelbattle/display/display.py index d5e3078..1d70159 100644 --- a/squirrelbattle/display/display.py +++ b/squirrelbattle/display/display.py @@ -50,7 +50,8 @@ class Display: self.y = y self.width = width self.height = height - if hasattr(self, "pad") and resize_pad: + if hasattr(self, "pad") and resize_pad and \ + self.height >= 0 and self.width >= 0: self.pad.resize(self.height + 1, self.width + 1) def refresh(self, *args, resize_pad: bool = True) -> None: @@ -58,6 +59,26 @@ class Display: self.resize(*args, resize_pad) self.display() + def refresh_pad(self, pad: Any, top_y: int, top_x: int, + window_y: int, window_x: int, + last_y: int, last_x: int) -> None: + """ + Refresh a pad on a part of the window. + The refresh starts at coordinates (top_y, top_x) from the pad, + and is drawn from (window_y, window_x) to (last_y, last_x). + If coordinates are invalid (negative indexes/length..., then nothing + is drawn and no error is raised. + """ + top_y, top_x = max(0, top_y), max(0, top_x) + window_y, window_x = max(0, window_y), max(0, window_x) + screen_max_y, screen_max_x = self.screen.getmaxyx() + last_y, last_x = min(screen_max_y - 1, last_y), \ + min(screen_max_x - 1, last_x) + + if last_y >= window_y and last_x >= window_x: + # Refresh the pad only if coordinates are valid + pad.refresh(top_y, top_x, window_y, window_x, last_y, last_x) + def display(self) -> None: raise NotImplementedError @@ -87,7 +108,8 @@ class VerticalSplit(Display): def display(self) -> None: for i in range(self.height): self.addstr(self.pad, i, 0, "┃") - self.pad.refresh(0, 0, self.y, self.x, self.y + self.height - 1, self.x) + self.refresh_pad(self.pad, 0, 0, self.y, self.x, + self.y + self.height - 1, self.x) class HorizontalSplit(Display): @@ -107,7 +129,8 @@ class HorizontalSplit(Display): def display(self) -> None: for i in range(self.width): self.addstr(self.pad, 0, i, "━") - self.pad.refresh(0, 0, self.y, self.x, self.y, self.x + self.width - 1) + self.refresh_pad(self.pad, 0, 0, self.y, self.x, self.y, + self.x + self.width - 1) class Box(Display): @@ -123,5 +146,5 @@ class Box(Display): self.addstr(self.pad, i, self.width - 1, "┃") self.addstr(self.pad, self.height - 1, 0, "┗" + "━" * (self.width - 2) + "┛") - self.pad.refresh(0, 0, self.y, self.x, self.y + self.height - 1, - self.x + self.width - 1) + self.refresh_pad(self.pad, 0, 0, self.y, self.x, + self.y + self.height - 1, self.x + self.width - 1) diff --git a/squirrelbattle/display/logsdisplay.py b/squirrelbattle/display/logsdisplay.py index 304cf7b..d332b69 100644 --- a/squirrelbattle/display/logsdisplay.py +++ b/squirrelbattle/display/logsdisplay.py @@ -19,5 +19,5 @@ class LogsDisplay(Display): for i in range(min(self.height, len(messages))): self.addstr(self.pad, self.height - i - 1, self.x, messages[i][:self.width]) - self.pad.refresh(0, 0, self.y, self.x, self.y + self.height - 1, - self.x + self.width - 1) + self.refresh_pad(self.pad, 0, 0, self.y, self.x, + self.y + self.height - 1, self.x + self.width - 1) diff --git a/squirrelbattle/display/mapdisplay.py b/squirrelbattle/display/mapdisplay.py index 571c527..ce134a5 100644 --- a/squirrelbattle/display/mapdisplay.py +++ b/squirrelbattle/display/mapdisplay.py @@ -36,4 +36,5 @@ class MapDisplay(Display): pmincol = max(0, min(self.pack.tile_width * self.map.width, pmincol)) self.pad.clear() self.update_pad() - self.pad.refresh(pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol) + self.refresh_pad(self.pad, pminrow, pmincol, sminrow, smincol, smaxrow, + smaxcol) diff --git a/squirrelbattle/display/menudisplay.py b/squirrelbattle/display/menudisplay.py index 8d03017..2338e0d 100644 --- a/squirrelbattle/display/menudisplay.py +++ b/squirrelbattle/display/menudisplay.py @@ -37,7 +37,7 @@ class MenuDisplay(Display): self.menubox.refresh(self.y, self.x, self.height, self.width) self.pad.clear() self.update_pad() - self.pad.refresh(cornery, 0, self.y + 1, self.x + 2, + self.refresh_pad(self.pad, cornery, 0, self.y + 1, self.x + 2, self.height - 2 + self.y, self.width - 2 + self.x) @@ -81,7 +81,8 @@ class MainMenuDisplay(Display): for i in range(len(self.title)): self.addstr(self.pad, 4 + i, max(self.width // 2 - len(self.title[0]) // 2 - 1, 0), self.title[i]) - self.pad.refresh(0, 0, self.y, self.x, self.height + self.y - 1, + self.refresh_pad(self.pad, 0, 0, self.y, self.x, + self.height + self.y - 1, self.width + self.x - 1) menuwidth = min(self.menudisplay.preferred_width, self.width) menuy, menux = len(self.title) + 8, self.width // 2 - menuwidth // 2 - 1 diff --git a/squirrelbattle/display/statsdisplay.py b/squirrelbattle/display/statsdisplay.py index bd20ede..988d99c 100644 --- a/squirrelbattle/display/statsdisplay.py +++ b/squirrelbattle/display/statsdisplay.py @@ -40,5 +40,5 @@ class StatsDisplay(Display): def display(self) -> None: self.pad.clear() self.update_pad() - self.pad.refresh(0, 0, self.y, self.x, + self.refresh_pad(self.pad, 0, 0, self.y, self.x, self.y + self.height - 1, self.width + self.x - 1) From 3e7dabc94e8e9beb61e2e5b16d215e3e51a95387 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 26 Nov 2020 21:59:48 +0100 Subject: [PATCH 5/8] Wrap perfectly the map on the screen, bricks won't teleport randomly anymore --- squirrelbattle/display/display_manager.py | 5 ++++- squirrelbattle/display/mapdisplay.py | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/squirrelbattle/display/display_manager.py b/squirrelbattle/display/display_manager.py index d50dfa1..2c7baf1 100644 --- a/squirrelbattle/display/display_manager.py +++ b/squirrelbattle/display/display_manager.py @@ -48,7 +48,10 @@ class DisplayManager: if self.game.state == GameMode.PLAY: # The map pad has already the good size self.mapdisplay.refresh(0, 0, self.rows * 4 // 5, - self.cols * 4 // 5, resize_pad=False) + self.mapdisplay.pack.tile_width + * (self.cols * 4 // 5 + // self.mapdisplay.pack.tile_width), + resize_pad=False) self.statsdisplay.refresh(0, self.cols * 4 // 5 + 1, self.rows, self.cols // 5 - 1) self.logsdisplay.refresh(self.rows * 4 // 5 + 1, 0, diff --git a/squirrelbattle/display/mapdisplay.py b/squirrelbattle/display/mapdisplay.py index ce134a5..ae4caa3 100644 --- a/squirrelbattle/display/mapdisplay.py +++ b/squirrelbattle/display/mapdisplay.py @@ -31,9 +31,17 @@ class MapDisplay(Display): smaxrow = min(smaxrow, self.height - 1) smaxcol = self.pack.tile_width * self.map.width - \ (x + deltax) + self.width - 1 + + # Wrap perfectly the map according to the width of the tiles + pmincol = self.pack.tile_width * (pmincol // self.pack.tile_width) + smincol = self.pack.tile_width * (smincol // self.pack.tile_width) + smaxcol = self.pack.tile_width \ + * (smaxcol // self.pack.tile_width + 1) - 1 + smaxcol = min(smaxcol, self.width - 1) pminrow = max(0, min(self.map.height, pminrow)) pmincol = max(0, min(self.pack.tile_width * self.map.width, pmincol)) + self.pad.clear() self.update_pad() self.refresh_pad(self.pad, pminrow, pmincol, sminrow, smincol, smaxrow, From 1e48bd16b37a64613394ad934d47ae6ad9e256ce Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 26 Nov 2020 22:20:14 +0100 Subject: [PATCH 6/8] Erase pads instead of clearing them, fixes #21 --- squirrelbattle/display/logsdisplay.py | 2 +- squirrelbattle/display/mapdisplay.py | 2 +- squirrelbattle/display/menudisplay.py | 2 +- squirrelbattle/display/statsdisplay.py | 2 +- squirrelbattle/game.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/squirrelbattle/display/logsdisplay.py b/squirrelbattle/display/logsdisplay.py index d332b69..43a18dc 100644 --- a/squirrelbattle/display/logsdisplay.py +++ b/squirrelbattle/display/logsdisplay.py @@ -15,7 +15,7 @@ class LogsDisplay(Display): print(type(self.logs.messages), flush=True) messages = self.logs.messages[-self.height:] messages = messages[::-1] - self.pad.clear() + self.pad.erase() for i in range(min(self.height, len(messages))): self.addstr(self.pad, self.height - i - 1, self.x, messages[i][:self.width]) diff --git a/squirrelbattle/display/mapdisplay.py b/squirrelbattle/display/mapdisplay.py index ae4caa3..9599a54 100644 --- a/squirrelbattle/display/mapdisplay.py +++ b/squirrelbattle/display/mapdisplay.py @@ -42,7 +42,7 @@ class MapDisplay(Display): pminrow = max(0, min(self.map.height, pminrow)) pmincol = max(0, min(self.pack.tile_width * self.map.width, pmincol)) - self.pad.clear() + self.pad.erase() self.update_pad() self.refresh_pad(self.pad, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol) diff --git a/squirrelbattle/display/menudisplay.py b/squirrelbattle/display/menudisplay.py index 2338e0d..b04ac37 100644 --- a/squirrelbattle/display/menudisplay.py +++ b/squirrelbattle/display/menudisplay.py @@ -35,7 +35,7 @@ class MenuDisplay(Display): # Menu box self.menubox.refresh(self.y, self.x, self.height, self.width) - self.pad.clear() + self.pad.erase() self.update_pad() self.refresh_pad(self.pad, cornery, 0, self.y + 1, self.x + 2, self.height - 2 + self.y, diff --git a/squirrelbattle/display/statsdisplay.py b/squirrelbattle/display/statsdisplay.py index 988d99c..d33f55c 100644 --- a/squirrelbattle/display/statsdisplay.py +++ b/squirrelbattle/display/statsdisplay.py @@ -38,7 +38,7 @@ class StatsDisplay(Display): | self.color_pair(3)) def display(self) -> None: - self.pad.clear() + self.pad.erase() self.update_pad() self.refresh_pad(self.pad, 0, 0, self.y, self.x, self.y + self.height - 1, self.width + self.x - 1) diff --git a/squirrelbattle/game.py b/squirrelbattle/game.py index 0bb3024..dce1165 100644 --- a/squirrelbattle/game.py +++ b/squirrelbattle/game.py @@ -55,7 +55,7 @@ class Game: when the given key gets pressed. """ while True: # pragma no cover - screen.clear() + screen.erase() screen.refresh() self.display_actions(DisplayActions.REFRESH) key = screen.getkey() From 0726a8db9e756aa44908d580d6fd6611b4c2ad4d Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 26 Nov 2020 22:29:10 +0100 Subject: [PATCH 7/8] A print instruction remains. It was rendered on the screen. Awkward... --- squirrelbattle/display/logsdisplay.py | 1 - 1 file changed, 1 deletion(-) diff --git a/squirrelbattle/display/logsdisplay.py b/squirrelbattle/display/logsdisplay.py index 43a18dc..7bed61e 100644 --- a/squirrelbattle/display/logsdisplay.py +++ b/squirrelbattle/display/logsdisplay.py @@ -12,7 +12,6 @@ class LogsDisplay(Display): self.logs = logs def display(self) -> None: - print(type(self.logs.messages), flush=True) messages = self.logs.messages[-self.height:] messages = messages[::-1] self.pad.erase() From 2690eb8760a570fea44ee3c03f95b4d5010903bb Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 26 Nov 2020 22:32:25 +0100 Subject: [PATCH 8/8] Update FakePad to fix tests --- squirrelbattle/display/display.py | 3 ++- squirrelbattle/tests/screen.py | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/squirrelbattle/display/display.py b/squirrelbattle/display/display.py index 1d70159..bd16344 100644 --- a/squirrelbattle/display/display.py +++ b/squirrelbattle/display/display.py @@ -71,7 +71,8 @@ class Display: """ top_y, top_x = max(0, top_y), max(0, top_x) window_y, window_x = max(0, window_y), max(0, window_x) - screen_max_y, screen_max_x = self.screen.getmaxyx() + screen_max_y, screen_max_x = self.screen.getmaxyx() if self.screen \ + else 42, 42 last_y, last_x = min(screen_max_y - 1, last_y), \ min(screen_max_x - 1, last_x) diff --git a/squirrelbattle/tests/screen.py b/squirrelbattle/tests/screen.py index 6eb2cd0..a6b3c9a 100644 --- a/squirrelbattle/tests/screen.py +++ b/squirrelbattle/tests/screen.py @@ -1,3 +1,6 @@ +from typing import Tuple + + class FakePad: """ In order to run tests, we simulate a fake curses pad that accepts functions @@ -10,8 +13,11 @@ class FakePad: smincol: int, smaxrow: int, smaxcol: int) -> None: pass - def clear(self) -> None: + def erase(self) -> None: pass def resize(self, height: int, width: int) -> None: pass + + def getmaxyx(self) -> Tuple[int, int]: + return 42, 42