Skip to content

Commit

Permalink
Turnuva sadece bi kere başlatılabilir
Browse files Browse the repository at this point in the history
  • Loading branch information
omerfarukfirat committed May 12, 2024
1 parent b0009ad commit 6fdc606
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 7 deletions.
18 changes: 18 additions & 0 deletions .idea/ft-transcendence.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion API/API/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [("127.0.0.1", 6379)],
"hosts": [("192.168.228.2", 6379)],
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion API/Apps/Tournament/Serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 10 additions & 4 deletions API/Apps/Tournament/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion API/Apps/Tournament/templates/w.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down

0 comments on commit 6fdc606

Please sign in to comment.