#!/usr/bin/env python3
"""
Simple test for Entity property setters
"""

def test_entity_setters(timer_name):
    """Test Entity property setters"""
    import mcrfpy
    import sys
    
    print("Testing Entity property setters...")
    
    # Create test scene and grid
    mcrfpy.createScene("test")
    ui = mcrfpy.sceneUI("test")
    
    # Create grid with texture
    texture = mcrfpy.Texture("assets/kenney_ice.png", 16, 16)
    grid = mcrfpy.Grid(10, 10, texture, (10, 10), (400, 400))
    ui.append(grid)
    
    # Create entity
    entity = mcrfpy.Entity((2.5, 3.5), texture, 5, grid)
    grid.entities.append(entity)
    
    # Test 1: Initial position
    print(f"Initial position: {entity.pos}")
    print(f"Initial position x={entity.pos.x}, y={entity.pos.y}")
    
    # Test 2: Set position with Vector
    entity.pos = mcrfpy.Vector(4.0, 5.0)
    print(f"After Vector setter: pos={entity.pos}, x={entity.pos.x}, y={entity.pos.y}")
    
    # Test 3: Set position with tuple
    entity.pos = (7.5, 8.5)
    print(f"After tuple setter: pos={entity.pos}, x={entity.pos.x}, y={entity.pos.y}")
    
    # Test 4: sprite_number
    print(f"Initial sprite_number: {entity.sprite_number}")
    entity.sprite_number = 10
    print(f"After setter: sprite_number={entity.sprite_number}")
    
    # Test 5: Invalid types
    try:
        entity.pos = "invalid"
        print("ERROR: Should have raised TypeError")
    except TypeError as e:
        print(f"✓ Correctly rejected invalid position: {e}")
    
    try:
        entity.sprite_number = "invalid"
        print("ERROR: Should have raised TypeError")
    except TypeError as e:
        print(f"✓ Correctly rejected invalid sprite_number: {e}")
    
    print("\n✅ Entity property setters test completed")
    sys.exit(0)

# Execute the test after a short delay
import mcrfpy
mcrfpy.setTimer("test", test_entity_setters, 100)