feat: simulate a month
This commit is contained in:
@@ -85,7 +85,21 @@ const createdAt = new Date('2026-01-01').toLocaleDateString(undefined, {
|
||||
</p>
|
||||
<p>
|
||||
You know, from your years of experience, that in 3 days, you sell
|
||||
approximately 5 shirts, 3 jeans, 2 pairs of shoes and 2 hats.
|
||||
approximately
|
||||
<ul>
|
||||
<li>
|
||||
5 shirts <ShirtItem v-for="_ in Array(5)" />
|
||||
</li>
|
||||
<li>
|
||||
3 jeans <JeanItem v-for="_ in Array(3)" />
|
||||
</li>
|
||||
<li>
|
||||
2 pairs of shoes <ShoeItem v-for="_ in Array(2)" />
|
||||
</li>
|
||||
<li>
|
||||
2 hats <HatItem v-for="_ in Array(2)" />
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
<section class="commands">
|
||||
<button
|
||||
@@ -132,6 +146,9 @@ const createdAt = new Date('2026-01-01').toLocaleDateString(undefined, {
|
||||
<button class="button-outline" @click="orders = [...batchPlanning]">
|
||||
batch
|
||||
</button>
|
||||
<div>
|
||||
<button class="button-outline" @click="heijunkaStore.simulateMonth()">Simulate a month</button>
|
||||
</div>
|
||||
</section>
|
||||
<section class="factory">
|
||||
<h2>Factory</h2>
|
||||
|
||||
@@ -37,8 +37,8 @@ const getInventoryByProduct = (
|
||||
): number => {
|
||||
const inventory = planning.filter(
|
||||
(p, index) =>
|
||||
index >= (currentDay - 1) * NUMBER_OF_HOURS_PER_DAY &&
|
||||
index < currentDay * NUMBER_OF_HOURS_PER_DAY &&
|
||||
index >= ((currentDay % NUMBER_OF_DAYS) - 1) * NUMBER_OF_HOURS_PER_DAY &&
|
||||
index < (currentDay % NUMBER_OF_DAYS) * NUMBER_OF_HOURS_PER_DAY &&
|
||||
p === product
|
||||
).length
|
||||
|
||||
@@ -146,13 +146,18 @@ export const useHeijunkaStore = defineStore('heijunka', {
|
||||
this.planning = []
|
||||
this.orders = []
|
||||
this.inventory = { ...initialInventory }
|
||||
},
|
||||
simulateMonth() {
|
||||
for (let index = 0; index < 30; index++) {
|
||||
this.newHour()
|
||||
}
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
currentDay: (state) =>
|
||||
Math.ceil(state.meta.currentHour / NUMBER_OF_HOURS_PER_DAY),
|
||||
gameEnded: (state) =>
|
||||
state.meta.currentHour >= NUMBER_OF_DAYS * NUMBER_OF_HOURS_PER_DAY,
|
||||
gameEnded: () => false,
|
||||
// state.meta.currentHour >= NUMBER_OF_DAYS * NUMBER_OF_HOURS_PER_DAY,
|
||||
meanLeadTime: (state) => getMean(state.orders.map((o) => o.leadTime))
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user