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>
This commit is contained in:
John McCardle 2025-12-29 19:47:48 -05:00
commit 9f481a2e4a
53 changed files with 614 additions and 586 deletions

View file

@ -7,24 +7,24 @@ import sys
def test_grid_none_texture(runtime):
"""Test Grid functionality without texture"""
print("\n=== Testing Grid with None texture ===")
# Test 1: Create Grid with None texture
try:
grid = mcrfpy.Grid(10, 10, None, mcrfpy.Vector(50, 50), mcrfpy.Vector(400, 400))
grid = mcrfpy.Grid(grid_size=(10, 10), pos=(50, 50), size=(400, 400))
print("✓ Grid created successfully with None texture")
except Exception as e:
print(f"✗ Failed to create Grid with None texture: {e}")
sys.exit(1)
# Add to UI
ui = mcrfpy.sceneUI("grid_none_test")
ui.append(grid)
# Test 2: Verify grid properties
try:
grid_size = grid.grid_size
print(f"✓ Grid size: {grid_size}")
# Check texture property
texture = grid.texture
if texture is None:
@ -33,39 +33,41 @@ def test_grid_none_texture(runtime):
print(f"✗ Grid texture should be None, got: {texture}")
except Exception as e:
print(f"✗ Property access failed: {e}")
# Test 3: Access grid points and set colors
# Test 3: Access grid points using ColorLayer (new API)
# Note: GridPoint no longer has .color - must use ColorLayer system
try:
# Add a color layer to the grid
color_layer = grid.add_layer("color", z_index=-1)
# Create a checkerboard pattern with colors
for x in range(10):
for y in range(10):
point = grid.at(x, y)
if (x + y) % 2 == 0:
point.color = mcrfpy.Color(255, 0, 0, 255) # Red
color_layer.set(x, y, mcrfpy.Color(255, 0, 0, 255)) # Red
else:
point.color = mcrfpy.Color(0, 0, 255, 255) # Blue
print("✓ Successfully set grid point colors")
color_layer.set(x, y, mcrfpy.Color(0, 0, 255, 255)) # Blue
print("✓ Successfully set grid colors via ColorLayer")
except Exception as e:
print(f"✗ Failed to set grid colors: {e}")
# Test 4: Add entities to the grid
try:
# Create an entity with its own texture
entity_texture = mcrfpy.Texture("assets/kenney_tinydungeon.png", 16, 16)
entity = mcrfpy.Entity(mcrfpy.Vector(5, 5), entity_texture, 1, grid)
entity = mcrfpy.Entity((5, 5), texture=entity_texture, sprite_index=1, grid=grid)
grid.entities.append(entity)
print(f"✓ Added entity to grid, total entities: {len(grid.entities)}")
except Exception as e:
print(f"✗ Failed to add entity: {e}")
# Test 5: Test grid interaction properties
try:
# Test zoom
grid.zoom = 2.0
print(f"✓ Set zoom to: {grid.zoom}")
# Test center
grid.center = mcrfpy.Vector(5, 5)
# Test center (uses pixel coordinates)
grid.center = (200, 200)
print(f"✓ Set center to: {grid.center}")
except Exception as e:
print(f"✗ Grid properties failed: {e}")
@ -86,7 +88,7 @@ mcrfpy.setScene("grid_none_test")
# Add a background frame so we can see the grid
ui = mcrfpy.sceneUI("grid_none_test")
background = mcrfpy.Frame(0, 0, 800, 600,
background = mcrfpy.Frame(pos=(0, 0), size=(800, 600),
fill_color=mcrfpy.Color(200, 200, 200),
outline_color=mcrfpy.Color(0, 0, 0),
outline=2.0)