Updated some stuff
This commit is contained in:
parent
168538a6fd
commit
a7ff4f2a3d
12
README.md
12
README.md
@ -11,8 +11,16 @@ This is the platform from which one can host any "game" that they have defined.
|
||||
* Developed protocols, which clients can use.
|
||||
|
||||
## TODOs
|
||||
* [ ] Create websocket server
|
||||
* [ ] Implement the description of the protocol from the client(s)
|
||||
* Web server
|
||||
* [ ] Figure out some sort of identification that is not external IP(cuz that's dumb)
|
||||
* [ ] Hand it out
|
||||
* [ ] Start accepting requests to the websocket server ONLY to the users who have joined the game
|
||||
|
||||
* Websocket server
|
||||
* [ ] Ping players while waiting for people
|
||||
* Game creation
|
||||
* [ ] Rules exchange -> Have to think about that one lol
|
||||
* [ ] Game start
|
||||
|
||||
## Flowcharts
|
||||
### Creation
|
||||
|
14
src/app.py
14
src/app.py
@ -1,7 +1,11 @@
|
||||
from flask import Flask, render_template, request, redirect, url_for, flash, session
|
||||
from flask import Flask, render_template, request, redirect, url_for, flash, session, jsonify
|
||||
from uuid import uuid4
|
||||
from .classes import Game
|
||||
from flask_socketio import SocketIO
|
||||
import json
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config['SECRET_KEY'] = 'DEV'
|
||||
socketio = SocketIO(app)
|
||||
|
||||
|
||||
def find_game_by_id(id:str) -> dict:
|
||||
@ -24,7 +28,7 @@ def start_game(game:dict):
|
||||
def index():
|
||||
return "Empty for now"
|
||||
|
||||
@app.route('/new/<str:name>/<int:players>', methods=['POST'])
|
||||
@app.route('/new/<string:name>/<int:players>', methods=['POST'])
|
||||
def new_game(name, players):
|
||||
# Log new game into json file and return a websocket url for the game
|
||||
games = []
|
||||
@ -46,6 +50,8 @@ def new_game(name, players):
|
||||
with open('games.json', 'w') as f:
|
||||
json.dump(games, f)
|
||||
|
||||
return jsonify(game)
|
||||
|
||||
|
||||
@app.route('/join/<uuid:game_id>', methods=['POST'])
|
||||
def join_game(game_id):
|
||||
@ -77,5 +83,7 @@ def join_game(game_id):
|
||||
with open('games.json', 'w') as f:
|
||||
json.dump(games, f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
socketio.run(app, debug=True)
|
||||
|
||||
|
||||
|
1
src/tests/create_game.http
Normal file
1
src/tests/create_game.http
Normal file
@ -0,0 +1 @@
|
||||
POST http://127.0.0.1:5000/new/game/2
|
Loading…
x
Reference in New Issue
Block a user