"""Use native whistle reach for the final existing-worker approach.

Walk the compatible native route nodes as before. The final worker centroid
or pellet approach stops within65 units, allowing genuine cursor/B recruitment
at a wall rather than requiring the captain to enter the same point. Actual
recruitment, unchanged identities, target-only throws, lift and Onyon/AP remain
required; no actors, native weights or rewards are assigned.
"""
import asyncio
from pathlib import Path
import test_equipment_fresh_original as fresh
import test_equipment_gameplay_real_server as equipment
from test_equipment_original_alternate import OriginalAlternateRoute
from test_equipment_worker_recovery import route_points
from test_gameplay_real_server import make_parser


class RecallApproachRoute(OriginalAlternateRoute):
    def walk_existing(self, target):
        state=self.playable()
        start=self.driver.active_navi(state)['position']
        points=route_points(state,start,target,self.delivery_color)
        self.record('existing-worker-native-route-walk',state,points=points,boundary=__doc__)
        for index,position in enumerate(points):
            self.driver.walk_to(self.game,position,radius=65 if index==len(points)-1 else 35,timeout=60)
            self.playable()


class RecallApproachEquipment(fresh.FreshOriginalEquipment):
    def __init__(self,session,driver,games):
        super().__init__(session,driver,games)
        self.routes={slot:RecallApproachRoute(game,driver) for slot,game in games.items()}
        for route in self.routes.values():route.session=session


async def main(args):
    fresh.FreshOriginalEquipment=RecallApproachEquipment
    equipment.HELPERS.append(Path(__file__))
    await fresh.main(args)


if __name__=='__main__':
    parser=make_parser(__doc__);parser.add_argument('--resume-checkpoint',type=Path)
    asyncio.run(main(parser.parse_args()))
