Align scene ids with names and order
This commit is contained in:
22
main.js
22
main.js
@@ -143,10 +143,24 @@
|
||||
};
|
||||
|
||||
const getNextSceneId = () => {
|
||||
const winCond = currentScene?.config?.winCondition;
|
||||
if (winCond?.nextSceneId) return winCond.nextSceneId;
|
||||
const idx = scenes.findIndex((s) => s.id === currentScene?.id);
|
||||
if (idx >= 0 && idx < scenes.length - 1) return scenes[idx + 1].id;
|
||||
const order = window.PhysilinksScenes?.order || [];
|
||||
const currentId = currentScene?.id;
|
||||
const orderedExisting = order.filter((id) =>
|
||||
scenes.some((s) => s.id === id),
|
||||
);
|
||||
if (orderedExisting.length > 0 && currentId) {
|
||||
const idx = orderedExisting.indexOf(currentId);
|
||||
if (idx >= 0 && idx < orderedExisting.length - 1) {
|
||||
return orderedExisting[idx + 1];
|
||||
}
|
||||
if (idx === orderedExisting.length - 1) {
|
||||
return orderedExisting[0];
|
||||
}
|
||||
}
|
||||
const fallbackIdx = scenes.findIndex((s) => s.id === currentId);
|
||||
if (fallbackIdx >= 0 && fallbackIdx < scenes.length - 1) {
|
||||
return scenes[fallbackIdx + 1].id;
|
||||
}
|
||||
return scenes[0]?.id || defaultSceneId;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user