"""Use genuine Yellow carriers after the original BK65 Purple release.

Original BK Crystal King has no required carry color. Its generated remote AP
marble is unburied and needs20 literal carriers; Yellow Pikmin can carry it
through the authored electrical hazards without an unrelated cleanup battle.
The genuine Purple press, same original target, real lift/Onyon/AP and Napsack
consumer remain mandatory. No original patch, slot data or row is edited.
"""
import asyncio
from pathlib import Path
import test_equipment_gameplay_real_server as equipment
import test_equipment_resupply as resupply
import test_equipment_natural_relift as natural
from test_gameplay_real_server import make_parser


def bk65_yellow(required,binding,target_name,buried_names):
    assert not required,'original BK65 has no required carry color'
    assert binding['location']==65 and binding['remote'] and binding['min_carriers']==20
    assert binding['depth_max']==0 and target_name=='Five-man Napsack'
    return 2


class YellowCarrierEquipment(natural.NaturalReliftEquipment):
    async def collect(self,source,location):
        if (source,location)!=(1,65):return await super().collect(source,location)
        assert self.source(2,510)==(1,65),'retain the exact original Glint-to-Napsack mapping'
        previous=resupply.carrier_color
        def selected(required,binding,target_name,buried_names):
            color=bk65_yellow(required,binding,target_name,buried_names)
            self.session.event('equipment-original-bk65-yellow-carriers',source=source,location=location,
                original_required=required,binding=binding,color=color,boundary=__doc__)
            return color
        resupply.carrier_color=selected
        try:return await super().collect(source,location)
        finally:resupply.carrier_color=previous


async def main(args):
    # Existing natural.main binds this class into the same reviewed entry/run.
    natural.NaturalReliftEquipment=YellowCarrierEquipment
    equipment.HELPERS.append(Path(__file__))
    await natural.main(args)


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