"""Strict Red threshold cases, with grounded spare Whites only for positive burial."""
import asyncio
from pathlib import Path
import test_gameplay_actor_cases as cases
from test_gameplay_digging_cases import DiggingRoute,prepare_digging_squad,EXTRA
from test_gameplay_settled_route import SettledRoute
from test_gameplay_real_server import make_parser


class PreciseRoute(DiggingRoute):
    def squad_at_actor(self,location,color,count):
        _,_,binding=self.physical(location)
        if color==4 and binding['depth_max']>0:
            return prepare_digging_squad(self,location,color,min(100,max(2,count*2)))
        # Config depth_max may be nonzero on a non-buried kit model. Red
        # negative/positive cases must retain exactly the requested count.
        return SettledRoute.squad_at_actor(self,location,color,count)


if __name__=='__main__':
    args=make_parser(__doc__).parse_args();args.case='loaded';cases.StableRoute=PreciseRoute
    cases.EXTRA.extend(Path(__file__).with_name(n) for n in EXTRA)
    cases.EXTRA.append(Path(__file__).resolve())
    asyncio.run(cases.main(args))
