diff --git a/base/static/css/main.css b/base/static/css/main.css index 80a38b2..3f13bbc 100644 --- a/base/static/css/main.css +++ b/base/static/css/main.css @@ -17,7 +17,7 @@ form a[role="button"] { width: 100%; } -i.owner { +i.owner, .gold { color: var(--pico-color-amber-200); } @@ -160,10 +160,28 @@ table select { color: var(--pico-color-sand-300); } } - .score { - font-weight: 900; - color: var(--pico-color-zinc-500); margin-left: .5em; } } + + +.score { + font-weight: 900; + color: var(--pico-color-zinc-500); +} +.correct { + .score, i { + color: var(--pico-color-lime-200);} +} +.wrong { + .score, i { + color: var(--pico-color-red-500);} +} + +table.results { + white-space: nowrap; +} +.sc i { + margin-right: .5em; +} diff --git a/game/templates/game/include/game_results.html b/game/templates/game/include/game_results.html new file mode 100644 index 0000000..0f03b99 --- /dev/null +++ b/game/templates/game/include/game_results.html @@ -0,0 +1,49 @@ +{% load game %} +{% if musikgame.over %} +

+ Résultats +

+
+ + Résultats + +
+ + + + + + + {% for player in musikgame.musicgameresults_set.all %} + + + {% endfor %} + + + + {% for music in musikgame.musicgameorder_set.all %} + + + + + {% for player in musikgame.musicgameresults_set.all %} + {% answer player music %} + {% endfor %} + + {% endfor %} + +
+ + + Musique + + Joueur + {{ player.player.username }} + {% if forloop.first %}{% endif %} + {{ player.score }} +
{{ music.order }} + {{ music.music_video.title }} + {{ music.player }}
+
+
+{% endif %} diff --git a/game/templates/game/musikgame_detail.html b/game/templates/game/musikgame_detail.html index 4130ef3..0df1510 100644 --- a/game/templates/game/musikgame_detail.html +++ b/game/templates/game/musikgame_detail.html @@ -63,40 +63,5 @@ {% endfor %} - {% if musikgame.over %} -

- Résultats -

-
- - Résultats - - - - - - - - - - - {% for music in musikgame.musicgameorder_set.all %} - - - - - - {% endfor %} - -
- - - Musique - - Joueur -
{{ music.order }} - {{ music.music_video.title }} - {{ music.player }}
-
- {% endif %} + {% include "game/include/game_results.html" %} {% endblock content %} diff --git a/game/templates/tags/game/answer.html b/game/templates/tags/game/answer.html new file mode 100644 index 0000000..bfdeba5 --- /dev/null +++ b/game/templates/tags/game/answer.html @@ -0,0 +1,16 @@ +{% if empty %} + + + {{ score }} + +{% elif correct %} + {{ answer }} + + {{ score }} + +{% else %} + {{ answer }} + + {{ score }} + +{% endif %} diff --git a/game/templatetags/game.py b/game/templatetags/game.py new file mode 100644 index 0000000..eec1bd0 --- /dev/null +++ b/game/templatetags/game.py @@ -0,0 +1,30 @@ +from django import template + +from .. import models + +register = template.Library() + + +@register.inclusion_tag("tags/game/answer.html") +def answer(player, music): + res = { + "answer": "", + "correct": False, + "score": 0, + "empty": False, + } + + answer = models.MusicGameAnswer.objects.filter( + player=player.player, game=music + ).first() + if answer: + res["answer"] = answer.answer + res["correct"] = answer.answer == music.player + if music.player == player.player: + res["score"] = 0 if res["correct"] else "−500" + else: + res["score"] = music.value if res["correct"] else 0 + else: + res["empty"] = True + + return res