mirror of
https://github.com/AudebertAdrien/ft_transcendence.git
synced 2025-12-16 05:57:48 +01:00
is working
This commit is contained in:
parent
a4e3fbda0f
commit
f00815b329
2
.env
2
.env
@ -1,7 +1,7 @@
|
||||
# Django settings
|
||||
SECRET_KEY="FollowTheWhiteRabbit"
|
||||
DEBUG=True
|
||||
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
|
||||
DJANGO_ALLOWED_HOSTS=['*']
|
||||
|
||||
# PostgreSQL settings
|
||||
POSTGRES_DB=players_db
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
venv/
|
||||
__pycache__/
|
||||
data/
|
||||
.env
|
||||
makefile
|
||||
@ -30,86 +30,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
registerButton.addEventListener('click', handleRegister);
|
||||
loginButton.addEventListener('click', handleLogin);
|
||||
|
||||
|
||||
/// THEOUCHE NOT CERTAIN ///
|
||||
async function createPlayer(name, totalMatch = 0, totalWin = 0, pWin = null, mScoreMatch = null, mScoreAdvMatch = null, bestScore = 0, mNbrBallTouch = null, totalDuration = null, mDuration = null, numParticipatedTournaments = 0, numWonTournaments = 0) {
|
||||
try {
|
||||
const response = await fetch('/api/create_player/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name,
|
||||
total_match: totalMatch,
|
||||
total_win: totalWin,
|
||||
p_win: pWin,
|
||||
m_score_match: mScoreMatch,
|
||||
m_score_adv_match: mScoreAdvMatch,
|
||||
best_score: bestScore,
|
||||
m_nbr_ball_touch: mNbrBallTouch,
|
||||
total_duration: totalDuration,
|
||||
m_duration: mDuration,
|
||||
num_participated_tournaments: numParticipatedTournaments,
|
||||
num_won_tournaments: numWonTournaments
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
throw new Error(errorData.error || 'Network response was not ok');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return data;
|
||||
|
||||
} catch (error) {
|
||||
// Afficher l'erreur avec un message plus spécifique
|
||||
console.error('Error creating player:', error.message);
|
||||
alert(`Failed to create player: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function createTournoi(name, nbr_player, date, winner_id) {
|
||||
try {
|
||||
const response = await fetch('/api/create_tournoi/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ name, nbr_player, date, winner_id })
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error creating tournoi:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function createMatch(player1_id, player2_id, score_player1, score_player2, nbr_ball_touch_p1, nbr_ball_touch_p2, duration, is_tournoi, tournoi_id) {
|
||||
try {
|
||||
const response = await fetch('/api/create_match/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ player1_id, player2_id, score_player1, score_player2, nbr_ball_touch_p1, nbr_ball_touch_p2, duration, is_tournoi, tournoi_id })
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Error creating match:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/// THEOUCHE NOT CERTAIN ///
|
||||
|
||||
async function handleCheckNickname() {
|
||||
const nickname = nicknameInput.value.trim();
|
||||
if (nickname) {
|
||||
@ -172,7 +92,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
try {
|
||||
const result = await registerUser(nickname, password);
|
||||
if (result) {
|
||||
//await createPlayer(nickname);
|
||||
registerForm.style.display = 'none';
|
||||
gameContainer.style.display = 'flex';
|
||||
formBlock.style.display = 'none';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user