-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from bertt6/main
prod updated
- Loading branch information
Showing
32 changed files
with
362 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# chat/urls.py | ||
from django.urls import path | ||
from .views import start_chat | ||
from .views import start_chat, get_messages | ||
|
||
urlpatterns = [ | ||
path('start-chat', start_chat, name='start-chat'), | ||
path('get-messages/<uuid:room_id>', get_messages, name='get-messages'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
import uuid | ||
|
||
from django.db import models | ||
|
||
from django.apps import apps | ||
from Apps.Profile.models import Profile | ||
from Apps.Tournament.models import Tournament | ||
|
||
|
||
# Create your models here. | ||
|
||
|
||
class Game(models.Model): | ||
id = models.UUIDField(primary_key=True,default=uuid.uuid4) | ||
id = models.UUIDField(primary_key=True, default=uuid.uuid4) | ||
player1 = models.ForeignKey(Profile, on_delete=models.CASCADE, related_name='player1') | ||
player2 = models.ForeignKey(Profile, on_delete=models.CASCADE, related_name='player2') | ||
winner = models.ForeignKey(Profile, on_delete=models.CASCADE, related_name='winner', null=True, blank=True,default=None) | ||
tournament = models.ForeignKey(Tournament, on_delete=models.SET_NULL, blank=True, null=True) | ||
winner = models.ForeignKey(Profile, on_delete=models.CASCADE, related_name='winner', null=True, blank=True, | ||
default=None) | ||
is_finished = models.BooleanField(default=False) | ||
date = models.DateTimeField(auto_now_add=True) | ||
tournament = models.ForeignKey('Tournament.Tournament', on_delete=models.CASCADE, null=True, blank=True) | ||
|
||
def __str__(self): | ||
return f'{self.player1} vs {self.player2} on {self.date} with Id {self.id}' | ||
|
||
def save(self, *args, **kwargs): | ||
if self.winner: | ||
self.is_finished = True | ||
super().save(*args, **kwargs) | ||
super().save(*args, **kwargs) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class MatchmakingConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'Apps.Matchmaking' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
|
||
from django.urls import path | ||
|
||
from . import views | ||
|
||
urlpatterns = [ | ||
path('', views.index, name='matchmaking'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.shortcuts import render | ||
|
||
|
||
def index(request): | ||
return render(request, 'Matchmaking/matchmaking.html') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ async function App() | |
|
||
App().catch((error) => { | ||
console.error(error) | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {loadPage} from "./spa.js"; | ||
|
||
function handleText() { | ||
const BASE_TEXT = "FINDING A MATCH"; | ||
const text = document.getElementById("matchmaking text"); | ||
console.log(text); | ||
let textIndex = 0; | ||
setInterval(() => { | ||
text.innerText = BASE_TEXT + ".".repeat(textIndex % 3); | ||
textIndex += 1; | ||
}, 1000); | ||
} | ||
function handleTimer() { | ||
const timer = document.getElementById("matchmaking-timer"); | ||
let time = 0; | ||
setInterval(() => { | ||
time += 1; | ||
let minutes = Math.floor(time / 60); | ||
let seconds = time % 60; | ||
minutes = minutes < 10 ? "0" + minutes : minutes; | ||
seconds = seconds < 10 ? "0" + seconds : seconds; | ||
timer.innerText = `${minutes}:${seconds}`; | ||
}, 1000); | ||
} | ||
async function connectToSocket() { | ||
const nickname = localStorage.getItem("activeUserNickname") | ||
const socket = new WebSocket(`ws://localhost:8000/ws/matchmaking/${nickname}`); | ||
socket.onopen = () => { | ||
console.log("Successfully connected to the server"); | ||
} | ||
socket.onmessage = (event) => { | ||
const data = JSON.parse(event.data); | ||
console.log(data) | ||
loadPage(`/game/${data.game_id}`); | ||
} | ||
} | ||
async function App() { | ||
handleText(); | ||
handleTimer(); | ||
await connectToSocket(); | ||
} | ||
App(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.