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