McRogueFace/tests/unit/test_pathfinding_integration.py
John McCardle 9f481a2e4a fix: Update test files to use current API patterns
Migrates test suite to current API:
- Frame(x, y, w, h) → Frame(pos=(x, y), size=(w, h))
- Caption("text", x, y) → Caption(pos=(x, y), text="text")
- caption.size → caption.font_size
- Entity(x, y, ...) → Entity((x, y), ...)
- Grid(w, h, ...) → Grid(grid_size=(w, h), ...)
- cell.color → ColorLayer system

Tests now serve as valid API usage examples.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 19:47:48 -05:00

58 lines
No EOL
1.5 KiB
Python

#!/usr/bin/env python3
"""Test pathfinding integration with demos"""
import mcrfpy
import sys
print("Testing pathfinding integration...")
print("=" * 50)
# Create scene and grid
mcrfpy.createScene("test")
grid = mcrfpy.Grid(grid_x=10, grid_y=10)
# Initialize grid
for y in range(10):
for x in range(10):
grid.at(x, y).walkable = True
# Add some walls
for i in range(5):
grid.at(5, i + 2).walkable = False
# Create entities
e1 = mcrfpy.Entity((2, 5), grid=grid)
e2 = mcrfpy.Entity((8, 5), grid=grid)
# Test pathfinding between entities
print(f"Entity 1 at ({e1.x}, {e1.y})")
print(f"Entity 2 at ({e2.x}, {e2.y})")
# Entity 1 finds path to Entity 2
path = e1.path_to(int(e2.x), int(e2.y))
print(f"\nPath from E1 to E2: {path}")
print(f"Path length: {len(path)} steps")
# Test movement simulation
if path and len(path) > 1:
print("\nSimulating movement along path:")
for i, (x, y) in enumerate(path[:5]): # Show first 5 steps
print(f" Step {i}: Move to ({x}, {y})")
# Test path in reverse
path_reverse = e2.path_to(int(e1.x), int(e1.y))
print(f"\nPath from E2 to E1: {path_reverse}")
print(f"Reverse path length: {len(path_reverse)} steps")
print("\n✓ Pathfinding integration working correctly!")
print("Enhanced demos are ready for interactive use.")
# Quick animation test
def test_timer(dt):
print(f"Timer callback received: dt={dt}ms")
sys.exit(0)
# Set a quick timer to test animation system
mcrfpy.setTimer("test", test_timer, 100)
print("\nTesting timer system for animations...")