Spaces:
Running
Running
| import os | |
| import sys | |
| # Ensure we can import engine | |
| sys.path.append(os.getcwd()) | |
| import engine_rust | |
| def test_dir(): | |
| # Load DB | |
| db_path = "engine/data/cards_compiled.json" | |
| with open(db_path, "r", encoding="utf-8") as f: | |
| cards_data_raw = f.read() | |
| db = engine_rust.PyCardDatabase(cards_data_raw) | |
| state = engine_rust.PyGameState(db) | |
| p0 = state.get_player(0) | |
| print("--- PyGameState Attributes ---") | |
| print(dir(state)) | |
| print("\n--- PyPlayerState Attributes ---") | |
| print(dir(p0)) | |
| # Try setting current_player | |
| try: | |
| state.current_player = 1 | |
| print("Set state.current_player = 1 success") | |
| except Exception as e: | |
| print(f"Set state.current_player = 1 failed: {e}") | |
| try: | |
| p0.stage = [249, -1, -1] | |
| print("Set p0.stage success") | |
| except Exception as e: | |
| print(f"Set p0.stage failed: {e}") | |
| if __name__ == "__main__": | |
| test_dir() | |