Merge branch 'main' of github.com:Kum1ta/PTME_Transcendence

This commit is contained in:
Misthaa
2024-10-01 02:35:17 +02:00
13 changed files with 115 additions and 29 deletions

View File

@ -6,7 +6,7 @@
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/09/13 16:20:58 by tomoron #+# #+# #
# Updated: 2024/09/30 19:55:24 by tomoron ### ########.fr #
# Updated: 2024/10/01 00:46:17 by tomoron ### ########.fr #
# #
# **************************************************************************** #
@ -461,7 +461,7 @@ class Game:
def saveResults(self):
try:
if(self.winner == None):
print("unkown winner, settings to 1")
print("unkown winner, setting to 1")
self.winner = 1
print("saving results")
p1DbUser = User.objects.get(id=self.p1.id)

View File

@ -0,0 +1,11 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# __init__.py :+: :+: :+: #
# +:+ +:+ +:+ #
# By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/10/01 00:41:32 by tomoron #+# #+# #
# Updated: 2024/10/01 01:05:30 by tomoron ### ########.fr #
# #
# **************************************************************************** #

View File

@ -13,11 +13,27 @@ from channels.routing import ProtocolTypeRouter, URLRouter
from django.urls import path
from django.core.asgi import get_asgi_application
from channels.sessions import SessionMiddlewareStack
from django.utils import timezone
from datetime import timedelta
from django.db import transaction
import threading
import time
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
from .websocket import WebsocketHandler
def deleteLoop():
while(True):
from .models import User
time.sleep(60 * 60)
limit = timezone.now() - timedelta(days=2 * 365)
with transaction.atomic():
User.objects.using('second').filter(last_login__lt=limit).delete()
threading.Thread(target=deleteLoop, daemon=True).start()
django = get_asgi_application()
application = ProtocolTypeRouter({

View File

@ -81,6 +81,14 @@ DATABASES = {
"NAME":"VAR_DB_NAME",
"USER":"VAR_DB_USERNAME",
"PASSWORD":"VAR_DB_PASSWORD"
},
"second": {
"ENGINE": "django.db.backends.postgresql",
"HOST":"VAR_DB_HOST",
"PORT":5432,
"NAME":"VAR_DB_NAME",
"USER":"VAR_DB_USERNAME",
"PASSWORD":"VAR_DB_PASSWORD"
}
}
@ -132,7 +140,7 @@ STATIC_ROOT = BASE_DIR / 'staticfiles'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
ASGI_APPLICATION = 'server.asgi.applicatio'
ASGI_APPLICATION = 'server.asgi.application'
SESSION_SAVE_EVERY_REQUEST = True
SESSION_COOKIE_NAME = 'sessionid'
SESSION_COOKIE_SECURE = False

View File

@ -91,10 +91,10 @@
</div>
<div class="skin-select">
<div id="bar">
<div class="barSelection" id="bar">
</div>
<div id="goal">
<div class="goalSelection" id="goal">
</div>
</div>
@ -102,23 +102,38 @@
<div class="menuSelected" id="rankedSelected">
<div id="whatGame">
<p>Bonsoir non ?</p>
<p>AAAAAAAAAA</p>
<span class="line"></span>
<p>BBBBBBBBBB</p>
</div>
<div class="skin-select">
<!-- Make sure you have ids and classes to make multiple "bars" and "goals" -->
<div class="barSelection" id="bar1">
</div>
<div class="goalSelection" id="goal1">
</div>
</div>
</div>
<div class="menuSelected" id="tournamentSelected">
<div id="whatGame">
<p>Bonsoir non ?</p>
<p>CCCCCCCCCC</p>
<span class="line"></span>
<p>DDDDDDDDDD</p>
</div>
<div class="skin-select">
<!-- Make sure you have ids and classes to make multiple "bars" and "goals" -->
<div class="barSelection" id="bar2">
</div>
<div class="goalSelection" id="goal2">
</div>
</div>
</div>
<!--------------------- END OF CHANGES --------------------->
</div>
</div>
<div class="bottom">

View File

@ -28,7 +28,7 @@
</div>
</div>
<div class="history" id="history">
<h3>History</h3>
<h3 style="margin-top: 20px;">History</h3>
<div id="scroll-match"></div>
</div>
</div>

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/29 22:36:43 by edbernar #+# #+# */
/* Updated: 2024/09/30 00:56:01 by edbernar ### ########.fr */
/* Updated: 2024/09/30 23:08:59 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -67,8 +67,6 @@ async function loadFiles()
loadBar.style.width = value;
await sleep(50);
}
console.log(Object.values(files).length * 100 / Object.values(url_files).length + '%');
console.log('files loaded :', files);
}
export { files, loadFiles };

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/22 17:19:17 by edbernar #+# #+# */
/* Updated: 2024/09/30 14:01:36 by edbernar ### ########.fr */
/* Updated: 2024/09/30 23:07:19 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -430,8 +430,7 @@ function moveCamera()
const distance = camera.position.distanceTo(screen.tv.position);
camera.position.copy(position);
console.log(distance);
if (position.equals(targetPosition) || distance < 0.15)
if (position.equals(targetPosition) || distance < 1)
{
pageRenderer.changePage('lobbyPage');
return ;

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/13 13:59:46 by edbernar #+# #+# */
/* Updated: 2024/09/29 23:24:39 by edbernar ### ########.fr */
/* Updated: 2024/09/30 23:53:04 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -131,7 +131,10 @@ class barSelecter
dispose()
{
if (this.renderer)
{
this.renderer.dispose();
this.renderer.forceContextLoss();
}
this.renderer = null;
if (this.scene)
{
@ -197,7 +200,10 @@ class goalSelecter
dispose()
{
if (this.renderer)
{
this.renderer.dispose();
this.renderer.forceContextLoss();
}
this.renderer = null;
if (this.scene)
{

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/22 17:08:46 by madegryc #+# #+# */
/* Updated: 2024/09/29 01:34:41 by edbernar ### ########.fr */
/* Updated: 2024/09/30 23:46:19 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -208,6 +208,13 @@ function selectGameModeTwo()
goalSelector.dispose();
document.getElementById('bar').innerHTML = '';
document.getElementById('goal').innerHTML = '';
if (barSelector)
barSelector.dispose();
if (goalSelector)
goalSelector.dispose();
barSelector = null;
goalSelector = null;
window.gc();
barSelector = new barSelecter(document.getElementById('bar'));
goalSelector = new goalSelecter(document.getElementById('goal'));
gameMode = 1;
@ -222,7 +229,18 @@ function selectGameModeThree()
{
menuList[i].style.display = 'none';
}
document.getElementById('bar1').innerHTML = '';
document.getElementById('goal1').innerHTML = '';
document.getElementsByClassName('menuSelected')[2].style.display = 'flex';
if (barSelector)
barSelector.dispose();
if (goalSelector)
goalSelector.dispose();
barSelector = null;
goalSelector = null;
window.gc();
barSelector = new barSelecter(document.getElementById('bar1'));
goalSelector = new goalSelecter(document.getElementById('goal1'));
gameMode = 2;
}
@ -235,7 +253,15 @@ function selectGameModeFour()
{
menuList[i].style.display = 'none';
}
document.getElementById('bar2').innerHTML = '';
document.getElementById('goal2').innerHTML = '';
document.getElementsByClassName('menuSelected')[3].style.display = 'flex';
if (barSelector)
barSelector.dispose();
if (goalSelector)
goalSelector.dispose();
barSelector = new barSelecter(document.getElementById('bar2'));
goalSelector = new goalSelecter(document.getElementById('goal2'));
gameMode = 3;
}

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/19 23:08:31 by edbernar #+# #+# */
/* Updated: 2024/09/29 02:08:41 by edbernar ### ########.fr */
/* Updated: 2024/10/01 00:21:50 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -206,14 +206,16 @@ function createGraph(ctx, data)
function showHistory(userInfo)
{
const divHistory = document.getElementById('history');
const divHistory = document.getElementById('scroll-match');
const history = userInfo.history;
history.forEach(element => {
const div = document.createElement('div');
div.setAttribute('class', 'history-card');
if (element.won)
if (element.forfeit)
div.style.backgroundColor = '#c45f0c';
else if (element.won)
div.style.backgroundColor = '#11ad11';
div.innerHTML = `
<div id="user-1">

View File

@ -239,7 +239,7 @@ body {
align-items: center;
}
#bar{
.barSelection{
margin: 25px;
width: 250px;
height: 250px;
@ -247,11 +247,11 @@ body {
transition: transform 0.3s ease;
}
#bar:hover{
.barSelection:hover{
transform: scale(1.05);
}
#goal{
.goalSelection{
margin: 25px;
width: 250px;
height: 250px;
@ -259,7 +259,7 @@ body {
transition: transform 0.3s ease;
}
#goal:hover{
.goalSelection:hover{
transform: scale(1.05);
}

View File

@ -113,16 +113,20 @@
text-align: center;
}
#profil .scroll-match {
#profil .history #scroll-match {
overflow-y: auto;
height: 100%;
width: 100%;
height: calc(100% - 60px);
display: flex;
flex-direction: column;
align-items: center;
}
#profil .history {
background-color: white;
width: 48%;
height: 42vh;
padding: 20px;
/* padding: 20px; */
text-align: center;
}
@ -132,6 +136,7 @@
margin-top: 20px;
background-color: #E74040;
height: 110px;
width: 90%;
padding: 15px;
padding-inline: 40px;
transition: 0.3s ease;