Show units being recruited in the University panel.

This commit is contained in:
Adrian 2024-11-05 11:03:34 +01:00
parent ba812bbc03
commit 1885463132
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,20 @@
<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 }

View File

@ -5,6 +5,7 @@
import type { VillageState } from "../village"; import type { VillageState } from "../village";
import village from "../village"; import village from "../village";
import Cost from "./Cost.svelte"; import Cost from "./Cost.svelte";
import RecruitmentQueue from "./RecruitmentQueue.svelte";
export let building: BuildingType; export let building: BuildingType;
@ -42,6 +43,10 @@
return res; return res;
} }
function setMaxUnits() {
numberOfUnits = maximumUnits;
}
</script> </script>
<div class="university"> <div class="university">
@ -65,8 +70,10 @@
max={ maximumUnits } max={ maximumUnits }
bind:value={ numberOfUnits } bind:value={ numberOfUnits }
/> />
<button on:click={ setMaxUnits }>↑</button>
<button on:click={ recruit } disabled={ numberOfUnits > maximumUnits }>Recruit</button> <button on:click={ recruit } disabled={ numberOfUnits > maximumUnits }>Recruit</button>
</div> </div>
<RecruitmentQueue { building } />
</div> </div>
<style> <style>