Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Lint

on: push

jobs:
run-linters:
name: Run linters
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install Python dependencies
run: pip install black mypy && ls && pip install -r requirements.txt

- name: Run linters
uses: wearerequired/lint-action@v1
with:
github_token: ${{ secrets.github_token }}
# Enable linters
black: true
mypy: true
auto_fix: true
mypy_args: "--ignore-missing-imports"
Empty file added Exceptions/__init__.py
Empty file.
10 changes: 5 additions & 5 deletions Exceptions/user_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

class UserError(Exception):
class ErrorType(Enum):
GENERIC_ERROR = 0,
INVALID_NAME = 1,
INVALID_GAME = 2,
INVALID_DELETION = 3,
INVALID_GAME_DELETION = 4,
GENERIC_ERROR = (0,)
INVALID_NAME = (1,)
INVALID_GAME = (2,)
INVALID_DELETION = (3,)
INVALID_GAME_DELETION = (4,)

def __init__(self, message, error_type=ErrorType.GENERIC_ERROR):
self.message = message
Expand Down
41 changes: 26 additions & 15 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,49 @@
from mod_test.test import mod_test
from flask import send_from_directory

if __name__ != '__main__':
if __name__ != "__main__":
import sys
import os
if os.path.split(sys.argv[0])[1].replace('.py', '') == __name__:
raise ImportError('No. Please do not import app. It will lead too all kinds of ridiculous stuff.')

if os.path.split(sys.argv[0])[1].replace(".py", "") == __name__:
raise ImportError(
"No. Please do not import app. It will lead too all kinds of ridiculous stuff."
)

import globals

app = globals.app

print('starting...')
print("starting...")


@app.route('/io')
@app.route("/io")
def hello_world():
return render_template('test_io.html')
return render_template("test_io.html")


@app.route('/favicon.ico')
@app.route("/favicon.ico")
def favicon():
import os
return send_from_directory(os.path.join(app.root_path, 'static'),
'favicon.ico',mimetype='image/vnd.microsoft.icon')

@app.route('/instruction')
return send_from_directory(
os.path.join(app.root_path, "static"),
"favicon.ico",
mimetype="image/vnd.microsoft.icon",
)


@app.route("/instruction")
def rules():
return render_template('instruction.html')
return render_template("instruction.html")


@app.route('/glossary')
@app.route("/glossary")
def glossary():
return render_template('glossary.html')
return render_template("glossary.html")


if True or __name__ == '__main__':
if True or __name__ == "__main__":
# Registering socketio listeners
import mod_game.waitroom
import mod_game.game_state
Expand All @@ -49,5 +60,5 @@ def glossary():
app.register_blueprint(mod_game_wr)
app.register_blueprint(mod_game_process)
app.register_blueprint(mod_test, url_prefix="/test")
if __name__ == '__main__':
if __name__ == "__main__":
globals.socketio.run(app)
14 changes: 10 additions & 4 deletions connection_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
from utils.socketio_helper import commit_and_notify_if_dirty


@socketio.on('disconnect')
@socketio.on("disconnect")
def on_disconnect():
change_state(False)


@socketio.on('connect')
@socketio.on("connect")
def on_connect():
change_state(True)

Expand Down Expand Up @@ -44,10 +44,16 @@ def change_state(is_online: bool):
def change_admin(is_online: bool, player: PlayerLogic):
if not is_online and player.model.isAdmin:
gm = GameManager(db)
new_adm = next((p.model for p in gm.get_my_game().get_players(True) if (not p.model.isAdmin and p.model.isOnline)), None)
new_adm = next(
(
p.model
for p in gm.get_my_game().get_players(True)
if (not p.model.isAdmin and p.model.isOnline)
),
None,
)
if new_adm is not None:
new_adm.isAdmin = True
player.model.isAdmin = False
db.session.commit()
gm.get_my_game().notify()

Loading