1000x1000 tile world generated deterministically from a seed using layered Perlin noise. Terrain derived from elevation: mountains, forests, grasslands, sand, water, with rivers traced downhill from peaks. ANSI-colored viewport centered on player. Command system with registry/dispatch, 8-direction movement (n/s/e/w + diagonals), look/l, quit/q. Players see arrival/departure messages. Set connect_maxwait=0.5 on telnetlib3 to avoid the 4s CHARSET negotiation timeout — MUD clients reject CHARSET immediately via MTTS.
47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
from mudlib.render.ansi import RESET, colorize_map, colorize_terrain
|
|
|
|
|
|
def test_colorize_terrain_grass():
|
|
"""Grass is colored green."""
|
|
result = colorize_terrain(".")
|
|
assert "\033[" in result # has ANSI code
|
|
assert "." in result
|
|
assert RESET in result
|
|
|
|
|
|
def test_colorize_terrain_mountain():
|
|
"""Mountain is colored."""
|
|
result = colorize_terrain("^")
|
|
assert "\033[" in result
|
|
assert "^" in result
|
|
assert RESET in result
|
|
|
|
|
|
def test_colorize_terrain_water():
|
|
"""Water is colored blue."""
|
|
result = colorize_terrain("~")
|
|
assert "\033[" in result
|
|
assert "~" in result
|
|
assert RESET in result
|
|
|
|
|
|
def test_colorize_terrain_unknown():
|
|
"""Unknown characters pass through unchanged."""
|
|
result = colorize_terrain("?")
|
|
assert result == "?"
|
|
|
|
|
|
def test_colorize_map():
|
|
"""colorize_map returns newline-separated colored rows."""
|
|
grid = [
|
|
[".", ".", "T"],
|
|
["~", "^", "."],
|
|
]
|
|
result = colorize_map(grid)
|
|
|
|
assert "\n" in result
|
|
lines = result.split("\n")
|
|
assert len(lines) == 2
|
|
|
|
# should have ANSI codes
|
|
assert "\033[" in result
|