"""Native-only grounded dig/carry preflight using actual White work states."""
import argparse
import json
from pathlib import Path
import test_grounded_native_preflight as probe
from test_gameplay_digging_cases import prepare_digging_squad
from test_equipment_survivors import NearConsumerRoute
from test_real_server import sha


def prepare(self,location,color,count):
    _,_,binding=self.physical(location)
    if binding['depth_max']>0:return prepare_digging_squad(self,location,color,min(100,max(2,count*2)))
    return NearConsumerRoute.squad_at_actor(self,location,color,count)


if __name__=='__main__':
    parser=argparse.ArgumentParser(description=__doc__)
    for option in ('native','client','assets','output'):parser.add_argument('--'+option,type=Path,required=True)
    args=parser.parse_args();probe.ProbeRoute.squad_at_actor=prepare
    extra={str(Path(__file__).resolve()):sha(__file__)}
    path=Path(__file__).with_name('test_gameplay_digging_cases.py');extra[str(path)]=sha(path)
    try:probe.main(args)
    finally:
        path=args.output/'report.json'
        if path.exists():
            report=json.loads(path.read_text());report['helper_sha256'].update(extra)
            report['inputs_unchanged'] &= all(sha(Path(p))==digest for p,digest in extra.items())
            if not report['inputs_unchanged']:report['status']='failed'
            path.write_text(json.dumps(report,indent=2)+'\n')
