Renderers module
Module with classes and methods to handle UI Provide the classes handle human players.
This module allows the handle CLI arguments and options.
The module contains the following classes:
- ConsoleRenderer(Renderer)
- A class to handler render UI in the console.
The module contains the following functions:
- clear_screen() -> None:
- Clear console, like command reset on modern Linux systems.
- blink(text: str) -> str:
- Modify information to be print to console and
add slow blinking
- print_blinking(cells: Iterable[str], positions: Iterable[int]) -> None:
- Add blinking ANSI code to positions in cells.
- print_solid(cells: Iterable[str]) -> None:
- Render game UI. It uses textwrap and
format to replace on the correct position..
ConsoleRenderer
Bases: Renderer
A class to handler render UI in the console. Extend abstract class Renderar for the creation of visual and state rendering
Methods:
Name | Description |
---|---|
render |
GameState) -> None: Renders a new UI depending on game state. |
Source code in src\frontend\console\renderers.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
placeholder2()
This is a placeholder
Source code in src\frontend\console\renderers.py
49 50 51 |
|
render(game_state)
Renders a new UI depending on game state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
game_state |
GameState
|
current GameState, consisting of a current Grid (9 elemets that that can be X, O or spaces) and a starting Mark (default X). |
required |
Source code in src\frontend\console\renderers.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
blink(text)
Modify information to be print to console and add slow blinking [5m slow blink and [0m reset.
Source code in src\frontend\console\renderers.py
57 58 59 60 61 |
|
clear_screen()
Clear console, like command reset on modern Linux systems.
Source code in src\frontend\console\renderers.py
52 53 54 55 |
|
print_blinking(cells, positions)
Add blinking ANSI code to positions in cells.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cells |
Iterable[str]
|
Lits of all cells |
required |
positions |
Iterable[int]
|
List of positions |
required |
Source code in src\frontend\console\renderers.py
63 64 65 66 67 68 69 70 71 72 73 |
|
print_solid(cells)
Render game UI. It uses textwrap and format to replace on the correct position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cells |
Iterable[str]
|
description |
required |
Source code in src\frontend\console\renderers.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|