code-battles 1.7.7 → 1.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +21 -4
- package/dist/cjs/styles.css +6 -6
- package/dist/code_battles/__init__.py +2 -0
- package/dist/code_battles/battles.py +3 -19
- package/dist/esm/index.js +21 -4
- package/dist/esm/styles.css +6 -6
- package/package.json +19 -19
- package/dist/cjs/types/particles.d.ts +0 -2
- package/dist/esm/types/particles.d.ts +0 -2
- package/dist/pyscript/codemirror-Cxby0EOW.js +0 -2
- package/dist/pyscript/codemirror-Cxby0EOW.js.map +0 -1
- package/dist/pyscript/codemirror-DtxT3fWl.js +0 -2
- package/dist/pyscript/codemirror-DtxT3fWl.js.map +0 -1
- package/dist/pyscript/codemirror_commands-CmeJ70sL.js +0 -2
- package/dist/pyscript/codemirror_commands-CmeJ70sL.js.map +0 -1
- package/dist/pyscript/codemirror_commands-DEH2ednO.js +0 -2
- package/dist/pyscript/codemirror_commands-DEH2ednO.js.map +0 -1
- package/dist/pyscript/codemirror_lang-python-BmOE5ND1.js +0 -2
- package/dist/pyscript/codemirror_lang-python-BmOE5ND1.js.map +0 -1
- package/dist/pyscript/codemirror_lang-python-C4eeLuBs.js +0 -2
- package/dist/pyscript/codemirror_lang-python-C4eeLuBs.js.map +0 -1
- package/dist/pyscript/codemirror_language-Bq5O0hUR.js +0 -2
- package/dist/pyscript/codemirror_language-Bq5O0hUR.js.map +0 -1
- package/dist/pyscript/codemirror_language-DbhkgEi1.js +0 -2
- package/dist/pyscript/codemirror_language-DbhkgEi1.js.map +0 -1
- package/dist/pyscript/codemirror_view-BwC4I3hj.js +0 -2
- package/dist/pyscript/codemirror_view-BwC4I3hj.js.map +0 -1
- package/dist/pyscript/codemirror_view-DNx7dL5k.js +0 -2
- package/dist/pyscript/codemirror_view-DNx7dL5k.js.map +0 -1
- package/dist/pyscript/core-BAg8axiz.js +0 -4
- package/dist/pyscript/core-BAg8axiz.js.map +0 -1
- package/dist/pyscript/core-D_Y2i5wV.js +0 -4
- package/dist/pyscript/core-D_Y2i5wV.js.map +0 -1
- package/dist/pyscript/core-ZERPM6xU.js +0 -4
- package/dist/pyscript/core-ZERPM6xU.js.map +0 -1
- package/dist/pyscript/deprecations-manager-C-kM_OOK.js +0 -2
- package/dist/pyscript/deprecations-manager-C-kM_OOK.js.map +0 -1
- package/dist/pyscript/deprecations-manager-DFWBNz_j.js +0 -2
- package/dist/pyscript/deprecations-manager-DFWBNz_j.js.map +0 -1
- package/dist/pyscript/deprecations-manager-DdXs-cNg.js +0 -2
- package/dist/pyscript/deprecations-manager-DdXs-cNg.js.map +0 -1
- package/dist/pyscript/donkey--RgkMgKe.js +0 -2
- package/dist/pyscript/donkey--RgkMgKe.js.map +0 -1
- package/dist/pyscript/donkey-9sgzITrF.js +0 -2
- package/dist/pyscript/donkey-9sgzITrF.js.map +0 -1
- package/dist/pyscript/donkey-DvYy_z4S.js +0 -2
- package/dist/pyscript/donkey-DvYy_z4S.js.map +0 -1
- package/dist/pyscript/error-ADoJa5BE.js +0 -2
- package/dist/pyscript/error-ADoJa5BE.js.map +0 -1
- package/dist/pyscript/error-BHehssqp.js +0 -2
- package/dist/pyscript/error-BHehssqp.js.map +0 -1
- package/dist/pyscript/error-Dc0g2_oA.js +0 -2
- package/dist/pyscript/error-Dc0g2_oA.js.map +0 -1
- package/dist/pyscript/index-B25jxAgK.js +0 -2
- package/dist/pyscript/index-B25jxAgK.js.map +0 -1
- package/dist/pyscript/index-BtkFDJPe.js +0 -2
- package/dist/pyscript/index-BtkFDJPe.js.map +0 -1
- package/dist/pyscript/mpy-BOCRQK6f.js +0 -2
- package/dist/pyscript/mpy-BOCRQK6f.js.map +0 -1
- package/dist/pyscript/mpy-PutLL-8K.js +0 -2
- package/dist/pyscript/mpy-PutLL-8K.js.map +0 -1
- package/dist/pyscript/mpy-lpj2Tqw5.js +0 -2
- package/dist/pyscript/mpy-lpj2Tqw5.js.map +0 -1
- package/dist/pyscript/py-ByqLLyxS.js +0 -2
- package/dist/pyscript/py-ByqLLyxS.js.map +0 -1
- package/dist/pyscript/py-C5u4njlg.js +0 -2
- package/dist/pyscript/py-C5u4njlg.js.map +0 -1
- package/dist/pyscript/py-CbCpu0Nu.js +0 -2
- package/dist/pyscript/py-CbCpu0Nu.js.map +0 -1
- package/dist/pyscript/py-editor-BSEgUf3R.js +0 -2
- package/dist/pyscript/py-editor-BSEgUf3R.js.map +0 -1
- package/dist/pyscript/py-editor-JsJIlo51.js +0 -2
- package/dist/pyscript/py-editor-JsJIlo51.js.map +0 -1
- package/dist/pyscript/py-editor-rQyrU9ml.js +0 -2
- package/dist/pyscript/py-editor-rQyrU9ml.js.map +0 -1
- package/dist/pyscript/py-game-CqGV5glf.js +0 -2
- package/dist/pyscript/py-game-CqGV5glf.js.map +0 -1
- package/dist/pyscript/py-game-D3nLvq_1.js +0 -2
- package/dist/pyscript/py-game-D3nLvq_1.js.map +0 -1
- package/dist/pyscript/py-game-DC-XdrKH.js +0 -2
- package/dist/pyscript/py-game-DC-XdrKH.js.map +0 -1
- package/dist/pyscript/py-terminal-CEeXlsXC.js +0 -2
- package/dist/pyscript/py-terminal-CEeXlsXC.js.map +0 -1
- package/dist/pyscript/py-terminal-CNqBj7Ns.js +0 -2
- package/dist/pyscript/py-terminal-CNqBj7Ns.js.map +0 -1
- package/dist/pyscript/py-terminal-qT02HXWZ.js +0 -2
- package/dist/pyscript/py-terminal-qT02HXWZ.js.map +0 -1
- package/dist/pyscript/xterm-7LwxAMsn.js +0 -2
- package/dist/pyscript/xterm-7LwxAMsn.js.map +0 -1
- package/dist/pyscript/zip-DxlTOqbw.js +0 -2
- package/dist/pyscript/zip-DxlTOqbw.js.map +0 -1
|
@@ -543,18 +543,10 @@ class CodeBattles(
|
|
|
543
543
|
|
|
544
544
|
@web_only
|
|
545
545
|
def _initialize(self):
|
|
546
|
-
from js import
|
|
546
|
+
from js import window
|
|
547
547
|
from pyscript.ffi import create_proxy
|
|
548
548
|
|
|
549
549
|
window.addEventListener("resize", create_proxy(lambda _: self._resize_canvas()))
|
|
550
|
-
document.getElementById("playpause").onclick = create_proxy(
|
|
551
|
-
lambda _: asyncio.get_event_loop().run_until_complete(self._play_pause())
|
|
552
|
-
)
|
|
553
|
-
step_element = document.getElementById("step")
|
|
554
|
-
if step_element is not None:
|
|
555
|
-
step_element.onclick = create_proxy(
|
|
556
|
-
lambda _: asyncio.get_event_loop().run_until_complete(self._step())
|
|
557
|
-
)
|
|
558
550
|
|
|
559
551
|
def _initialize_simulation(
|
|
560
552
|
self, player_codes: List[str], seed: Optional[int] = None
|
|
@@ -698,15 +690,7 @@ class CodeBattles(
|
|
|
698
690
|
with open(output_file, "w") as f:
|
|
699
691
|
f.write(simulation_str)
|
|
700
692
|
|
|
701
|
-
def
|
|
702
|
-
loop = asyncio.get_event_loop()
|
|
703
|
-
loop.run_until_complete(self._start_simulation_async(*args, **kwargs))
|
|
704
|
-
|
|
705
|
-
def _start_simulation_from_file(self, contents: str):
|
|
706
|
-
loop = asyncio.get_event_loop()
|
|
707
|
-
loop.run_until_complete(self._start_simulation_from_file_async(contents))
|
|
708
|
-
|
|
709
|
-
async def _start_simulation_from_file_async(self, contents: str):
|
|
693
|
+
async def _start_simulation_from_file(self, contents: str):
|
|
710
694
|
from js import document
|
|
711
695
|
|
|
712
696
|
try:
|
|
@@ -773,7 +757,7 @@ class CodeBattles(
|
|
|
773
757
|
print(e)
|
|
774
758
|
|
|
775
759
|
@web_only
|
|
776
|
-
async def
|
|
760
|
+
async def _start_simulation(
|
|
777
761
|
self,
|
|
778
762
|
parameters: Dict[str, str],
|
|
779
763
|
player_codes: List[str],
|
package/dist/esm/index.js
CHANGED
|
@@ -407,7 +407,7 @@ const runNoUI = (parameters, apis, playerBots, seed, verbose) => {
|
|
|
407
407
|
const players = playerBots.map((api) => (api === "None" ? "" : apis[api]));
|
|
408
408
|
tryUntilSuccess(() =>
|
|
409
409
|
// @ts-ignore
|
|
410
|
-
window._startSimulation
|
|
410
|
+
window._startSimulation(parameters, players, playerBots, true, false, verbose, seed));
|
|
411
411
|
};
|
|
412
412
|
const tryUntilSuccess = (f, timeout = 500) => {
|
|
413
413
|
try {
|
|
@@ -2698,7 +2698,7 @@ const RunSimulationBlock = () => {
|
|
|
2698
2698
|
window._isSimulationFromFile = true;
|
|
2699
2699
|
tryUntilSuccess(() => {
|
|
2700
2700
|
// @ts-ignore
|
|
2701
|
-
window._startSimulationFromFile
|
|
2701
|
+
window._startSimulationFromFile(text);
|
|
2702
2702
|
});
|
|
2703
2703
|
}), style: {
|
|
2704
2704
|
textAlign: "center",
|
|
@@ -3349,6 +3349,8 @@ const PlayPauseButton = () => {
|
|
|
3349
3349
|
(_b = window.mainAudio) === null || _b === void 0 ? void 0 : _b.play();
|
|
3350
3350
|
}
|
|
3351
3351
|
setPlaying((p) => !p);
|
|
3352
|
+
// @ts-ignore
|
|
3353
|
+
window._playPause();
|
|
3352
3354
|
}, leftSection: playing ? (React.createElement("i", { className: "fa-solid fa-pause" })) : (React.createElement("i", { className: "fa-solid fa-play" })), color: playing ? "yellow.4" : "green", id: "playpause" }, playing ? "Pause" : "Play"));
|
|
3353
3355
|
};
|
|
3354
3356
|
const Simulation = () => {
|
|
@@ -3411,7 +3413,7 @@ const Simulation = () => {
|
|
|
3411
3413
|
const seed = (_a = searchParams.get("seed")) !== null && _a !== void 0 ? _a : "";
|
|
3412
3414
|
tryUntilSuccess(() =>
|
|
3413
3415
|
// @ts-ignore
|
|
3414
|
-
window._startSimulation
|
|
3416
|
+
window._startSimulation(parameters, players, playerNames, false, !showcaseMode, true, seed));
|
|
3415
3417
|
}
|
|
3416
3418
|
}, [loading]);
|
|
3417
3419
|
const newRank = getRank(getLocalStorage("Cached tournament/info"), winner, getLocalStorage("Point Modifier")) + 1;
|
|
@@ -3492,7 +3494,9 @@ const Simulation = () => {
|
|
|
3492
3494
|
showcaseMode || (React.createElement(React.Fragment, null,
|
|
3493
3495
|
React.createElement("span", { id: "render-status", style: { marginRight: 10 } }),
|
|
3494
3496
|
React.createElement(NumberInput, { id: "breakpoint", label: "Breakpoint", min: 0, leftSection: React.createElement("i", { className: "fa-solid fa-stopwatch" }), display: "inline-block", maw: "35%", mr: "xs" }),
|
|
3495
|
-
React.createElement(Button, { style: { flex: "none" }, my: "xs", w: 100, leftSection: React.createElement("i", { className: "fa-solid fa-wand-magic" }), color: "grape", id: "step", mr: "xs", radius: "20px"
|
|
3497
|
+
React.createElement(Button, { style: { flex: "none" }, my: "xs", w: 100, leftSection: React.createElement("i", { className: "fa-solid fa-wand-magic" }), color: "grape", id: "step", mr: "xs", radius: "20px",
|
|
3498
|
+
// @ts-ignore
|
|
3499
|
+
onClick: () => window._step() }, "Step"))),
|
|
3496
3500
|
React.createElement(PlayPauseButton, null),
|
|
3497
3501
|
downloadBytes && (React.createElement(Button, { ml: "xs", radius: "20px", leftSection: React.createElement("i", { className: "fa-solid fa-download" }), color: "blue", onClick: () => downloadFile(`${playerNames.join("-")}.btl`, "text/plain",
|
|
3498
3502
|
// @ts-ignore
|
|
@@ -5981,6 +5985,19 @@ function requirePrismLineNumbers () {
|
|
|
5981
5985
|
requirePrismLineNumbers();
|
|
5982
5986
|
|
|
5983
5987
|
const initialize = () => {
|
|
5988
|
+
// Load the packed Python file of the project, on the main thread and on a web worker.
|
|
5989
|
+
const mainThreadScript = document.createElement("script");
|
|
5990
|
+
mainThreadScript.type = "py";
|
|
5991
|
+
mainThreadScript.src = "/scripts/packed.py";
|
|
5992
|
+
mainThreadScript.setAttribute("config", "/config.json");
|
|
5993
|
+
document.body.appendChild(mainThreadScript);
|
|
5994
|
+
const workerScript = document.createElement("script");
|
|
5995
|
+
workerScript.type = "py";
|
|
5996
|
+
workerScript.src = "/scripts/packed.py";
|
|
5997
|
+
workerScript.setAttribute("config", "/config.json");
|
|
5998
|
+
workerScript.toggleAttribute("worker", true);
|
|
5999
|
+
workerScript.setAttribute("name", "worker");
|
|
6000
|
+
document.body.appendChild(workerScript);
|
|
5984
6001
|
// @ts-ignore
|
|
5985
6002
|
window.showAlert = (title, alert, color, icon, limitTime, isCode) => {
|
|
5986
6003
|
var _a;
|