2024-10-25 19:03:32 +02:00
|
|
|
<script lang="ts">
|
|
|
|
import units from "../data/units";
|
|
|
|
import village from "../village";
|
|
|
|
|
|
|
|
$: currentUnits = Object.entries($village.units).map(([type, count]) => {
|
|
|
|
const unit = units.find(u => u.type === type);
|
2024-11-07 10:12:29 +01:00
|
|
|
if (!unit) {
|
|
|
|
throw new Error(`Unable to find unit: "${type}"`);
|
|
|
|
|
|
|
|
}
|
2024-10-25 19:03:32 +02:00
|
|
|
return {
|
|
|
|
...unit,
|
|
|
|
count,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<section>
|
|
|
|
{ #each currentUnits as unit }
|
|
|
|
<p>{ unit.name }: { unit.count }</p>
|
|
|
|
{ /each }
|
|
|
|
</section>
|