diff --git a/orochi/bot.py b/orochi/bot.py index 28fb262..cd5cfc4 100644 --- a/orochi/bot.py +++ b/orochi/bot.py @@ -3,6 +3,7 @@ from disnake import CategoryChannel, PermissionOverwrite, TextChannel from disnake.ext import commands import logging +from orochi import http from orochi.config import Config from orochi.models import Game @@ -221,6 +222,8 @@ class Confirm(disnake.ui.View): def run(): config = Config.load() + http.run_web_server() + logger = logging.getLogger('discord') logger.setLevel(logging.DEBUG) handler = logging.FileHandler(filename='../discord.log', encoding='utf-8', mode='w') diff --git a/orochi/http.py b/orochi/http.py new file mode 100644 index 0000000..5f6e46c --- /dev/null +++ b/orochi/http.py @@ -0,0 +1,23 @@ +from threading import Thread + +from flask import Flask, render_template + +from orochi.models import Game + +app = Flask(__name__) + + +@app.route('/') +def index(): + game = Game.INSTANCE + return render_template('list.html', game=game) + + +@app.route('/admin') +def admin(): + game = Game.INSTANCE + return render_template('list.html', game=game, admin=True) + + +def run_web_server(): + Thread(target=lambda: app.run(debug=True, use_reloader=False)).start() diff --git a/orochi/models.py b/orochi/models.py index f9c80ab..2f659b8 100644 --- a/orochi/models.py +++ b/orochi/models.py @@ -68,7 +68,7 @@ class RoundVote: @property def room(self): - for r in Game.rounds: + for r in Game.INSTANCE.rounds: for room in r.rooms: if self in room.votes: return room @@ -126,11 +126,11 @@ class Game: vote1=RoundVote(player1=self.players['Tora']), vote2=RoundVote(player1=self.players['Kamui'], player2=self.players['Philia'])), - room_b=RoundRoom(room=Room.A, + room_b=RoundRoom(room=Room.B, vote1=RoundVote(player1=self.players['Dan']), vote2=RoundVote(player1=self.players['Ennea'], player2=self.players['Delphine'])), - room_c=RoundRoom(room=Room.A, + room_c=RoundRoom(room=Room.C, vote1=RoundVote(player1=self.players['Hanabi']), vote2=RoundVote(player1=self.players['Nona'], player2=self.players['Oji'])), diff --git a/orochi/templates/list.html b/orochi/templates/list.html new file mode 100644 index 0000000..a3a10b0 --- /dev/null +++ b/orochi/templates/list.html @@ -0,0 +1,74 @@ + + + + Zero Escape: Radical Outcome + + + + + +

Scores Nonary Game: Ambidex Edition

+ +

Tableau des scores

+ + + + + + + + + + {% for player in game.players.values() %} + + + + + {% endfor %} + +
JoueurScore
{{ player.name }}{{ player.score }}
+ +

Récapitulatif par tour

+ + {% for round in game.rounds %} +

Tour n°{{ round.round }}

+ + + + + + + + + + + + {% for room in round.rooms %} + {% for vote in room.votes %} + + {% if loop.index0 == 0 %} + + {% endif %} + + {% if round.round != game.rounds|length or admin %} + + {% else %} + + {% endif %} + + + {% endfor %} + {% endfor %} + +
SalleÉquipesVote
{{ room.room.value }}{{ vote.player1.name }}{% if vote.player2 %}, {{ vote.player2.name }}{% endif %}{{ room.vote1.vote.value|default('Pas de vote') }}Vote en cours ...
+ {% endfor %} + + \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 95493ac..a926517 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ disnake +flask pyyaml