diff --git a/.idea/ft-transcendence.iml b/.idea/ft-transcendence.iml
new file mode 100644
index 00000000..1edba38c
--- /dev/null
+++ b/.idea/ft-transcendence.iml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 00000000..92db1df4
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 00000000..105ce2da
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..86abaf79
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/API/API/settings.py b/API/API/settings.py
index fb868317..dd9c1887 100644
--- a/API/API/settings.py
+++ b/API/API/settings.py
@@ -102,7 +102,7 @@
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
- "hosts": [("127.0.0.1", 6379)],
+ "hosts": [("192.168.228.2", 6379)],
},
},
}
diff --git a/API/Apps/Tournament/Serializers.py b/API/Apps/Tournament/Serializers.py
index ed08c6a2..d86b6967 100644
--- a/API/Apps/Tournament/Serializers.py
+++ b/API/Apps/Tournament/Serializers.py
@@ -38,7 +38,7 @@ class Meta:
class TournamentPostSerializer(serializers.ModelSerializer):
class Meta:
model = Tournament
- fields = ['id', 'name', 'max_participants', 'created_by', 'current_participants']
+ fields = ['id', 'name', 'max_participants', 'created_by']
def validate(self, val):
if val['max_participants'] <= 2:
diff --git a/API/Apps/Tournament/consumers.py b/API/Apps/Tournament/consumers.py
index 7e0b68a9..682a4964 100644
--- a/API/Apps/Tournament/consumers.py
+++ b/API/Apps/Tournament/consumers.py
@@ -79,11 +79,11 @@ def connect(self):
def receive(self, text_data):
data = json.loads(text_data)
print("data",data)
- if data['send_type'] == 'checkMatch':
+ if data['request_type'] == 'checkMatch':
self.checkMatch(self.nickname, self.tournament_id)
- elif data['send_type'] == 'start':
- self.check_start_conditions()
- self.StartTournament(data)
+ elif data['request_type'] == 'StartTournament':
+ self.check_start_conditions()
+ self.StartTournament(data)
def check_start_conditions(self):
player = get_player_from_cache(f"user_{self.tournament_id}", self.nickname)
@@ -130,10 +130,16 @@ def disconnect(self, close_code):
def StartTournament(self, data):
print(get_players_from_cache(f"user_{self.tournament_id}"))
tournament = Tournament.objects.get(id=self.tournament_id)
+ print("turrrrrr",tournament.is_started)
+ if tournament.is_started == True:
+ print("31313131313")
+ return
participants = tournament.current_participants.all()
if tournament.current_participants.count() > 2:
round_number = 1
round_obj = Round.objects.create(round_number=round_number)
+ tournament.is_started = True
+ tournament.save()
round_obj.participants.set(participants)
tournament.rounds.add(round_obj)
try:
diff --git a/API/Apps/Tournament/templates/w.html b/API/Apps/Tournament/templates/w.html
index 06b2d3b1..f3dbbe1a 100644
--- a/API/Apps/Tournament/templates/w.html
+++ b/API/Apps/Tournament/templates/w.html
@@ -16,7 +16,7 @@
const url = window.location.pathname;
const param = url.split("/");
const nickname = param[param.length - 2];
- const tournament_id = "eba06344-e081-4e52-852f-38bbff0fdbd6";
+ const tournament_id = "a8671b64-478e-4483-b693-d44b22b0ea17";
const socket = new WebSocket('ws://localhost:8000/ws/tournament/?nickname=' + nickname + '&tournament_id=' + tournament_id);