import { getRemainingUnitCount } from "../utils";
import type { VillageState } from "../village";


export default function pillage(V: VillageState, regionIndex: number, soldiersCount: number) {
    if (soldiersCount > getRemainingUnitCount(V, 'soldier')) {
        return false;
    }

    const region = V.worldmap[regionIndex];

    if (region.state.mission) {
        return false;
    }

    region.state.mission = {
        type: 'pillage',
        unitType: 'soldier',
        unitCount: soldiersCount,
        remainingTime: region.distance * 10 * 1000,
    };

    return true;
}
