mirror of
https://github.com/ghndrx/shellmate.git
synced 2026-02-10 14:55:08 +00:00
Simplify chess board rendering - plain text that works over SSH
- Remove complex Rich styling from board (caused rendering issues) - Use simple ASCII box drawing (+---+) instead of Unicode box chars - Use dots for dark squares, spaces for light - Plain text status display - Much more reliable over SSH terminals
This commit is contained in:
@@ -92,36 +92,34 @@ def test_game_status_render():
|
||||
def test_chess_board_render():
|
||||
"""Test that chess board renders without errors."""
|
||||
output = StringIO()
|
||||
console = Console(file=output, width=80, height=24, force_terminal=True, color_system="truecolor")
|
||||
|
||||
PIECES = {
|
||||
'K': '♔', 'Q': '♕', 'R': '♖', 'B': '♗', 'N': '♘', 'P': '♙',
|
||||
'k': '♚', 'q': '♛', 'r': '♜', 'b': '♝', 'n': '♞', 'p': '♟',
|
||||
}
|
||||
|
||||
# Render a simple board section
|
||||
console.print(" a b c d e f g h")
|
||||
console.print(" ┌───┬───┬───┬───┬───┬───┬───┬───┐")
|
||||
|
||||
# Render one rank with colored squares
|
||||
row = "8 │"
|
||||
for file in range(8):
|
||||
is_light = (7 + file) % 2 == 1
|
||||
if is_light:
|
||||
bg = "on #769656"
|
||||
else:
|
||||
bg = "on #4a7c3f"
|
||||
|
||||
# Starting position pieces
|
||||
pieces_row = ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'r']
|
||||
char = PIECES.get(pieces_row[file], ' ')
|
||||
row += f"[#1a1a1a bold {bg}] {char} [/]│"
|
||||
# Simplified board rendering (plain text)
|
||||
lines = []
|
||||
lines.append(" a b c d e f g h")
|
||||
lines.append(" +---+---+---+---+---+---+---+---+")
|
||||
|
||||
# Render rank 8 with pieces
|
||||
pieces_row = ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'r']
|
||||
row = " 8 |"
|
||||
for file, piece_char in enumerate(pieces_row):
|
||||
char = PIECES.get(piece_char, '?')
|
||||
row += f" {char} |"
|
||||
row += " 8"
|
||||
console.print(row)
|
||||
lines.append(row)
|
||||
lines.append(" +---+---+---+---+---+---+---+---+")
|
||||
|
||||
for line in lines:
|
||||
output.write(line + "\n")
|
||||
|
||||
rendered = output.getvalue()
|
||||
assert "a b c" in rendered
|
||||
assert "♜" in rendered # Black rook
|
||||
assert "+---+" in rendered
|
||||
|
||||
|
||||
def test_narrow_terminal_render():
|
||||
|
||||
Reference in New Issue
Block a user