Compare commits
4 Commits
adcda176cc
...
dd91a8723b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd91a8723b | ||
|
|
975e813947 | ||
|
|
467b7d4706 | ||
|
|
14075ee2a3 |
9
app.py
9
app.py
@@ -189,17 +189,14 @@ class Room:
|
|||||||
rooms: dict[str, Room] = {}
|
rooms: dict[str, Room] = {}
|
||||||
|
|
||||||
|
|
||||||
API_ROOT = "http://127.0.0.1:8989"
|
|
||||||
|
|
||||||
|
|
||||||
@app.GET("/")
|
@app.GET("/")
|
||||||
async def home(request):
|
async def home(request):
|
||||||
return render(request, "index.html", {"API_ROOT": API_ROOT})
|
return render(request, "index.html")
|
||||||
|
|
||||||
|
|
||||||
@app.GET("/<id>")
|
@app.GET("/<id>")
|
||||||
async def home_with_id(request, id):
|
async def home_with_id(request, id):
|
||||||
return render(request, "index.html", {"API_ROOT": API_ROOT})
|
return render(request, "index.html")
|
||||||
|
|
||||||
|
|
||||||
@app.POST("/join/<room_id>")
|
@app.POST("/join/<room_id>")
|
||||||
@@ -331,9 +328,7 @@ def get_piece_moves(piece_kind, board: Board, is_white, src: str) -> list[Coord]
|
|||||||
def generate_valid_moves(
|
def generate_valid_moves(
|
||||||
piece_kind: str, board: Board, is_white: bool, src: str
|
piece_kind: str, board: Board, is_white: bool, src: str
|
||||||
) -> list[Coord]:
|
) -> list[Coord]:
|
||||||
print(" -- FIRST ORDER ---------------------------")
|
|
||||||
possible_moves: list[Coord] = get_piece_moves(piece_kind, board, is_white, src)
|
possible_moves: list[Coord] = get_piece_moves(piece_kind, board, is_white, src)
|
||||||
print(" -- FIRST ORDER ---------------------------")
|
|
||||||
valids: list[Coord] = []
|
valids: list[Coord] = []
|
||||||
king: Coord
|
king: Coord
|
||||||
for i in range(8):
|
for i in range(8):
|
||||||
|
|||||||
@@ -162,7 +162,7 @@
|
|||||||
|
|
||||||
selected = [i, j];
|
selected = [i, j];
|
||||||
moves = [];
|
moves = [];
|
||||||
fetch('{{ API_ROOT }}/moves/' + ROOM_ID, {
|
fetch('/moves/' + ROOM_ID, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -182,7 +182,7 @@
|
|||||||
moves.forEach(move => {
|
moves.forEach(move => {
|
||||||
console.log(move);
|
console.log(move);
|
||||||
if (move[0] == i && move[1] == j) {
|
if (move[0] == i && move[1] == j) {
|
||||||
fetch('{{ API_ROOT }}/move/' + ROOM_ID, {
|
fetch('/move/' + ROOM_ID, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -208,7 +208,7 @@
|
|||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
if (ROOM_ID) {
|
if (ROOM_ID) {
|
||||||
fetch('{{ API_ROOT }}/poll/' + ROOM_ID, {
|
fetch('/poll/' + ROOM_ID, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
@@ -240,7 +240,7 @@
|
|||||||
|
|
||||||
function join(rid) {
|
function join(rid) {
|
||||||
if (rid.length > 0 && /^[a-zA-Z0-9_-]+$/.test(rid)) {
|
if (rid.length > 0 && /^[a-zA-Z0-9_-]+$/.test(rid)) {
|
||||||
fetch('{{ API_ROOT }}/join/' + rid, {
|
fetch('/join/' + rid, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
|
|||||||
2
libs
2
libs
Submodule libs updated: 4e04784f9b...dd648bc50f
Reference in New Issue
Block a user