feat: simulate a month

This commit is contained in:
Julien Calixte
2026-01-02 10:19:57 +01:00
parent c4bdecf323
commit 8123d6b0ac
2 changed files with 27 additions and 5 deletions

View File

@@ -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))
}
})