feat(Grid): flexible at() method arguments
- Support tuple argument: grid.at((x, y)) - Support keyword arguments: grid.at(x=5, y=3) - Support pos keyword: grid.at(pos=(2, 8)) - Maintain backward compatibility with grid.at(x, y) - Add comprehensive error handling for invalid arguments Improves API ergonomics and Python-like flexibility 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
cd0bd5468b
commit
5b6b0cc8ff
34 changed files with 1930 additions and 184 deletions
53
example_config.py
Normal file
53
example_config.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Example configuration script that sets up shared state for other scripts
|
||||
Usage: ./mcrogueface --exec example_config.py --exec example_automation.py game.py
|
||||
"""
|
||||
import mcrfpy
|
||||
|
||||
# Create a shared configuration namespace
|
||||
class AutomationConfig:
|
||||
# Test settings
|
||||
test_enabled = True
|
||||
screenshot_interval = 5 # Take screenshot every N tests
|
||||
max_test_count = 50
|
||||
test_delay_ms = 1000
|
||||
|
||||
# Monitoring settings
|
||||
monitor_enabled = True
|
||||
monitor_interval_ms = 500
|
||||
report_delay_seconds = 30
|
||||
|
||||
# Game-specific settings
|
||||
start_button_pos = (512, 400)
|
||||
inventory_key = "i"
|
||||
movement_keys = ["w", "a", "s", "d"]
|
||||
|
||||
# Shared state
|
||||
test_results = []
|
||||
performance_data = []
|
||||
|
||||
@classmethod
|
||||
def log_result(cls, test_name, success, details=""):
|
||||
"""Log a test result"""
|
||||
cls.test_results.append({
|
||||
"test": test_name,
|
||||
"success": success,
|
||||
"details": details,
|
||||
"frame": mcrfpy.getFrame()
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def get_summary(cls):
|
||||
"""Get test summary"""
|
||||
total = len(cls.test_results)
|
||||
passed = sum(1 for r in cls.test_results if r["success"])
|
||||
return f"Tests: {passed}/{total} passed"
|
||||
|
||||
# Attach config to mcrfpy module so other scripts can access it
|
||||
mcrfpy.automation_config = AutomationConfig
|
||||
|
||||
print("Config: Automation configuration loaded")
|
||||
print(f"Config: Test delay = {AutomationConfig.test_delay_ms}ms")
|
||||
print(f"Config: Max tests = {AutomationConfig.max_test_count}")
|
||||
print("Config: Other scripts can access config via mcrfpy.automation_config")
|
||||
Loading…
Add table
Add a link
Reference in a new issue