-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create game function; use jinja2 templates for html
- Loading branch information
Showing
22 changed files
with
1,034 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,3 @@ You will need a python3.10+ | |
3. Hit `uvicorn main:app --reload` | ||
4. ... | ||
5. Profit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const POSSIBLE_PLAYERS = [ | ||
{'id': '09eabde7-3a21-43f6-b197-c75452e7c214', 'name': 'Саша', 'points': 0, 'current_break': 0, 'max_break': 0}, | ||
{'id': '1d5dd8e0-b411-43ac-a872-25747fce3c12', 'name': 'Сергей', 'points': 0, 'current_break': 0, 'max_break': 0}, | ||
{'id': '578137b1-b118-4a9d-85b0-b5a108b5e333', 'name': 'Гузель', 'points': 0, 'current_break': 0, 'max_break': 0}, | ||
] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const SnookerScoreKeeperNewGameForm = { | ||
delimiters: ["[[", "]]"], | ||
mounted () { | ||
M.AutoInit() | ||
const modals = document.querySelectorAll('.modal'); | ||
M.Modal.init(modals, {}); | ||
}, | ||
created() { | ||
const app = this; | ||
}, | ||
data() { | ||
return { | ||
selectedPlayers: [], | ||
errorMessage: '' | ||
} | ||
}, | ||
methods: { | ||
sendForm() { | ||
const app = this | ||
this.errorMessage = '' | ||
if (this.selectedPlayers.length < 2) { | ||
this.errorMessage = 'нужно выбрать хотя бы двух игроков' | ||
return | ||
} | ||
|
||
const playerIndices = []; | ||
for (var idx in POSSIBLE_PLAYERS) { | ||
player = POSSIBLE_PLAYERS[idx] | ||
if (this.selectedPlayers.includes(player.id)) { | ||
playerIndices.push(String(idx)) | ||
} | ||
} | ||
const pset = playerIndices.join(''); | ||
|
||
const fetch_options = { | ||
method: "POST", | ||
cache: "no-cache", | ||
headers: { | ||
"Content-Type": "application/json", | ||
} | ||
} | ||
|
||
fetch('/create-new-game/', fetch_options) | ||
.then(response => response.json()) | ||
.then(result => { | ||
window.location.href = `/play/?gid=${result.game_id}&pset=${pset}` | ||
}) | ||
.catch((error) => { | ||
app.errorMessage = 'не удалось создать игру' | ||
console.log(error) | ||
}); | ||
} | ||
} | ||
} | ||
|
||
Vue.createApp(SnookerScoreKeeperNewGameForm).mount('#new-game-form') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ dataclasses-json==0.5.7 | |
fastapi==0.95.1 | ||
uvicorn==0.21.1 | ||
websockets==11.0.2 | ||
Jinja2==3.1.2 |
22 changes: 22 additions & 0 deletions
22
server/data/results/result_113d99eb-7775-4062-9693-53780f130ef3.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"game_id": "113d99eb-7775-4062-9693-53780f130ef3", | ||
"game_date": 1682317664.058284, | ||
"player_stats": [ | ||
{ | ||
"id": "09eabde7-3a21-43f6-b197-c75452e7c214", | ||
"name": "Саша", | ||
"points": 53, | ||
"max_break": 0, | ||
"current_break": 0, | ||
"fouls": 0 | ||
}, | ||
{ | ||
"id": "578137b1-b118-4a9d-85b0-b5a108b5e333", | ||
"name": "Гузель", | ||
"points": 20, | ||
"max_break": 0, | ||
"current_break": 0, | ||
"fouls": 0 | ||
} | ||
] | ||
} |
Oops, something went wrong.