code-battles 1.1.0 → 1.2.0

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.
Files changed (32) hide show
  1. package/LICENSE.md +7 -7
  2. package/README.md +39 -39
  3. package/dist/code_battles/__init__.py +20 -13
  4. package/dist/code_battles/__pycache__/__init__.cpython-312.pyc +0 -0
  5. package/dist/code_battles/__pycache__/battles.cpython-312.pyc +0 -0
  6. package/dist/code_battles/__pycache__/utilities.cpython-312.pyc +0 -0
  7. package/dist/code_battles/battles.py +640 -566
  8. package/dist/code_battles/js.pyi +131 -130
  9. package/dist/code_battles/pyodide/ffi/__init__.pyi +2 -2
  10. package/dist/code_battles/pyscript/ffi/__init__.pyi +3 -3
  11. package/dist/code_battles/utilities.py +226 -222
  12. package/dist/pdoc-template/custom.css +22 -22
  13. package/dist/pdoc-template/module.html.jinja2 +305 -305
  14. package/dist/pdoc-template/syntax-highlighting.css +248 -248
  15. package/dist/pyscript/core-CjO3FOKB.js +2 -0
  16. package/dist/pyscript/core-CjO3FOKB.js.map +1 -0
  17. package/dist/pyscript/core.js +1 -1
  18. package/dist/pyscript/{deprecations-manager-B8Tn4H-t.js → deprecations-manager-pFtn19mE.js} +2 -2
  19. package/dist/pyscript/{deprecations-manager-B8Tn4H-t.js.map → deprecations-manager-pFtn19mE.js.map} +1 -1
  20. package/dist/pyscript/{error-Dmba-E9f.js → error-tq-z48YI.js} +2 -2
  21. package/dist/pyscript/{error-Dmba-E9f.js.map → error-tq-z48YI.js.map} +1 -1
  22. package/dist/pyscript/{mpy-BnYOGs9W.js → mpy-DovD7Qjy.js} +2 -2
  23. package/dist/pyscript/{mpy-BnYOGs9W.js.map → mpy-DovD7Qjy.js.map} +1 -1
  24. package/dist/pyscript/{py-D2NmpN63.js → py-BUsUWVJg.js} +2 -2
  25. package/dist/pyscript/{py-D2NmpN63.js.map → py-BUsUWVJg.js.map} +1 -1
  26. package/dist/pyscript/{py-editor-Czy2e-Jt.js → py-editor-CeySmmer.js} +2 -2
  27. package/dist/pyscript/{py-editor-Czy2e-Jt.js.map → py-editor-CeySmmer.js.map} +1 -1
  28. package/dist/pyscript/{py-terminal-w87wZryi.js → py-terminal-CH_wV7wQ.js} +2 -2
  29. package/dist/pyscript/{py-terminal-w87wZryi.js.map → py-terminal-CH_wV7wQ.js.map} +1 -1
  30. package/package.json +14 -14
  31. package/dist/pyscript/core-CZGzC87D.js +0 -2
  32. package/dist/pyscript/core-CZGzC87D.js.map +0 -1
