"use strict"; importScripts("/vendor/pyodide.js"); const ready = (async () => { const py = await loadPyodide({indexURL: "/vendor/", fullStdLib:false}); const response = await fetch("/rules.json", {credentials:"omit"}); if (!response.ok) throw Error("Файлы движка недоступны"); const files = await response.json(); for (const file of ["catalog.json","engine.py","strategy.py","local_game.py"]) { py.FS.writeFile("/home/pyodide/"+file, files[file]); } return py.runPython("from local_game import dispatch\ndispatch"); })(); onmessage = async ({data}) => { try { const dispatch = await ready; postMessage({result:JSON.parse(dispatch(JSON.stringify(data)))}); } catch { postMessage({error:"Не удалось открыть позицию. Попробуйте начать новую партию."}); } };