Skip to content

Commit 084a53a

Browse files
author
Seungwon An
authored
Merge pull request #40 from MomHelpMe/fix/for-eval
fix log는 이제 없다.
2 parents 95c9a15 + 7062d40 commit 084a53a

21 files changed

+68
-61
lines changed

backend/game/consumers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
SCREEN_HEIGHT = 750
1212
SCREEN_WIDTH = 1250
13-
MAX_SCORE = 150
13+
MAX_SCORE = 25
1414

1515

1616
class GameState:

backend/game/matchingConsumers.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
SCREEN_HEIGHT = 750
1616
SCREEN_WIDTH = 1250
17-
MAX_SCORE = 10
17+
MAX_SCORE = 25
1818

1919

2020
@sync_to_async
@@ -41,6 +41,7 @@ def get_user_nicknames(user1, user2):
4141
class MatchingGameState:
4242
async def initialize(self, user1, user2):
4343
try:
44+
self.game_state = 0 # 0: in game, 1: game over
4445
self.user = [user1, user2]
4546
self.user_authenticated = [False, False]
4647
self.map = GameMap()
@@ -173,9 +174,9 @@ async def disconnect(self, close_code):
173174
# 누가 남았는지 판별 (내가 0이라면 1이 승자, 내가 1이라면 0이 승자)
174175
winner_index = 1 - self.user_index
175176
state = MatchingGameConsumer.game_states[self.room_group_name]
176-
177-
# send_game_result를 통해 DB에 게임결과 저장 및
178-
# 나머지(승자)에게 게임 종료 메시지 전송
177+
if (state.game_state != 0):
178+
return
179+
await asyncio.sleep(0.1)
179180
await self.send_game_result(winner_index)
180181
await asyncio.sleep(0.1)
181182
await self.close()
@@ -266,6 +267,7 @@ async def game_loop(self):
266267

267268
async def send_game_result(self, winner):
268269
state = MatchingGameConsumer.game_states[self.room_group_name]
270+
state.game_state = 1
269271

270272
print("Game result for", self.room_group_name, ":", state.score, "Winner:", winner)
271273
await self.save_game_result(state, winner)

backend/transcendence/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939

4040
# SECURITY WARNING: don't run with debug turned on in production!
41-
DEBUG = True
41+
# DEBUG = True
4242

4343
ALLOWED_HOSTS = []
4444

@@ -100,7 +100,7 @@ def custom_exception_handler(exc, context):
100100
"django.middleware.clickjacking.XFrameOptionsMiddleware",
101101
]
102102

103-
CORS_ORIGIN_ALLOW_ALL = True # TEST: 모든 도메인 허용 (보안 취약)
103+
# CORS_ORIGIN_ALLOW_ALL = True # TEST: 모든 도메인 허용 (보안 취약)
104104

105105
CSRF_TRUSTED_ORIGINS = [
106106
"https://localhost:443",

frontend/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>Phong</title>
77
<link rel="stylesheet" href="style.css">
8+
<link rel="shortcut icon" href="#">
89
</head>
910
<body>
1011
<div id="app"></div>

frontend/src/components/2FA.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class TwoFA extends Component {
120120
}
121121
})
122122
.catch(error => {
123-
console.error('Error:', error);
123+
// console.error('Error:', error);
124124
});
125125
});
126126
}

frontend/src/components/Edit-Profile.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class EditProfile extends Component {
8080
this.state.is_2FA = data.is_2FA;
8181
})
8282
.catch(error => {
83-
console.error('Fetch error:', error);
83+
// console.error('Fetch error:', error);
8484
changeUrl("/");
8585
});
8686
return { nickname: this.nickname, img_url: this.img_url, is_2FA: this.is_2FA };
@@ -186,7 +186,7 @@ export class EditProfile extends Component {
186186
else throw new Error('Network response was not ok');
187187
})
188188
.catch(error => {
189-
console.error('Fetch error:', error);
189+
// console.error('Fetch error:', error);
190190
changeUrl("/");
191191
});
192192
});
@@ -215,15 +215,15 @@ export class EditProfile extends Component {
215215
if (response.ok) {
216216
return response.json();
217217
} else {
218-
console.error('Failed to update profile. Status:', response.status);
218+
// console.error('Failed to update profile. Status:', response.status);
219219
throw new Error('Failed to update profile');
220220
}
221221
})
222222
.then(result => {
223223
changeUrl(`/main/profile/${this.props.uid}/edit`);
224224
})
225225
.catch(error => {
226-
console.error('Fetch error:', error);
226+
// console.error('Fetch error:', error);
227227
changeUrl("/");
228228
});
229229
});