package/LICENSE.md CHANGED
@@ -1,7 +1,7 @@
1
- Copyright 2024 Noam Zaks and Code Battles Contributors
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright 2024 Noam Zaks and Code Battles Contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,39 +1,39 @@
1
- <p align="center">
2
- <img src="https://github.com/noamzaks/code-battles/assets/63877260/b330aa14-7003-4204-8907-e77a5c6e8d81" height="140">
3
- </p>
4
- <h1 align="center">
5
- Code Battles
6
- <br />
7
- <img src="https://img.shields.io/npm/v/code-battles">
8
- <a href='https://code-battles.readthedocs.io/en/latest/?badge=latest'>
9
- <img src='https://readthedocs.org/projects/code-battles/badge/?version=latest' alt='Documentation Status' />
10
- </a>
11
- <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg">
12
- <img src="https://img.shields.io/badge/license-MIT-blue.svg">
13
- </h1>
14
-
15
- <p align="center">
16
- A fun group coding experience of writing <b>Python</b> bots to compete in a game!
17
- </p>
18
- <p align="center">
19
- 🏃 <a href="#getting-started">Getting Started</a>
20
- &nbsp;&middot&nbsp;
21
- 🚗 <a href="#roadmap">Roadmap</a>
22
- </p>
23
-
24
- # Getting Started
25
-
26
- Create your own **code battles** competition by implementing your game in Python using this library, **without doing** web development!
27
-
28
- Follow the instructions in the [documentation](https://code-battles.readthedocs.org).
29
-
30
- # Roadmap
31
-
32
- - [ ] Download game file containing all decisions made.
33
- - [ ] Support game file re-run of a simulation.
34
- - [ ] Support additional metadata to detect "highlight" simulations.
35
-
36
- ## Open Source Licenses
37
-
38
- - [Font Awesome](https://fontawesome.com/license/free)
39
- - [PyScript](https://github.com/pyscript/pyscript/blob/main/LICENSE)
1
+ <p align="center">
2
+ <img src="https://github.com/noamzaks/code-battles/assets/63877260/b330aa14-7003-4204-8907-e77a5c6e8d81" height="140">
3
+ </p>
4
+ <h1 align="center">
5
+ Code Battles
6
+ <br />
7
+ <img src="https://img.shields.io/npm/v/code-battles">
8
+ <a href='https://code-battles.readthedocs.io/en/latest/?badge=latest'>
9
+ <img src='https://readthedocs.org/projects/code-battles/badge/?version=latest' alt='Documentation Status' />
10
+ </a>
11
+ <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg">
12
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg">
13
+ </h1>
14
+
15
+ <p align="center">
16
+ A fun group coding experience of writing <b>Python</b> bots to compete in a game!
17
+ </p>
18
+ <p align="center">
19
+ 🏃 <a href="#getting-started">Getting Started</a>
20
+ &nbsp;&middot&nbsp;
21
+ 🚗 <a href="#roadmap">Roadmap</a>
22
+ </p>
23
+
24
+ # Getting Started
25
+
26
+ Create your own **code battles** competition by implementing your game in Python using this library, **without doing** web development!
27
+
28
+ Follow the instructions in the [documentation](https://code-battles.readthedocs.org).
29
+
30
+ # Roadmap
31
+
32
+ - [ ] Download game file containing all decisions made.
33
+ - [ ] Support game file re-run of a simulation.
34
+ - [ ] Support additional metadata to detect "highlight" simulations.
35
+
36
+ ## Open Source Licenses
37
+
38
+ - [Font Awesome](https://fontawesome.com/license/free)
39
+ - [PyScript](https://github.com/pyscript/pyscript/blob/main/LICENSE)
@@ -1,13 +1,20 @@
1
- from code_battles.utilities import GameCanvas, Alignment
2
- from code_battles.battles import CodeBattles
3
- from js import window
4
- from pyscript.ffi import create_proxy
5
-
6
-
7
- def run_game(battles: CodeBattles):
8
- """Binds the given code battles instance to the React code to enable all simulations."""
9
-
10
- window._startSimulation = create_proxy(battles._start_simulation)
11
-
12
-
13
- __all__ = ["CodeBattles", "GameCanvas", "Alignment", "run_game"]
1
+ import sys
2
+
3
+ from code_battles.utilities import GameCanvas, Alignment
4
+ from code_battles.battles import CodeBattles, is_web
5
+ from js import window
6
+ from pyscript.ffi import create_proxy
7
+
8
+
9
+ def run_game(battles: CodeBattles):
10
+ """
11
+ Binds the given code battles instance to the React code to enable all simulations.
12
+ """
13
+
14
+ if is_web:
15
+ window._startSimulation = create_proxy(battles._start_simulation)
16
+ else:
17
+ battles._run_local_simulation()
18
+
19
+
20
+ __all__ = ["CodeBattles", "GameCanvas", "Alignment", "run_game"]