<script lang="ts">
    import type { BuildingType } from "../types";
    import village from "../village";

    export let building: BuildingType;


    $: unitsCount = building.state.recruitment?.count || 0;
    $: recruitmentTime = building.behavior.units?.recruitmentTime($village, building) || 0;
    $: currentRecruitTime = building.state.recruitment?.elapsedTime || 0;
    $: timeToNextRecruit = recruitmentTime * 1000 - currentRecruitTime;
    $: prettyDuration = Math.ceil(timeToNextRecruit / 1000);
</script>

{ #if unitsCount > 0 }
<div>
    { unitsCount }
    ({ prettyDuration }’)
</div>
{ /if }
