import{ setupLevel, setupLevelUi } from './level.js'; const levels = { 'Initial Jump': [ [], setupLevel([], [8, 0]) ], 'Monopole Mining': [ ['Initial Jump'], setupLevel([[3, 3]], [8,8]) ], }; export function setupLevelSelectUi(root, audio) { const levelList = document.createElement('ol'); const levelPicker = name => { const [ dependencies, level ] = levels[name]; const allDependenciesSatisfied = dependencies.map(x => levels[x][1].completed).reduce((acc, x) => acc && x, true); if (allDependenciesSatisfied) { const button = document.createElement('input'); button.type = 'button'; button.onclick = () => { root.innerText = ''; setupLevelUi(level, root, audio); } const li = document.createElement('li'); li.appendChild(button); levelList.appendChild(li); } } [...Object.keys(levels)].forEach(levelPicker); root.appendChild(levelList); }