diff --git a/backend/game/consumers.py b/backend/game/consumers.py
index bbbf247..c998004 100644
--- a/backend/game/consumers.py
+++ b/backend/game/consumers.py
@@ -10,7 +10,7 @@
SCREEN_HEIGHT = 750
SCREEN_WIDTH = 1250
-MAX_SCORE = 150
+MAX_SCORE = 25
class GameState:
diff --git a/backend/game/matchingConsumers.py b/backend/game/matchingConsumers.py
index f9ef6e8..1d7d3e1 100644
--- a/backend/game/matchingConsumers.py
+++ b/backend/game/matchingConsumers.py
@@ -14,7 +14,7 @@
SCREEN_HEIGHT = 750
SCREEN_WIDTH = 1250
-MAX_SCORE = 10
+MAX_SCORE = 25
@sync_to_async
@@ -41,6 +41,7 @@ def get_user_nicknames(user1, user2):
class MatchingGameState:
async def initialize(self, user1, user2):
try:
+ self.game_state = 0 # 0: in game, 1: game over
self.user = [user1, user2]
self.user_authenticated = [False, False]
self.map = GameMap()
@@ -173,9 +174,9 @@ async def disconnect(self, close_code):
# 누가 남았는지 판별 (내가 0이라면 1이 승자, 내가 1이라면 0이 승자)
winner_index = 1 - self.user_index
state = MatchingGameConsumer.game_states[self.room_group_name]
-
- # send_game_result를 통해 DB에 게임결과 저장 및
- # 나머지(승자)에게 게임 종료 메시지 전송
+ if (state.game_state != 0):
+ return
+ await asyncio.sleep(0.1)
await self.send_game_result(winner_index)
await asyncio.sleep(0.1)
await self.close()
@@ -266,6 +267,7 @@ async def game_loop(self):
async def send_game_result(self, winner):
state = MatchingGameConsumer.game_states[self.room_group_name]
+ state.game_state = 1
print("Game result for", self.room_group_name, ":", state.score, "Winner:", winner)
await self.save_game_result(state, winner)
diff --git a/backend/transcendence/settings.py b/backend/transcendence/settings.py
index 4b69662..def52f5 100644
--- a/backend/transcendence/settings.py
+++ b/backend/transcendence/settings.py
@@ -38,7 +38,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
-DEBUG = True
+# DEBUG = True
ALLOWED_HOSTS = []
@@ -100,7 +100,7 @@ def custom_exception_handler(exc, context):
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
-CORS_ORIGIN_ALLOW_ALL = True # TEST: 모든 도메인 허용 (보안 취약)
+# CORS_ORIGIN_ALLOW_ALL = True # TEST: 모든 도메인 허용 (보안 취약)
CSRF_TRUSTED_ORIGINS = [
"https://localhost:443",
diff --git a/frontend/index.html b/frontend/index.html
index 16a7524..2199729 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -5,6 +5,7 @@
Phong
+
diff --git a/frontend/src/components/2FA.js b/frontend/src/components/2FA.js
index 88ad8e0..28ec7ba 100644
--- a/frontend/src/components/2FA.js
+++ b/frontend/src/components/2FA.js
@@ -120,7 +120,7 @@ export class TwoFA extends Component {
}
})
.catch(error => {
- console.error('Error:', error);
+ // console.error('Error:', error);
});
});
}
diff --git a/frontend/src/components/Edit-Profile.js b/frontend/src/components/Edit-Profile.js
index 6e1a885..1646824 100644
--- a/frontend/src/components/Edit-Profile.js
+++ b/frontend/src/components/Edit-Profile.js
@@ -80,7 +80,7 @@ export class EditProfile extends Component {
this.state.is_2FA = data.is_2FA;
})
.catch(error => {
- console.error('Fetch error:', error);
+ // console.error('Fetch error:', error);
changeUrl("/");
});
return { nickname: this.nickname, img_url: this.img_url, is_2FA: this.is_2FA };
@@ -186,7 +186,7 @@ export class EditProfile extends Component {
else throw new Error('Network response was not ok');
})
.catch(error => {
- console.error('Fetch error:', error);
+ // console.error('Fetch error:', error);
changeUrl("/");
});
});
@@ -215,7 +215,7 @@ export class EditProfile extends Component {
if (response.ok) {
return response.json();
} else {
- console.error('Failed to update profile. Status:', response.status);
+ // console.error('Failed to update profile. Status:', response.status);
throw new Error('Failed to update profile');
}
})
@@ -223,7 +223,7 @@ export class EditProfile extends Component {
changeUrl(`/main/profile/${this.props.uid}/edit`);
})
.catch(error => {
- console.error('Fetch error:', error);
+ // console.error('Fetch error:', error);
changeUrl("/");
});
});
diff --git a/frontend/src/components/Friends-List.js b/frontend/src/components/Friends-List.js
index 8c0c5cb..7863de3 100644
--- a/frontend/src/components/Friends-List.js
+++ b/frontend/src/components/Friends-List.js
@@ -92,7 +92,7 @@ export class FriendsList extends Component {
{ className: "fList", ids: friendIdList, contents: friendNicknameList }));
})
.catch(error => {
- console.error('Fetch error:', error);
+ // console.error('Fetch error:', error);
changeUrl("/");
});
}
@@ -144,7 +144,7 @@ export class FriendsList extends Component {
if (part.length !== 2)
{
// 올바르지 않은 입력입니다!
- console.log("invalid input!");
+ // console.log("invalid input!");
return ;
}
const nickname = part[0];
@@ -152,14 +152,14 @@ export class FriendsList extends Component {
if (!this.users)
{
- console.log("user is not loaded!");
+ // console.log("user is not loaded!");
return ;
}
const isFriend = this.friends.find(friend => friend.user_id === uid);
const isUser = this.users.find(user => user.user_id === uid);
if (isFriend || !isUser || isUser.nickname !== nickname)
{
- console.log("invalid input!");
+ // console.log("invalid input!");
}
else
{
@@ -179,7 +179,7 @@ export class FriendsList extends Component {
changeUrl(window.location.pathname);
})
.catch(error => {
- console.error('Fetch error:', error);
+ // console.error('Fetch error:', error);
changeUrl("/");
});
}
@@ -229,7 +229,7 @@ export class FriendsList extends Component {
});
})
.catch(error => {
- console.error('Fetch error:', error);
+ // console.error('Fetch error:', error);
changeUrl("/");
});
})
@@ -263,7 +263,7 @@ export class FriendsList extends Component {
changeUrl(window.location.pathname);
})
.catch(error => {
- console.error('Fetch error:', error);
+ // console.error('Fetch error:', error);
changeUrl("/");
});
});
diff --git a/frontend/src/components/Game-Core.js b/frontend/src/components/Game-Core.js
index e4253b3..8930c4a 100644
--- a/frontend/src/components/Game-Core.js
+++ b/frontend/src/components/Game-Core.js
@@ -38,13 +38,13 @@ export class GameCore extends Component {
let counter = 0;
let leftBar, rightBar, leftBall, rightBall, map, score, penaltyTime = [0, 0];
- console.log(canvas)
+ // console.log(canvas)
function playSound(soundName) {
var sound = sounds[soundName];
if (sound) {
sound.currentTime = 0;
sound.play().catch(function (error) {
- console.log('Autoplay was prevented:', error);
+ // console.log('Autoplay was prevented:', error);
});
}
}
@@ -420,7 +420,7 @@ export class GameCore extends Component {
rightBall = new Ball(data.right_ball_x, data.right_ball_y, BALL_RADIUS, BALL_COLOR[1]);
score = new Score();
- console.log(SCREEN_HEIGHT, SCREEN_WIDTH, BAR_HEIGHT, BAR_WIDTH, BALL_RADIUS);
+ // console.log(SCREEN_HEIGHT, SCREEN_WIDTH, BAR_HEIGHT, BAR_WIDTH, BALL_RADIUS);
setInterval(interpolate, 3);
}
diff --git a/frontend/src/components/Game-Result-Page.js b/frontend/src/components/Game-Result-Page.js
index ecb7ff1..956a912 100644
--- a/frontend/src/components/Game-Result-Page.js
+++ b/frontend/src/components/Game-Result-Page.js
@@ -108,7 +108,7 @@ export class GameResultPage extends Component {
}
})
.catch(error => {
- console.error("Error sending tournament results:", error);
+ // console.error("Error sending tournament results:", error);
changeUrl("/");
});
changeUrl("/main/tournament");
diff --git a/frontend/src/components/Game-Tournament-Core.js b/frontend/src/components/Game-Tournament-Core.js
index cf773ae..956d2f0 100644
--- a/frontend/src/components/Game-Tournament-Core.js
+++ b/frontend/src/components/Game-Tournament-Core.js
@@ -38,13 +38,13 @@ export class GameTournamentCore extends Component {
let counter = 0;
let leftBar, rightBar, leftBall, rightBall, map, score, penaltyTime = [0, 0];
- console.log(canvas)
+ // console.log(canvas)
function playSound(soundName) {
var sound = sounds[soundName];
if (sound) {
sound.currentTime = 0;
sound.play().catch(function (error) {
- console.log('Autoplay was prevented:', error);
+ // console.log('Autoplay was prevented:', error);
});
}
}
@@ -336,8 +336,8 @@ export class GameTournamentCore extends Component {
} else if (data.type === 'game_result') {
this.gameSocket.close();
socketList.pop();
- console.log("winner!!");
- console.log(data.winner);
+ // console.log("winner!!");
+ // console.log(data.winner);
const winner = data.winner === 0 ? this.props.player1 : this.props.player2;
const loser = data.winner === 0 ? this.props.player2 : this.props.player1;
if (this.props.game === 1) {
@@ -437,7 +437,7 @@ export class GameTournamentCore extends Component {
rightBall = new Ball(data.right_ball_x, data.right_ball_y, BALL_RADIUS, BALL_COLOR[1]);
score = new Score();
- console.log(SCREEN_HEIGHT, SCREEN_WIDTH, BAR_HEIGHT, BAR_WIDTH, BALL_RADIUS);
+ // console.log(SCREEN_HEIGHT, SCREEN_WIDTH, BAR_HEIGHT, BAR_WIDTH, BALL_RADIUS);
setInterval(interpolate, 3);
}
diff --git a/frontend/src/components/Game-Tournament.js b/frontend/src/components/Game-Tournament.js
index 878943b..7fd0a2c 100644
--- a/frontend/src/components/Game-Tournament.js
+++ b/frontend/src/components/Game-Tournament.js
@@ -27,7 +27,7 @@ export class GameTournament extends GameDefault {
} else {
changeUrl("/main/tournament");
}
- console.log(this.props);
+ // console.log(this.props);
new GameTournamentCore(document.querySelector("div#game"), this.props);
}
}
\ No newline at end of file
diff --git a/frontend/src/components/Game-matching-Core.js b/frontend/src/components/Game-matching-Core.js
index e4ddd85..bf18f92 100644
--- a/frontend/src/components/Game-matching-Core.js
+++ b/frontend/src/components/Game-matching-Core.js
@@ -38,13 +38,12 @@ export class GameMatchingCore extends Component {
let counter = 0;
let leftBar, rightBar, leftBall, rightBall, map, score, penaltyTime = [0, 0];
- console.log(canvas)
+ // console.log(canvas)
function playSound(soundName) {
var sound = sounds[soundName];
if (sound) {
sound.currentTime = 0;
sound.play().catch(function (error) {
- console.log('Autoplay was prevented:', error);
});
}
}
@@ -420,7 +419,7 @@ export class GameMatchingCore extends Component {
rightBall = new Ball(data.right_ball_x, data.right_ball_y, BALL_RADIUS, BALL_COLOR[1]);
score = new Score();
- console.log(SCREEN_HEIGHT, SCREEN_WIDTH, BAR_HEIGHT, BAR_WIDTH, BALL_RADIUS);
+ // console.log(SCREEN_HEIGHT, SCREEN_WIDTH, BAR_HEIGHT, BAR_WIDTH, BALL_RADIUS);
setInterval(interpolate, 3);
}
diff --git a/frontend/src/components/Input.js b/frontend/src/components/Input.js
index 49c4b03..9b63824 100644
--- a/frontend/src/components/Input.js
+++ b/frontend/src/components/Input.js
@@ -3,7 +3,7 @@ import { Component } from "../core/Component.js";
export class Input extends Component {
template () {
- console.log(this.props.searchText);
+ // console.log(this.props.searchText);
return `
diff --git a/frontend/src/components/Main-Menu.js b/frontend/src/components/Main-Menu.js
index bfcae4a..7096f18 100644
--- a/frontend/src/components/Main-Menu.js
+++ b/frontend/src/components/Main-Menu.js
@@ -84,7 +84,7 @@ export class Menu extends Component {
}
})
.catch(error => {
- console.error('Fetch error:', error);
+ // console.error('Fetch error:', error);
changeUrl("/");
});
changeUrl("/main");
@@ -125,7 +125,7 @@ export class Menu extends Component {
else throw new Error('Network response was not ok');
})
.catch(error => {
- console.error('Fetch error:', error);
+ // console.error('Fetch error:', error);
location.reload(true);
});
});
diff --git a/frontend/src/components/Match-Wait.js b/frontend/src/components/Match-Wait.js
index 5c41f47..cf58451 100644
--- a/frontend/src/components/Match-Wait.js
+++ b/frontend/src/components/Match-Wait.js
@@ -8,13 +8,17 @@ export class WaitForMatch extends Component {
initState() {
if (socketList[0] !== undefined) {
setTimeout(() => {
- console.log("send enter-matching");
+ if (window.location.pathname !== "/main/matching") {
+ // console.log("cancel enter-matching");
+ return;
+ }
+ // console.log("send enter-matching");
socketList[0].send(JSON.stringify({ 'action': 'enter-matching' }));
socketList[0].onmessage = (e) => {
const data = JSON.parse(e.data);
- console.log(data);
+ // console.log(data);
if (data.action === 'start_game') {
- console.log("start game on " + data.room_name);
+ // console.log("start game on " + data.room_name);
changeUrl('/game/vs/' + data.room_name);
}
};
@@ -71,7 +75,7 @@ export class WaitForMatch extends Component {
setEvent() {
this.addEvent('click', '#goBack', (event) => {
- console.log("send leave-matching");
+ // console.log("send leave-matching");
if (socketList[0] !== undefined)
socketList[0].send(JSON.stringify({ 'action': 'leave-matching' }));
window.removeEventListener('popstate', handleSocketClose);
@@ -79,7 +83,7 @@ export class WaitForMatch extends Component {
});
const handleSocketClose = (e) => {
- console.log("send leave-matching");
+ // console.log("send leave-matching");
if (socketList[0] !== undefined)
socketList[0].send(JSON.stringify({ 'action': 'leave-matching' }));
window.removeEventListener('popstate', handleSocketClose);
diff --git a/frontend/src/components/Profile-Info.js b/frontend/src/components/Profile-Info.js
index fdc7d47..c62f05c 100644
--- a/frontend/src/components/Profile-Info.js
+++ b/frontend/src/components/Profile-Info.js
@@ -36,7 +36,7 @@ export class ProfileInfo extends Component {
}
initState() {
- console.log(this.props.lan.value);
+ // console.log(this.props.lan.value);
const payload = parseJWT();
if (!payload) this.uid = null;
else this.uid = payload.id;
@@ -63,7 +63,7 @@ x } else {
Math.round((data.user.win / (data.user.lose + data.user.win)) * 100);
})
.catch(error => {
- console.error('Fetch error:', error);
+ // console.error('Fetch error:', error);
changeUrl("/");
});
diff --git a/frontend/src/components/Tournament-History.js b/frontend/src/components/Tournament-History.js
index c983318..6482c0f 100644
--- a/frontend/src/components/Tournament-History.js
+++ b/frontend/src/components/Tournament-History.js
@@ -76,17 +76,17 @@ export class TournamentHistory extends Component {
setEvent(){
this.addEvent('click', '#tournament-prev-button', (event) => {
- console.log("prev");
- console.log(this.state.idx);
+ // console.log("prev");
+ // console.log(this.state.idx);
if (this.state.idx > 0) this.state.idx--;
- console.log(this.state.idx);
+ // console.log(this.state.idx);
});
this.addEvent('click', '#tournament-next-button', (event) => {
- console.log("next");
- console.log(this.state.idx);
+ // console.log("next");
+ // console.log(this.state.idx);
if (this.state.idx < this.size) this.state.idx++;
- console.log(this.state.idx);
+ // console.log(this.state.idx);
});
}
}
\ No newline at end of file
diff --git a/frontend/src/components/Tournament-Setting.js b/frontend/src/components/Tournament-Setting.js
index 4d09ca1..aef9256 100644
--- a/frontend/src/components/Tournament-Setting.js
+++ b/frontend/src/components/Tournament-Setting.js
@@ -77,7 +77,7 @@ export class TournamentSetting extends Component {
});
})
.catch(error => {
- console.error("Error fetching tournament history:", error);
+ // console.error("Error fetching tournament history:", error);
this.games = {}; // 오류 발생 시 기본값 설정
});
@@ -85,7 +85,7 @@ export class TournamentSetting extends Component {
this.games[date] = JSON.parse(this.games[date]);
}
- console.log(this.games);
+ // console.log(this.games);
return `
diff --git a/frontend/src/core/router.js b/frontend/src/core/router.js
index 342b7a1..2bcda0d 100644
--- a/frontend/src/core/router.js
+++ b/frontend/src/core/router.js
@@ -88,7 +88,7 @@ export async function parsePath(path) {
if (urlParams.has('code')) {
const code = urlParams.get('code');
- console.log("code:" + code);
+ // console.log("code:" + code);
try {
const response = await postRequest('/callback/', { code });
@@ -112,7 +112,7 @@ export async function parsePath(path) {
const langData = await langResponse.json();
if (langData) {
- console.log(langData.language);
+ // console.log(langData.language);
root.lan.value = langData.language;
changeUrl('/main');
return null;
@@ -122,7 +122,7 @@ export async function parsePath(path) {
return changeUrl("/", false);
}
} catch (error) {
- console.error('Error:', error);
+ // console.error('Error:', error);
return changeUrl("/error");
}
}
@@ -135,7 +135,7 @@ export async function parsePath(path) {
return changeUrl("/", false); // /를 제외한 다른 경로로 이동할 때 인증되지 않은 경우 /로 이동, replaceState 사용
}
} catch (error) {
- console.error('Error:', error);
+ // console.error('Error:', error);
return changeUrl("/error");
}
@@ -151,7 +151,7 @@ export async function parsePath(path) {
keys.forEach((key, index) => {
props[key.substring(1)] = values[index];
});
- console.log(props);
+ // console.log(props);
route.component(props);
return;
}
diff --git a/frontend/src/core/showLoading.js b/frontend/src/core/showLoading.js
index f7f850c..5525d95 100644
--- a/frontend/src/core/showLoading.js
+++ b/frontend/src/core/showLoading.js
@@ -24,10 +24,10 @@ const online = async (socketList) => {
onlineSocket.onopen = () => {
onlineSocket.send(JSON.stringify({ action: 'authenticate', token }));
- console.log("online socket opened");
+ // console.log("online socket opened");
};
onlineSocket.onclose = () => {
- console.log("online socket closed");
+ // console.log("online socket closed");
closeAllSockets(socketList);
changeUrl("/error", false);
};
@@ -40,8 +40,9 @@ export const showLoading = async (routes, socketList) => {
await Promise.all([
initializeRouter(routes),
- parsePath(window.location.pathname),
- changeUrl("/main", false)
+ // parsePath(window.location.pathname),
+ // changeUrl("/main", false),
+ parsePath("/main"),
]);
setTimeout(async () => {
await online(socketList);
diff --git a/frontend/src/utils.js b/frontend/src/utils.js
index 25e7aa5..fc3477b 100644
--- a/frontend/src/utils.js
+++ b/frontend/src/utils.js
@@ -34,7 +34,7 @@ export async function getRequest(endpoint) {
});
return response;
} catch (error) {
- console.error("Error:", error);
+ // console.error("Error:", error);
return null;
}
}
@@ -58,7 +58,7 @@ export async function postRequest(endpoint, body) {
});
return response;
} catch (error) {
- console.error("Error:", error);
+ // console.error("Error:", error);
return null;
}
}