Spaces:
Running
Running
Beracles
commited on
Commit
·
945b70e
1
Parent(s):
ebe21f0
initial version
Browse files- .gitignore +160 -0
- Dockerfile +25 -0
- app/__init__.py +0 -0
- app/watermelon.py +43 -0
- main.py +18 -0
- requirements.txt +3 -0
- static/index.css +53 -0
- static/index.html +15 -0
- static/watermelon/delete_all_of_sth/index.html +38 -0
- static/watermelon/delete_all_of_sth/index.js +20 -0
- static/watermelon/help/index.html +27 -0
- static/watermelon/help/index.js +18 -0
- static/watermelon/index.html +21 -0
- static/watermelon/index.js +0 -0
- static/watermelon/reset_game/index.html +27 -0
- static/watermelon/reset_game/index.js +18 -0
- static/watermelon/set_number_of_sth/index.html +42 -0
- static/watermelon/set_number_of_sth/index.js +22 -0
.gitignore
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Byte-compiled / optimized / DLL files
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
|
| 6 |
+
# C extensions
|
| 7 |
+
*.so
|
| 8 |
+
|
| 9 |
+
# Distribution / packaging
|
| 10 |
+
.Python
|
| 11 |
+
build/
|
| 12 |
+
develop-eggs/
|
| 13 |
+
dist/
|
| 14 |
+
downloads/
|
| 15 |
+
eggs/
|
| 16 |
+
.eggs/
|
| 17 |
+
lib/
|
| 18 |
+
lib64/
|
| 19 |
+
parts/
|
| 20 |
+
sdist/
|
| 21 |
+
var/
|
| 22 |
+
wheels/
|
| 23 |
+
share/python-wheels/
|
| 24 |
+
*.egg-info/
|
| 25 |
+
.installed.cfg
|
| 26 |
+
*.egg
|
| 27 |
+
MANIFEST
|
| 28 |
+
|
| 29 |
+
# PyInstaller
|
| 30 |
+
# Usually these files are written by a python script from a template
|
| 31 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
| 32 |
+
*.manifest
|
| 33 |
+
*.spec
|
| 34 |
+
|
| 35 |
+
# Installer logs
|
| 36 |
+
pip-log.txt
|
| 37 |
+
pip-delete-this-directory.txt
|
| 38 |
+
|
| 39 |
+
# Unit test / coverage reports
|
| 40 |
+
htmlcov/
|
| 41 |
+
.tox/
|
| 42 |
+
.nox/
|
| 43 |
+
.coverage
|
| 44 |
+
.coverage.*
|
| 45 |
+
.cache
|
| 46 |
+
nosetests.xml
|
| 47 |
+
coverage.xml
|
| 48 |
+
*.cover
|
| 49 |
+
*.py,cover
|
| 50 |
+
.hypothesis/
|
| 51 |
+
.pytest_cache/
|
| 52 |
+
cover/
|
| 53 |
+
|
| 54 |
+
# Translations
|
| 55 |
+
*.mo
|
| 56 |
+
*.pot
|
| 57 |
+
|
| 58 |
+
# Django stuff:
|
| 59 |
+
*.log
|
| 60 |
+
local_settings.py
|
| 61 |
+
db.sqlite3
|
| 62 |
+
db.sqlite3-journal
|
| 63 |
+
|
| 64 |
+
# Flask stuff:
|
| 65 |
+
instance/
|
| 66 |
+
.webassets-cache
|
| 67 |
+
|
| 68 |
+
# Scrapy stuff:
|
| 69 |
+
.scrapy
|
| 70 |
+
|
| 71 |
+
# Sphinx documentation
|
| 72 |
+
docs/_build/
|
| 73 |
+
|
| 74 |
+
# PyBuilder
|
| 75 |
+
.pybuilder/
|
| 76 |
+
target/
|
| 77 |
+
|
| 78 |
+
# Jupyter Notebook
|
| 79 |
+
.ipynb_checkpoints
|
| 80 |
+
|
| 81 |
+
# IPython
|
| 82 |
+
profile_default/
|
| 83 |
+
ipython_config.py
|
| 84 |
+
|
| 85 |
+
# pyenv
|
| 86 |
+
# For a library or package, you might want to ignore these files since the code is
|
| 87 |
+
# intended to run in multiple environments; otherwise, check them in:
|
| 88 |
+
# .python-version
|
| 89 |
+
|
| 90 |
+
# pipenv
|
| 91 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
| 92 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
| 93 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
| 94 |
+
# install all needed dependencies.
|
| 95 |
+
#Pipfile.lock
|
| 96 |
+
|
| 97 |
+
# poetry
|
| 98 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
| 99 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
| 100 |
+
# commonly ignored for libraries.
|
| 101 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
| 102 |
+
#poetry.lock
|
| 103 |
+
|
| 104 |
+
# pdm
|
| 105 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
| 106 |
+
#pdm.lock
|
| 107 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
| 108 |
+
# in version control.
|
| 109 |
+
# https://pdm.fming.dev/#use-with-ide
|
| 110 |
+
.pdm.toml
|
| 111 |
+
|
| 112 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
| 113 |
+
__pypackages__/
|
| 114 |
+
|
| 115 |
+
# Celery stuff
|
| 116 |
+
celerybeat-schedule
|
| 117 |
+
celerybeat.pid
|
| 118 |
+
|
| 119 |
+
# SageMath parsed files
|
| 120 |
+
*.sage.py
|
| 121 |
+
|
| 122 |
+
# Environments
|
| 123 |
+
.env
|
| 124 |
+
.venv
|
| 125 |
+
env/
|
| 126 |
+
venv/
|
| 127 |
+
ENV/
|
| 128 |
+
env.bak/
|
| 129 |
+
venv.bak/
|
| 130 |
+
|
| 131 |
+
# Spyder project settings
|
| 132 |
+
.spyderproject
|
| 133 |
+
.spyproject
|
| 134 |
+
|
| 135 |
+
# Rope project settings
|
| 136 |
+
.ropeproject
|
| 137 |
+
|
| 138 |
+
# mkdocs documentation
|
| 139 |
+
/site
|
| 140 |
+
|
| 141 |
+
# mypy
|
| 142 |
+
.mypy_cache/
|
| 143 |
+
.dmypy.json
|
| 144 |
+
dmypy.json
|
| 145 |
+
|
| 146 |
+
# Pyre type checker
|
| 147 |
+
.pyre/
|
| 148 |
+
|
| 149 |
+
# pytype static type analyzer
|
| 150 |
+
.pytype/
|
| 151 |
+
|
| 152 |
+
# Cython debug symbols
|
| 153 |
+
cython_debug/
|
| 154 |
+
|
| 155 |
+
# PyCharm
|
| 156 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
| 157 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
| 158 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
| 159 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
| 160 |
+
#.idea/
|
Dockerfile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
| 2 |
+
# you will also find guides on how best to write your Dockerfile
|
| 3 |
+
|
| 4 |
+
FROM python:3.10.5
|
| 5 |
+
|
| 6 |
+
# Set up a new user named "user" with user ID 1000
|
| 7 |
+
RUN useradd -m -u 1000 user
|
| 8 |
+
|
| 9 |
+
# Switch to the "user" user
|
| 10 |
+
USER user
|
| 11 |
+
|
| 12 |
+
# Set home to the user's home directory
|
| 13 |
+
ENV HOME=/home/user \
|
| 14 |
+
PATH=/home/user/.local/bin:$PATH
|
| 15 |
+
|
| 16 |
+
# Set the working directory to the user's home directory
|
| 17 |
+
WORKDIR $HOME/code
|
| 18 |
+
|
| 19 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 20 |
+
|
| 21 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 22 |
+
|
| 23 |
+
COPY . .
|
| 24 |
+
|
| 25 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
app/__init__.py
ADDED
|
File without changes
|
app/watermelon.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
from fastapi import APIRouter,WebSocket,WebSocketDisconnect
|
| 3 |
+
from fastapi.responses import FileResponse
|
| 4 |
+
import requests
|
| 5 |
+
import json
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
router = APIRouter(
|
| 9 |
+
prefix="/watermelon",
|
| 10 |
+
tags=["watermelon"],
|
| 11 |
+
)
|
| 12 |
+
game = "watermelon"
|
| 13 |
+
header = {'accept': 'application/json', 'Content-Type': 'application/json'}
|
| 14 |
+
url_base = "https://pgsoft-ai-patcher.hf.space/watermelon"
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
@router.get("/")
|
| 18 |
+
def index():
|
| 19 |
+
return FileResponse(path="static/watermelon/index.html", media_type="text/html")
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
@router.websocket("/ws")
|
| 23 |
+
async def websocket_endpoint(websocket: WebSocket):
|
| 24 |
+
await websocket.accept()
|
| 25 |
+
while True:
|
| 26 |
+
try:
|
| 27 |
+
data = await websocket.receive_json()
|
| 28 |
+
except WebSocketDisconnect:
|
| 29 |
+
continue
|
| 30 |
+
print(f"received data: {data}")
|
| 31 |
+
url = f"{url_base}/{data['url']}"
|
| 32 |
+
myobj = data["data"]
|
| 33 |
+
try:
|
| 34 |
+
res = requests.post(url, headers=header, json=myobj)
|
| 35 |
+
print(res.status_code)
|
| 36 |
+
await websocket.send_text(json.dumps(json.loads(res.text),indent=4))
|
| 37 |
+
except Exception as e:
|
| 38 |
+
res = {
|
| 39 |
+
"result": "Failure",
|
| 40 |
+
"detail": f"failed to request, {e}",
|
| 41 |
+
}
|
| 42 |
+
await websocket.send_text(json.dumps(res, indent=4))
|
| 43 |
+
|
main.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from fastapi.staticfiles import StaticFiles
|
| 3 |
+
from fastapi.responses import FileResponse
|
| 4 |
+
import uvicorn
|
| 5 |
+
from app import watermelon
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
app = FastAPI()
|
| 9 |
+
app.include_router(watermelon.router)
|
| 10 |
+
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
@app.get("/")
|
| 14 |
+
def index() -> FileResponse:
|
| 15 |
+
return FileResponse(path="static/index.html", media_type="text/html")
|
| 16 |
+
|
| 17 |
+
if __name__ == "__main__":
|
| 18 |
+
uvicorn.run(app, host="127.0.0.1", port=8000)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn[standard]
|
| 3 |
+
python-jose
|
static/index.css
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
input {
|
| 2 |
+
font-size: large;
|
| 3 |
+
width: 250px;
|
| 4 |
+
}
|
| 5 |
+
|
| 6 |
+
button {
|
| 7 |
+
font-size: large;
|
| 8 |
+
margin-top: 10px;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
select {
|
| 12 |
+
font-size: large;
|
| 13 |
+
width: 250px;
|
| 14 |
+
text-align: center;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
pre {
|
| 18 |
+
font-size: large;
|
| 19 |
+
border: 2px solid black;
|
| 20 |
+
border-radius: 3px;
|
| 21 |
+
background-color: silver;
|
| 22 |
+
height: 180px;
|
| 23 |
+
width: 100;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
a {
|
| 27 |
+
font-size: larger;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
div {
|
| 31 |
+
margin: 5px;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
.response {
|
| 35 |
+
width: 100%;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.target,
|
| 39 |
+
.command,
|
| 40 |
+
.number {
|
| 41 |
+
display: flex;
|
| 42 |
+
flex-direction: column;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
form{
|
| 46 |
+
display: flex;
|
| 47 |
+
flex-direction: column;
|
| 48 |
+
align-items: center;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
h1{
|
| 52 |
+
text-align: center;
|
| 53 |
+
}
|
static/index.html
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
|
| 4 |
+
<body>
|
| 5 |
+
<header>
|
| 6 |
+
<title>AI Patcher</title>
|
| 7 |
+
<h1 style="text-align: center;">AI Patcher</h1>
|
| 8 |
+
</header>
|
| 9 |
+
<div style="text-align: center;">
|
| 10 |
+
<a href="http://127.0.0.1:8000/watermelon/">Watermelon</a>
|
| 11 |
+
|
| 12 |
+
</div>
|
| 13 |
+
</body>
|
| 14 |
+
|
| 15 |
+
</html>
|
static/watermelon/delete_all_of_sth/index.html
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
|
| 4 |
+
<head>
|
| 5 |
+
<title>AI Patcher</title>
|
| 6 |
+
<link rel="stylesheet" type="text/css" href="../../index.css">
|
| 7 |
+
</head>
|
| 8 |
+
|
| 9 |
+
<body>
|
| 10 |
+
<h1>delete all of something</h1>
|
| 11 |
+
<form action="" onsubmit="sendMessage(event)">
|
| 12 |
+
<div class="command">
|
| 13 |
+
<label for="command">Command:</label>
|
| 14 |
+
<input type="text" id="command" name="command" required />
|
| 15 |
+
</div>
|
| 16 |
+
<div class="target">
|
| 17 |
+
<label for="target">Target:</label>
|
| 18 |
+
<select id="target" name="target" required>
|
| 19 |
+
<option value="fruit">fruit</option>
|
| 20 |
+
<option value="prop">prop</option>
|
| 21 |
+
<option value="swap card">swap card</option>
|
| 22 |
+
<option value="lightning">lightning</option>
|
| 23 |
+
<option value="bomb">bomb</option>
|
| 24 |
+
<option value="freeze">freeze</option>
|
| 25 |
+
</select>
|
| 26 |
+
</div>
|
| 27 |
+
<button>Send</button>
|
| 28 |
+
</form>
|
| 29 |
+
<div style="display: flex;">
|
| 30 |
+
<div class="response">
|
| 31 |
+
<label for="messages">Response:</label>
|
| 32 |
+
<pre id="messages"></pre>
|
| 33 |
+
</div>
|
| 34 |
+
</div>
|
| 35 |
+
<script src="index.js"></script>
|
| 36 |
+
</body>
|
| 37 |
+
|
| 38 |
+
</html>
|
static/watermelon/delete_all_of_sth/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// delete_all_of_sth
|
| 2 |
+
var ws = new WebSocket("ws://localhost:8000/watermelon/ws");
|
| 3 |
+
ws.onmessage = function (event) {
|
| 4 |
+
var messages = document.getElementById('messages')
|
| 5 |
+
messages.innerText = event.data
|
| 6 |
+
};
|
| 7 |
+
function sendMessage(event) {
|
| 8 |
+
var command = document.getElementById("command")
|
| 9 |
+
var target = document.getElementById("target")
|
| 10 |
+
|
| 11 |
+
var myobj = {
|
| 12 |
+
url: "delete_all_of_sth",
|
| 13 |
+
data: {
|
| 14 |
+
command: command.value,
|
| 15 |
+
target: target.value,
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
ws.send(JSON.stringify(myobj))
|
| 19 |
+
event.preventDefault()
|
| 20 |
+
}
|
static/watermelon/help/index.html
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
|
| 4 |
+
<head>
|
| 5 |
+
<title>AI Patcher</title>
|
| 6 |
+
<link rel="stylesheet" type="text/css" href="../../index.css">
|
| 7 |
+
</head>
|
| 8 |
+
|
| 9 |
+
<body>
|
| 10 |
+
<h1>help</h1>
|
| 11 |
+
<form action="" onsubmit="sendMessage(event)">
|
| 12 |
+
<div class="command">
|
| 13 |
+
<label for="command">Command:</label>
|
| 14 |
+
<input type="text" id="command" name="command" required />
|
| 15 |
+
</div>
|
| 16 |
+
<button>Send</button>
|
| 17 |
+
</form>
|
| 18 |
+
<div style="display: flex;">
|
| 19 |
+
<div class="response">
|
| 20 |
+
<label for="messages">Response:</label>
|
| 21 |
+
<pre id="messages"></pre>
|
| 22 |
+
</div>
|
| 23 |
+
</div>
|
| 24 |
+
<script src="index.js"></script>
|
| 25 |
+
</body>
|
| 26 |
+
|
| 27 |
+
</html>
|
static/watermelon/help/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// help
|
| 2 |
+
var ws = new WebSocket("ws://localhost:8000/watermelon/ws");
|
| 3 |
+
ws.onmessage = function (event) {
|
| 4 |
+
var messages = document.getElementById('messages')
|
| 5 |
+
messages.innerText = event.data
|
| 6 |
+
};
|
| 7 |
+
function sendMessage(event) {
|
| 8 |
+
var input = document.getElementById("command")
|
| 9 |
+
|
| 10 |
+
var myobj = {
|
| 11 |
+
url: "help",
|
| 12 |
+
data: {
|
| 13 |
+
command: input.value
|
| 14 |
+
}
|
| 15 |
+
}
|
| 16 |
+
ws.send(JSON.stringify(myobj))
|
| 17 |
+
event.preventDefault()
|
| 18 |
+
}
|
static/watermelon/index.html
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
|
| 4 |
+
<head>
|
| 5 |
+
<title>AI Patcher</title>
|
| 6 |
+
<h1 style="text-align: center;">AI Patcher for Watermelon</h1>
|
| 7 |
+
<link rel="stylesheet" type="text/css" href="../index.css">
|
| 8 |
+
</head>
|
| 9 |
+
|
| 10 |
+
<body>
|
| 11 |
+
<div style="display: flex;flex-direction: column;align-items: center;">
|
| 12 |
+
<div style="display:flex;flex-direction: column;">
|
| 13 |
+
<a href="http://127.0.0.1:8000/watermelon/help/index.html">help</a>
|
| 14 |
+
<a href="http://127.0.0.1:8000/watermelon/reset_game/index.html">reset_game</a>
|
| 15 |
+
<a href="http://127.0.0.1:8000/watermelon/set_number_of_sth/index.html">set_number_of_sth</a>
|
| 16 |
+
</div>
|
| 17 |
+
</div>
|
| 18 |
+
<script src="index.js"></script>
|
| 19 |
+
</body>
|
| 20 |
+
|
| 21 |
+
</html>
|
static/watermelon/index.js
ADDED
|
File without changes
|
static/watermelon/reset_game/index.html
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
|
| 4 |
+
<head>
|
| 5 |
+
<title>AI Patcher</title>
|
| 6 |
+
<link rel="stylesheet" type="text/css" href="../../index.css">
|
| 7 |
+
</head>
|
| 8 |
+
|
| 9 |
+
<body>
|
| 10 |
+
<h1>reset game</h1>
|
| 11 |
+
<form action="" onsubmit="sendMessage(event)">
|
| 12 |
+
<div class="command">
|
| 13 |
+
<label for="command">Command:</label>
|
| 14 |
+
<input type="text" id="command" name="command" required />
|
| 15 |
+
</div>
|
| 16 |
+
<button>Send</button>
|
| 17 |
+
</form>
|
| 18 |
+
<div style="display: flex;">
|
| 19 |
+
<div class="response">
|
| 20 |
+
<label for="messages">Response:</label>
|
| 21 |
+
<pre id="messages"></pre>
|
| 22 |
+
</div>
|
| 23 |
+
</div>
|
| 24 |
+
<script src="index.js"></script>
|
| 25 |
+
</body>
|
| 26 |
+
|
| 27 |
+
</html>
|
static/watermelon/reset_game/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// reset_game
|
| 2 |
+
var ws = new WebSocket("ws://localhost:8000/watermelon/ws");
|
| 3 |
+
ws.onmessage = function (event) {
|
| 4 |
+
var messages = document.getElementById('messages')
|
| 5 |
+
messages.innerText = event.data
|
| 6 |
+
};
|
| 7 |
+
function sendMessage(event) {
|
| 8 |
+
var input = document.getElementById("command")
|
| 9 |
+
|
| 10 |
+
var myobj = {
|
| 11 |
+
url: "reset_game",
|
| 12 |
+
data: {
|
| 13 |
+
command: input.value
|
| 14 |
+
}
|
| 15 |
+
}
|
| 16 |
+
ws.send(JSON.stringify(myobj))
|
| 17 |
+
event.preventDefault()
|
| 18 |
+
}
|
static/watermelon/set_number_of_sth/index.html
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
|
| 4 |
+
<head>
|
| 5 |
+
<title>AI Patcher</title>
|
| 6 |
+
<link rel="stylesheet" type="text/css" href="../../index.css">
|
| 7 |
+
</head>
|
| 8 |
+
|
| 9 |
+
<body>
|
| 10 |
+
<h1>set number of something</h1>
|
| 11 |
+
<form action="" onsubmit="sendMessage(event)">
|
| 12 |
+
<div class="command">
|
| 13 |
+
<label for="command">Command:</label>
|
| 14 |
+
<input type="text" id="command" name="command" required />
|
| 15 |
+
</div>
|
| 16 |
+
<div class="target">
|
| 17 |
+
<label for="target">Target:</label>
|
| 18 |
+
<select id="target" name="target" required>
|
| 19 |
+
<option value="fruit">fruit</option>
|
| 20 |
+
<option value="prop">prop</option>
|
| 21 |
+
<option value="swap card">swap card</option>
|
| 22 |
+
<option value="lightning">lightning</option>
|
| 23 |
+
<option value="bomb">bomb</option>
|
| 24 |
+
<option value="freeze">freeze</option>
|
| 25 |
+
</select>
|
| 26 |
+
</div>
|
| 27 |
+
<div class="number">
|
| 28 |
+
<label for="number">Number:</label>
|
| 29 |
+
<input type="number" id="number" name="number" required />
|
| 30 |
+
</div>
|
| 31 |
+
<button>Send</button>
|
| 32 |
+
</form>
|
| 33 |
+
<div style="display: flex;">
|
| 34 |
+
<div class="response">
|
| 35 |
+
<label for="messages">Response:</label>
|
| 36 |
+
<pre id="messages"></pre>
|
| 37 |
+
</div>
|
| 38 |
+
</div>
|
| 39 |
+
<script src="index.js"></script>
|
| 40 |
+
</body>
|
| 41 |
+
|
| 42 |
+
</html>
|
static/watermelon/set_number_of_sth/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// set_number_of_sth
|
| 2 |
+
var ws = new WebSocket("ws://localhost:8000/watermelon/ws");
|
| 3 |
+
ws.onmessage = function (event) {
|
| 4 |
+
var messages = document.getElementById('messages')
|
| 5 |
+
messages.innerText = event.data
|
| 6 |
+
};
|
| 7 |
+
function sendMessage(event) {
|
| 8 |
+
var command = document.getElementById("command")
|
| 9 |
+
var target = document.getElementById("target")
|
| 10 |
+
var number = document.getElementById("number")
|
| 11 |
+
|
| 12 |
+
var myobj = {
|
| 13 |
+
url: "set_number_of_sth",
|
| 14 |
+
data: {
|
| 15 |
+
command: command.value,
|
| 16 |
+
target: target.value,
|
| 17 |
+
integer: number.value
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
ws.send(JSON.stringify(myobj))
|
| 21 |
+
event.preventDefault()
|
| 22 |
+
}
|