- 为铁球、陶瓷球和木球制作风格化材质,归档 CC0 原始参考 - 更新方形球洞和实心滑槽,统一 90° 弯槽并兼容旧存档 - 用顺流泡沫表示水流方向,为冰块制作三种交错的裂纹 - 同步 Blender 源资产、Godot 加载、工坊和试玩预览
159 lines
10 KiB
Python
159 lines
10 KiB
Python
"""Launch IntoHole scenes and run their Godot playtests."""
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
import subprocess
|
|
|
|
from baseline import executable
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
GAME = ROOT / 'godot_engine'
|
|
OUTPUT = ROOT / 'playtest/artifacts/styled'
|
|
|
|
|
|
def run(command: list, log_name: str, live: bool = False, log_dir: Path | None = None) -> None:
|
|
output = log_dir or OUTPUT
|
|
output.mkdir(parents=True, exist_ok=True)
|
|
if live:
|
|
subprocess.run(list(map(str, command)), cwd=ROOT, check=True)
|
|
return
|
|
path = output / (log_name + '.log')
|
|
with path.open('w') as stream:
|
|
result = subprocess.run(list(map(str, command)), cwd=ROOT, stdout=stream,
|
|
stderr=subprocess.STDOUT, timeout=180)
|
|
log = path.read_text(errors='replace')
|
|
if result.returncode or 'SCRIPT ERROR:' in log or 'ERROR:' in log:
|
|
print(log[-12000:])
|
|
raise SystemExit(result.returncode or 1)
|
|
print(f'{log_name}: {path}')
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('command', nargs='?', default='showcase',
|
|
choices=['showcase', 'workshop', 'materials', 'environment', 'test-environment', 'capture-environment', 'tutorial', 'water', 'ice', 'test-elements', 'build', 'test', 'test-balls', 'test-tutorial', 'test-player-controls', 'test-turn-merge', 'test-floating', 'test-alignment', 'capture-tutorial', 'capture'])
|
|
parser.add_argument('--lesson', type=int, choices=range(1, 6), default=1,
|
|
help='Start a particular tutorial lesson for authoring/playtest.')
|
|
args = parser.parse_args()
|
|
godot = executable('godot')
|
|
output = ROOT / 'playtest/artifacts/tutorial' if args.command in ('tutorial', 'test-tutorial', 'test-player-controls', 'test-turn-merge', 'test-floating', 'capture-tutorial') else ROOT / 'playtest/artifacts/environment' if args.command in ('environment', 'test-environment', 'capture-environment') else OUTPUT
|
|
if args.command in ('water', 'ice', 'test-elements'):
|
|
output = ROOT / 'playtest/artifacts/element_puzzles'
|
|
common = [godot, '--path', GAME, '--log-file', output / 'engine.log']
|
|
output.mkdir(parents=True, exist_ok=True)
|
|
scenes = {'workshop': 'res://designer/scenes/workshop.tscn',
|
|
'showcase': 'res://playtest/showcase/scenes/showcase.tscn',
|
|
'materials': 'res://playtest/materials/scenes/materials.tscn',
|
|
'environment': 'res://playtest/environment/scenes/environment.tscn',
|
|
'tutorial': 'res://playtest/tutorial/scenes/tutorial.tscn'}
|
|
if args.command in ('water', 'ice'):
|
|
scenes[args.command] = f'res://playtest/{args.command}/scenes/{args.lesson:02d}.tscn'
|
|
if args.command == 'build':
|
|
run([executable('blender'), '--background', '--factory-startup',
|
|
'--python-exit-code', '1', '--python', ROOT / 'assets/collections/storybook/source/build.py'], 'build')
|
|
# Import only this project's resource changes; never rebuild baseline assets.
|
|
run(common + ['--headless', '--import'], 'import', log_dir=output)
|
|
if args.command == 'build':
|
|
return
|
|
if args.command in ('test-environment', 'capture-environment'):
|
|
check_path = 'res://playtest/checks/validate_environment.gd' if args.command == 'test-environment' else 'res://playtest/captures/capture_environment.gd'
|
|
mode = ['--headless'] if args.command == 'test-environment' else []
|
|
run(common + mode + ['--fixed-fps', '120', '--script', check_path], args.command, log_dir=output)
|
|
if args.command == 'test-environment':
|
|
report = json.loads((output / 'report.json').read_text())
|
|
print(f"Environment checks: {report['passed']}; failed: {report['failed']}")
|
|
if report['failed']:
|
|
raise SystemExit(1)
|
|
elif args.command in ('test-turn-merge', 'test-floating'):
|
|
check_name = 'turn_merge' if args.command == 'test-turn-merge' else 'floating'
|
|
run(common + ['--headless', '--fixed-fps', '120', '--script',
|
|
f'res://playtest/checks/validate_{check_name}.gd'], args.command, log_dir=output)
|
|
report = json.loads((output / f'{check_name}_report.json').read_text())
|
|
print(f"{check_name} checks: {report['passed']}; failed: {report['failed']}")
|
|
if report['failed']:
|
|
raise SystemExit(1)
|
|
elif args.command in ('test-tutorial', 'test-player-controls', 'capture-tutorial'):
|
|
mode = [] if args.command == 'capture-tutorial' else ['--headless']
|
|
capture_args = ['--', '--capture-tutorial', '--gui-only'] if args.command == 'capture-tutorial' else []
|
|
if args.command == 'test-player-controls':
|
|
capture_args = ['--', '--controls-only']
|
|
run(common + mode + ['--fixed-fps', '120', '--script',
|
|
'res://playtest/checks/validate_tutorial.gd'] + capture_args,
|
|
args.command, log_dir=output)
|
|
report_name = 'gui_acceptance.json' if args.command == 'capture-tutorial' else 'acceptance.json'
|
|
if args.command == 'test-player-controls':
|
|
report_name = 'controls_acceptance.json'
|
|
report = json.loads((output / report_name).read_text())
|
|
print(f"Tutorial checks: {report['passed']}; failed: {report['failed']}")
|
|
if report['failed']:
|
|
raise SystemExit(1)
|
|
elif args.command == 'test-elements':
|
|
run(common + ['--headless', '--fixed-fps', '120', '--script',
|
|
'res://playtest/checks/validate_element_puzzles.gd'], 'acceptance', log_dir=output)
|
|
report = json.loads((output / 'acceptance.json').read_text())
|
|
print(f"Element puzzles: {report['passed']}/{len(report['levels'])} passed")
|
|
elif args.command == 'test-alignment':
|
|
run(common + ['--headless', '--fixed-fps', '120', '--script',
|
|
'res://playtest/checks/validate_surface_alignment.gd'], 'surface_alignment')
|
|
report = json.loads((OUTPUT / 'surface_alignment_report.json').read_text())
|
|
print(f"Surface alignment checks: {report['passed']}; failed: {report['failed']}")
|
|
if report['failed']:
|
|
raise SystemExit(1)
|
|
elif args.command == 'test-balls':
|
|
run([executable('blender'), '--background', '--factory-startup',
|
|
'--python-exit-code', '1', '--python', ROOT / 'assets/collections/storybook/source/verify.py'], 'ball_source_verification')
|
|
run(common + ['--headless', '--fixed-fps', '120', '--script',
|
|
'res://playtest/checks/validate_ball_materials.gd'], 'ball_materials_test')
|
|
report = json.loads((OUTPUT / 'ball_materials_report.json').read_text())
|
|
print(f"Ball material checks: {report['passed']}; failed: {report['failed']}")
|
|
elif args.command == 'test':
|
|
run([executable('blender'), '--background', '--factory-startup',
|
|
'--python-exit-code', '1', '--python', ROOT / 'assets/collections/storybook/source/verify.py'], 'source_verification')
|
|
run(common + ['--headless', '--fixed-fps', '120', '--script',
|
|
'res://playtest/checks/validate_studio.gd'], 'test')
|
|
run(common + ['--headless', '--fixed-fps', '120', '--script',
|
|
'res://playtest/checks/validate_editor_tools.gd'], 'editor_tools_test')
|
|
run(common + ['--headless', '--fixed-fps', '120', '--script',
|
|
'res://playtest/checks/validate_surface_alignment.gd'], 'surface_alignment')
|
|
run(common + ['--headless', '--fixed-fps', '120', '--script',
|
|
'res://playtest/checks/validate_solid_chutes.gd'], 'solid_chutes_test')
|
|
run(common + ['--headless', '--fixed-fps', '120', '--script',
|
|
'res://playtest/checks/validate_ball_materials.gd'], 'ball_materials_test')
|
|
run(common + ['--headless', '--fixed-fps', '120', '--script',
|
|
'res://playtest/checks/validate_entities.gd'], 'entities_test')
|
|
run(common + ['--headless', '--fixed-fps', '120', '--script',
|
|
'res://playtest/checks/validate_stacking.gd'], 'stacking_test')
|
|
run(common + ['--headless', '--fixed-fps', '120', '--script',
|
|
'res://playtest/checks/validate_ball_placement.gd'], 'ball_placement_test')
|
|
run(common + ['--headless', '--fixed-fps', '120', '--script',
|
|
'res://playtest/checks/validate_boost.gd'], 'boost_test')
|
|
run(common + ['--headless', '--fixed-fps', '120', '--script',
|
|
'res://playtest/checks/check_repeat.gd'], 'repeat')
|
|
report = json.loads((OUTPUT / 'report.json').read_text())
|
|
print(f"Passed: {report['passed']}; failed: {report['failed']}")
|
|
entities = json.loads((OUTPUT / 'entities_report.json').read_text())
|
|
print(f"Entity and free-ball checks: {entities['passed']}; failed: {entities['failed']}")
|
|
stacking = json.loads((OUTPUT / 'stacking_report.json').read_text())
|
|
print(f"Stacking and ground checks: {stacking['passed']}; failed: {stacking['failed']}")
|
|
ball_placement = json.loads((OUTPUT / 'ball_placement_report.json').read_text())
|
|
print(f"Ball placement checks: {ball_placement['passed']}; failed: {ball_placement['failed']}")
|
|
boost = json.loads((OUTPUT / 'boost_report.json').read_text())
|
|
print(f"Directional boost checks: {boost['passed']}; failed: {boost['failed']}")
|
|
repeats = json.loads((OUTPUT / 'repeat_runs.json').read_text())
|
|
print(f"Repeated full runs: {repeats['passed']}/30; failed: {repeats['failed']}")
|
|
if report['failed']:
|
|
raise SystemExit(1)
|
|
elif args.command == 'capture':
|
|
for scene in ['showcase', 'workshop']:
|
|
run(common + ['--scene', scenes[scene], '--',
|
|
f'--capture={OUTPUT / (scene + ".png")}'], scene + '_capture')
|
|
else:
|
|
extra = ['--', f'--lesson={args.lesson}'] if args.command == 'tutorial' else []
|
|
run(common + ['--scene', scenes[args.command]] + extra, args.command, live=True, log_dir=output)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|