mirror of
https://github.com/AudebertAdrien/ft_transcendence.git
synced 2026-11-09 18:27:06 +01:00
merging with branch: yannick
This commit is contained in:
@@ -182,4 +182,4 @@ class Game:
|
||||
# match type: 'tournament'
|
||||
# -> tournament id
|
||||
|
||||
#endfortheouche(p1, p2, s_p1, s_p2, bt_p1, bt_p2, dur, is_tournoi, name_tournament)
|
||||
#endfortheouche(p1, p2, s_p1, s_p2, bt_p1, bt_p2, dur, is_tournoi, name_tournament)
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
# Generated by Django 5.0.7 on 2024-07-24 16:21
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('game', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='best_score',
|
||||
field=models.PositiveSmallIntegerField(default=0),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='m_duration',
|
||||
field=models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='m_nbr_ball_touch',
|
||||
field=models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='m_score_adv_match',
|
||||
field=models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='m_score_match',
|
||||
field=models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='num_participated_tournaments',
|
||||
field=models.PositiveSmallIntegerField(default=0),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='num_won_tournaments',
|
||||
field=models.PositiveSmallIntegerField(default=0),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='p_win',
|
||||
field=models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='total_duration',
|
||||
field=models.DurationField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='total_match',
|
||||
field=models.PositiveSmallIntegerField(default=0),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='total_win',
|
||||
field=models.PositiveSmallIntegerField(default=0),
|
||||
),
|
||||
]
|
||||
@@ -48,4 +48,4 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -50,4 +50,4 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -34,4 +34,4 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -3,6 +3,7 @@ from django.core.exceptions import ValidationError
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.db.models import Max, Sum, F
|
||||
from datetime import timedelta
|
||||
<<<<<<< HEAD
|
||||
from channels.db import database_sync_to_async
|
||||
|
||||
async def endfortheouche(p1, p2, s_p1, s_p2, bt_p1, bt_2, dur, is_tournoi, name_tournament):
|
||||
@@ -26,6 +27,26 @@ async def endfortheouche(p1, p2, s_p1, s_p2, bt_p1, bt_2, dur, is_tournoi, name_
|
||||
await uptdate_player_statistics(p2)
|
||||
|
||||
@database_sync_to_async
|
||||
=======
|
||||
|
||||
def endfortheouche(p1, p2, s_p1, s_p2, winner, bt_p1, bt_p2, dur, is_tournoi, name_tournament) :
|
||||
#If he doesn't exist, create player p1
|
||||
if not Player.objects.filter(name=p1).exist():
|
||||
create_player(p1)
|
||||
|
||||
#If he doesn't exist, create player p2
|
||||
if not Player.objects.filter(name=p2).exist():
|
||||
create_player(p2)
|
||||
|
||||
#create Match
|
||||
create_match(p1, p2, s_p1, s_p2, bt_p1, bt_p2, dur, is_tournoi, name_tournamenttournoi)
|
||||
|
||||
#Update data p1 et p2
|
||||
uptdate_player_statistics(p1)
|
||||
uptdate_player_statistics(p2)
|
||||
|
||||
|
||||
>>>>>>> f31331d344927dfd9bca940943bdba9a4d79a2b4
|
||||
def create_player(
|
||||
name,
|
||||
total_match=0,
|
||||
@@ -60,13 +81,19 @@ def create_player(
|
||||
player.save()
|
||||
return player
|
||||
|
||||
<<<<<<< HEAD
|
||||
@database_sync_to_async
|
||||
=======
|
||||
>>>>>>> f31331d344927dfd9bca940943bdba9a4d79a2b4
|
||||
def create_tournoi(name, nbr_player, date, winner):
|
||||
tournoi = Tournoi(name=name, nbr_player=nbr_player, date=date, winner=winner)
|
||||
tournoi.save()
|
||||
return tournoi
|
||||
|
||||
<<<<<<< HEAD
|
||||
@database_sync_to_async
|
||||
=======
|
||||
>>>>>>> f31331d344927dfd9bca940943bdba9a4d79a2b4
|
||||
def create_match(player1, player2, score_player1, score_player2, nbr_ball_touch_p1, nbr_ball_touch_p2, duration, is_tournoi, tournoi):
|
||||
match = Match(
|
||||
player1=player1,
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
|
||||
from django.shortcuts import render
|
||||
|
||||
<<<<<<< HEAD
|
||||
def index(request):
|
||||
return render(request, 'index.html')
|
||||
|
||||
=======
|
||||
>>>>>>> f31331d344927dfd9bca940943bdba9a4d79a2b4
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from .models import Player, Tournoi, Match
|
||||
from .utils import create_player, create_tournoi, create_match
|
||||
@@ -15,6 +18,11 @@ from django.views.decorators.csrf import csrf_exempt
|
||||
import json
|
||||
import uuid
|
||||
|
||||
|
||||
def index(request):
|
||||
return render(request, 'index.html')
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
def register_user(request):
|
||||
if request.method == 'POST':
|
||||
@@ -199,4 +207,4 @@ def tournoi_list(request):
|
||||
tournois = Tournoi.objects.select_related('winner').all()
|
||||
return render(request, 'pong/tournoi_list.html', {'tournois': tournois})
|
||||
|
||||
####################### THEOUCHE PART ############################
|
||||
####################### THEOUCHE PART ############################
|
||||
|
||||
Reference in New Issue
Block a user