Paweł Łaba
commited on
Commit
·
ecea336
1
Parent(s):
8b32461
zmiana dodanie opcji zapisu
Browse files- app.py +2 -2
- public/script.js +3 -2
app.py
CHANGED
@@ -96,14 +96,14 @@ async def save_game(request: Request):
|
|
96 |
}
|
97 |
|
98 |
try:
|
99 |
-
with open("public/
|
100 |
existing_data = json.load(f)
|
101 |
except (FileNotFoundError, json.JSONDecodeError):
|
102 |
existing_data = []
|
103 |
|
104 |
existing_data.append(game_data)
|
105 |
|
106 |
-
with open("public/
|
107 |
json.dump(existing_data, f)
|
108 |
|
109 |
return {"status": "success", "hash": game_data["hash"]}
|
|
|
96 |
}
|
97 |
|
98 |
try:
|
99 |
+
with open("public/games_data.json", "r") as f:
|
100 |
existing_data = json.load(f)
|
101 |
except (FileNotFoundError, json.JSONDecodeError):
|
102 |
existing_data = []
|
103 |
|
104 |
existing_data.append(game_data)
|
105 |
|
106 |
+
with open("public/games_data.json", "w") as f:
|
107 |
json.dump(existing_data, f)
|
108 |
|
109 |
return {"status": "success", "hash": game_data["hash"]}
|
public/script.js
CHANGED
@@ -115,9 +115,10 @@ async function handleMove(index) {
|
|
115 |
|
116 |
// Ruch gracza
|
117 |
board[index] = -1;
|
118 |
-
updateBoardDisplay();
|
119 |
// dodaj gkrok do historii
|
120 |
-
step.push(index);
|
|
|
|
|
121 |
|
122 |
if (checkWin(board)) return;
|
123 |
|
|
|
115 |
|
116 |
// Ruch gracza
|
117 |
board[index] = -1;
|
|
|
118 |
// dodaj gkrok do historii
|
119 |
+
step.push(index);
|
120 |
+
updateBoardDisplay();
|
121 |
+
|
122 |
|
123 |
if (checkWin(board)) return;
|
124 |
|