frontend/src/components/Friends-List.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class FriendsList extends Component {
9292
{ className: "fList", ids: friendIdList, contents: friendNicknameList }));
9393
})
9494
.catch(error => {
95-
console.error('Fetch error:', error);
95+
// console.error('Fetch error:', error);
9696
changeUrl("/");
9797
});
9898
}
@@ -144,22 +144,22 @@ export class FriendsList extends Component {
144144
if (part.length !== 2)
145145
{
146146
// 올바르지 않은 입력입니다!
147-
console.log("invalid input!");
147+
// console.log("invalid input!");
148148
return ;
149149
}
150150
const nickname = part[0];
151151
const uid = parseInt(part[1]);
152152

153153
if (!this.users)
154154
{
155-
console.log("user is not loaded!");
155+
// console.log("user is not loaded!");
156156
return ;
157157
}
158158
const isFriend = this.friends.find(friend => friend.user_id === uid);
159159
const isUser = this.users.find(user => user.user_id === uid);
160160
if (isFriend || !isUser || isUser.nickname !== nickname)
161161
{
162-
console.log("invalid input!");
162+
// console.log("invalid input!");
163163
}
164164
else
165165
{
@@ -179,7 +179,7 @@ export class FriendsList extends Component {
179179
changeUrl(window.location.pathname);
180180
})
181181
.catch(error => {
182-
console.error('Fetch error:', error);
182+
// console.error('Fetch error:', error);
183183
changeUrl("/");
184184
});
185185
}
@@ -229,7 +229,7 @@ export class FriendsList extends Component {
229229
});
230230
})
231231
.catch(error => {
232-
console.error('Fetch error:', error);
232+
// console.error('Fetch error:', error);
233233
changeUrl("/");
234234
});
235235
})
@@ -263,7 +263,7 @@ export class FriendsList extends Component {
263263
changeUrl(window.location.pathname);
264264
})
265265
.catch(error => {
266-
console.error('Fetch error:', error);
266+
// console.error('Fetch error:', error);
267267
changeUrl("/");
268268
});
269269
});

frontend/src/components/Game-Core.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ export class GameCore extends Component {
3838
let counter = 0;
3939
let leftBar, rightBar, leftBall, rightBall, map, score, penaltyTime = [0, 0];
4040

41-
console.log(canvas)
41+
// console.log(canvas)
4242
function playSound(soundName) {
4343
var sound = sounds[soundName];
4444
if (sound) {
4545
sound.currentTime = 0;
4646
sound.play().catch(function (error) {
47-
console.log('Autoplay was prevented:', error);
47+
// console.log('Autoplay was prevented:', error);
4848
});
4949
}
5050
}
@@ -420,7 +420,7 @@ export class GameCore extends Component {
420420
rightBall = new Ball(data.right_ball_x, data.right_ball_y, BALL_RADIUS, BALL_COLOR[1]);
421421
score = new Score();
422422

423-
console.log(SCREEN_HEIGHT, SCREEN_WIDTH, BAR_HEIGHT, BAR_WIDTH, BALL_RADIUS);
423+
// console.log(SCREEN_HEIGHT, SCREEN_WIDTH, BAR_HEIGHT, BAR_WIDTH, BALL_RADIUS);
424424
setInterval(interpolate, 3);
425425
}
426426

frontend/src/components/Game-Result-Page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class GameResultPage extends Component {
108108
}
109109
})
110110
.catch(error => {
111-
console.error("Error sending tournament results:", error);
111+
// console.error("Error sending tournament results:", error);
112112
changeUrl("/");
113113
});
114114
changeUrl("/main/tournament");

frontend/src/components/Game-Tournament-Core.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ export class GameTournamentCore extends Component {
3838
let counter = 0;
3939
let leftBar, rightBar, leftBall, rightBall, map, score, penaltyTime = [0, 0];
4040

41-
console.log(canvas)
41+
// console.log(canvas)
4242
function playSound(soundName) {
4343
var sound = sounds[soundName];
4444
if (sound) {
4545
sound.currentTime = 0;
4646
sound.play().catch(function (error) {
47-
console.log('Autoplay was prevented:', error);
47+
// console.log('Autoplay was prevented:', error);
4848
});
4949
}
5050
}
@@ -336,8 +336,8 @@ export class GameTournamentCore extends Component {
336336
} else if (data.type === 'game_result') {
337337
this.gameSocket.close();
338338
socketList.pop();
339-
console.log("winner!!");
340-
console.log(data.winner);
339+
// console.log("winner!!");
340+
// console.log(data.winner);
341341
const winner = data.winner === 0 ? this.props.player1 : this.props.player2;
342342
const loser = data.winner === 0 ? this.props.player2 : this.props.player1;
343343
if (this.props.game === 1) {
@@ -437,7 +437,7 @@ export class GameTournamentCore extends Component {
437437
rightBall = new Ball(data.right_ball_x, data.right_ball_y, BALL_RADIUS, BALL_COLOR[1]);
438438
score = new Score();
439439

440-
console.log(SCREEN_HEIGHT, SCREEN_WIDTH, BAR_HEIGHT, BAR_WIDTH, BALL_RADIUS);
440+
// console.log(SCREEN_HEIGHT, SCREEN_WIDTH, BAR_HEIGHT, BAR_WIDTH, BALL_RADIUS);
441441
setInterval(interpolate, 3);
442442
}
443443

0 commit comments

Comments
 (0)