refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
"""
|
|
|
|
|
Test TCOD Field of View with Two Entities
|
|
|
|
|
==========================================
|
|
|
|
|
|
|
|
|
|
Demonstrates:
|
|
|
|
|
1. Grid with obstacles (walls)
|
|
|
|
|
2. Two entities at different positions
|
|
|
|
|
3. Entity-specific FOV calculation
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
4. Color layer for FOV visualization (new API)
|
refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import mcrfpy
|
|
|
|
|
import sys
|
|
|
|
|
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
def run_tests():
|
|
|
|
|
"""Run FOV entity tests"""
|
|
|
|
|
print("=== TCOD FOV Entity Tests ===\n")
|
|
|
|
|
|
|
|
|
|
# Test 1: FOV enum availability
|
|
|
|
|
print("Test 1: FOV Enum")
|
|
|
|
|
try:
|
|
|
|
|
print(f" FOV.BASIC = {mcrfpy.FOV.BASIC}")
|
|
|
|
|
print(f" FOV.SHADOW = {mcrfpy.FOV.SHADOW}")
|
2026-02-09 08:15:18 -05:00
|
|
|
print("OK: FOV enum available\n")
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
except Exception as e:
|
2026-02-09 08:15:18 -05:00
|
|
|
print(f"FAIL: FOV enum not available: {e}")
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# Test 2: Create grid with walls
|
|
|
|
|
print("Test 2: Grid Creation with Walls")
|
|
|
|
|
grid = mcrfpy.Grid(pos=(0, 0), size=(640, 400), grid_size=(40, 25))
|
|
|
|
|
|
|
|
|
|
# Set up walls
|
|
|
|
|
for y in range(25):
|
|
|
|
|
for x in range(40):
|
|
|
|
|
point = grid.at(x, y)
|
|
|
|
|
# Border walls
|
|
|
|
|
if x == 0 or x == 39 or y == 0 or y == 24:
|
|
|
|
|
point.walkable = False
|
|
|
|
|
point.transparent = False
|
|
|
|
|
# Central wall
|
|
|
|
|
elif x == 20 and y != 12: # Wall with door at y=12
|
|
|
|
|
point.walkable = False
|
|
|
|
|
point.transparent = False
|
|
|
|
|
else:
|
|
|
|
|
point.walkable = True
|
|
|
|
|
point.transparent = True
|
|
|
|
|
|
2026-02-09 08:15:18 -05:00
|
|
|
print("OK: Grid with walls created\n")
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
|
|
|
|
|
# Test 3: Create entities
|
|
|
|
|
print("Test 3: Entity Creation")
|
|
|
|
|
player = mcrfpy.Entity((5, 12))
|
|
|
|
|
enemy = mcrfpy.Entity((35, 12))
|
refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
grid.entities.append(player)
|
|
|
|
|
grid.entities.append(enemy)
|
2026-02-09 08:15:18 -05:00
|
|
|
print(f" Player at grid ({player.grid_x}, {player.grid_y})")
|
|
|
|
|
print(f" Enemy at grid ({enemy.grid_x}, {enemy.grid_y})")
|
|
|
|
|
print("OK: Entities created\n")
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
|
|
|
|
|
# Test 4: FOV calculation for player
|
|
|
|
|
print("Test 4: Player FOV Calculation")
|
2026-02-09 08:15:18 -05:00
|
|
|
grid.compute_fov((player.grid_x, player.grid_y), radius=15, algorithm=mcrfpy.FOV.SHADOW)
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
|
|
|
|
|
# Player should see themselves
|
2026-02-09 08:15:18 -05:00
|
|
|
assert grid.is_in_fov(player.grid_x, player.grid_y), "Player should see themselves"
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
print(" Player can see their own position")
|
|
|
|
|
|
|
|
|
|
# Player should see nearby cells
|
|
|
|
|
assert grid.is_in_fov(6, 12), "Player should see adjacent cells"
|
|
|
|
|
print(" Player can see adjacent cells")
|
|
|
|
|
|
|
|
|
|
# Player should NOT see behind the wall (outside door line)
|
|
|
|
|
assert not grid.is_in_fov(21, 5), "Player should not see behind wall"
|
|
|
|
|
print(" Player cannot see behind wall at (21, 5)")
|
|
|
|
|
|
|
|
|
|
# Player should NOT see enemy (behind wall even with door)
|
2026-02-09 08:15:18 -05:00
|
|
|
assert not grid.is_in_fov(enemy.grid_x, enemy.grid_y), "Player should not see enemy"
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
print(" Player cannot see enemy")
|
|
|
|
|
|
2026-02-09 08:15:18 -05:00
|
|
|
print("OK: Player FOV working correctly\n")
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
|
|
|
|
|
# Test 5: FOV calculation for enemy
|
|
|
|
|
print("Test 5: Enemy FOV Calculation")
|
2026-02-09 08:15:18 -05:00
|
|
|
grid.compute_fov((enemy.grid_x, enemy.grid_y), radius=15, algorithm=mcrfpy.FOV.SHADOW)
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
|
|
|
|
|
# Enemy should see themselves
|
2026-02-09 08:15:18 -05:00
|
|
|
assert grid.is_in_fov(enemy.grid_x, enemy.grid_y), "Enemy should see themselves"
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
print(" Enemy can see their own position")
|
|
|
|
|
|
|
|
|
|
# Enemy should NOT see player (behind wall)
|
2026-02-09 08:15:18 -05:00
|
|
|
assert not grid.is_in_fov(player.grid_x, player.grid_y), "Enemy should not see player"
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
print(" Enemy cannot see player")
|
|
|
|
|
|
2026-02-09 08:15:18 -05:00
|
|
|
print("OK: Enemy FOV working correctly\n")
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
|
|
|
|
|
# Test 6: FOV with color layer
|
|
|
|
|
print("Test 6: FOV Color Layer Visualization")
|
2026-02-09 08:15:18 -05:00
|
|
|
fov_layer = mcrfpy.ColorLayer(z_index=-1, grid_size=(40, 25))
|
|
|
|
|
grid.add_layer(fov_layer)
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
fov_layer.fill((0, 0, 0, 255)) # Start with black (unknown)
|
|
|
|
|
|
|
|
|
|
# Draw player FOV
|
|
|
|
|
fov_layer.draw_fov(
|
2026-02-09 08:15:18 -05:00
|
|
|
source=(player.grid_x, player.grid_y),
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
radius=10,
|
|
|
|
|
fov=mcrfpy.FOV.SHADOW,
|
|
|
|
|
visible=(255, 255, 200, 64),
|
|
|
|
|
discovered=(100, 100, 100, 128),
|
|
|
|
|
unknown=(0, 0, 0, 255)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Check visible cell
|
2026-02-09 08:15:18 -05:00
|
|
|
visible_cell = fov_layer.at(player.grid_x, player.grid_y)
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
assert visible_cell.r == 255, "Player position should be visible"
|
|
|
|
|
print(" Player position has visible color")
|
|
|
|
|
|
|
|
|
|
# Check hidden cell (behind wall)
|
2026-02-09 08:15:18 -05:00
|
|
|
hidden_cell = fov_layer.at(enemy.grid_x, enemy.grid_y)
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
assert hidden_cell.r == 0, "Enemy position should be unknown"
|
|
|
|
|
print(" Enemy position has unknown color")
|
|
|
|
|
|
2026-02-09 08:15:18 -05:00
|
|
|
print("OK: FOV color layer working correctly\n")
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
|
|
|
|
|
print("=== All FOV Entity Tests Passed! ===")
|
|
|
|
|
return True
|
refactor: comprehensive test suite overhaul and demo system
Major changes:
- Reorganized tests/ into unit/, integration/, regression/, benchmarks/, demo/
- Deleted 73 failing/outdated tests, kept 126 passing tests (100% pass rate)
- Created demo system with 6 feature screens (Caption, Frame, Primitives, Grid, Animation, Color)
- Updated .gitignore to track tests/ directory
- Updated CLAUDE.md with comprehensive testing guidelines and API quick reference
Demo system features:
- Interactive menu navigation (press 1-6 for demos, ESC to return)
- Headless screenshot generation for CI
- Per-feature demonstration screens with code examples
Testing infrastructure:
- tests/run_tests.py - unified test runner with timeout support
- tests/demo/demo_main.py - interactive/headless demo runner
- All tests are headless-compliant
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 23:37:05 -05:00
|
|
|
|
|
|
|
|
# Main execution
|
feat: Implement FOV enum and layer draw_fov for #114 and #113
Phase 1 - FOV Enum System:
- Create PyFOV.h/cpp with mcrfpy.FOV IntEnum (BASIC, DIAMOND, SHADOW, etc.)
- Add mcrfpy.default_fov module property initialized to FOV.BASIC
- Add grid.fov and grid.fov_radius properties for per-grid defaults
- Remove deprecated module-level FOV_* constants (breaking change)
Phase 2 - Layer Operations:
- Implement ColorLayer.fill_rect(pos, size, color) for rectangle fills
- Implement TileLayer.fill_rect(pos, size, index) for tile rectangle fills
- Implement ColorLayer.draw_fov(source, radius, fov, visible, discovered, unknown)
to paint FOV-based visibility on color layers using parent grid's TCOD map
The FOV enum uses Python's IntEnum for type safety while maintaining
backward compatibility with integer values. Tests updated to use new API.
Addresses #114 (FOV enum), #113 (layer operations)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:18:10 -05:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
try:
|
|
|
|
|
if run_tests():
|
|
|
|
|
print("\nPASS")
|
|
|
|
|
sys.exit(0)
|
|
|
|
|
else:
|
|
|
|
|
print("\nFAIL")
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(f"\nFAIL: {e}")
|
|
|
|
|
import traceback
|
|
|
|
|
traceback.print_exc()
|
|
|
|
|
sys.exit(1)
|