Skip to content

Commit ff66f0f

Browse files
Merge pull request #283 from boostcamp-2020/develop
12์›” 17์ผ ์ €๋… ๋ฐฐํฌ
2 parents 36f9675 + 0e58a72 commit ff66f0f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+289
-150
lines changed

โ€Žsrc/backend/game/GameMethods/common.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ function dealCards(count = 1) {
2828
}
2929

3030
const setUserTeller = (users, tellerTurnID) => {
31-
users.forEach((user) => {
32-
if (tellerTurnID === user.turnID) user.setTeller(true);
33-
else user.setTeller(false);
34-
});
31+
users.forEach((user) => user.setTeller(tellerTurnID === user.turnID));
3532
};
3633

3734
function startRound() {

โ€Žsrc/backend/game/GameMethods/scoreBoardScene.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ const isGameOver = (game) => {
77
if (game.status.unusedCards.length < game.getUsers().length) return true;
88

99
// ํ”Œ๋ ˆ์ด์–ด ์ตœ์†Œ ํ•œ๋ช…์ด 30์ ์„ ๋„˜๊ฒผ์„ ๊ฒฝ์šฐ
10-
if (game.getUsers().some((user) => user.score >= SCORE.WIN_SCORE))
11-
return true;
12-
13-
return false;
10+
const bHigherGoal = game
11+
.getUsers()
12+
.some((user) => user.score >= SCORE.WIN_SCORE);
13+
return bHigherGoal;
1414
};
1515

1616
// ๊ฐ€์žฅ ๋†’์€ ์Šค์ฝ”์–ด๋ฅผ ๊ฐ€์ง„ ์œ ์ €์˜ socketID๋ฅผ ๋ฆฌํ„ด
@@ -49,8 +49,6 @@ function endScoreBoardScene() {
4949

5050
if (isGameOver(this)) {
5151
this.emitGameEnd();
52-
53-
// WaitingScene ์‹œ์ž‘
5452
this.setState(GAME_STATE.WAITING);
5553
} else {
5654
this.startTellerScene();

โ€Žsrc/backend/game/GameMethods/user.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ function getUsers() {
2828
}
2929

3030
function getTeller() {
31-
const [teller] = this.getUsers().filter((user) => user.isTeller);
31+
const [teller] = this.getUsers().filter((user) => user.bTeller);
3232
return teller;
3333
}
3434

3535
function getGuessers() {
36-
return this.getUsers().filter((user) => !user.isTeller);
36+
return this.getUsers().filter((user) => !user.bTeller);
3737
}
3838

3939
function getUsersProfile() {

โ€Žsrc/backend/game/GameMethods/voteScene.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@ function forceGuesserVote() {
2020

2121
unvotedUsers.forEach((user) => {
2222
const { submittedCard } = user;
23-
24-
// ์ž๊ธฐ ์นด๋“œ๋ฅผ ๋บ€ ๋‚˜๋จธ์ง€ ์นด๋“œ๋งŒ ๊ณจ๋ผ๋ƒ„
2523
const voteableCards = submittedCards.filter(
2624
(card) => card !== submittedCard,
2725
);
2826

29-
// ๋žœ๋ค ํ•˜๊ฒŒ ํˆฌํ‘œ
3027
user.voteCard(generateRandom.pickOneFromArray(voteableCards));
3128
});
3229
}
@@ -45,10 +42,11 @@ function emitEndVote() {
4542
};
4643
});
4744

45+
const endTime = this.getEndTime(TIME.WAIT_RESULT);
4846
emit({
4947
users: this.getUsers(),
5048
name: 'end vote',
51-
params: { players },
49+
params: { players, endTime },
5250
});
5351
}
5452

โ€Žsrc/backend/game/User.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ class User {
66
this.nickname = nickname;
77
this.color = color;
88

9-
this.isTeller = false;
9+
this.bTeller = false;
1010

1111
this.turnID = 0;
1212
this.score = 0;
1313
this.cards = [];
1414

1515
this.submittedCard = null;
1616
this.votedCard = null;
17-
this.isReady = false;
18-
this.isSkip = false;
17+
this.bReady = false;
18+
this.bSkip = false;
1919
}
2020

2121
initOnStart({ turnID } = {}) {
@@ -27,20 +27,20 @@ class User {
2727
initOnRound() {
2828
this.submittedCard = null;
2929
this.votedCard = null;
30-
this.isReady = false;
31-
this.isSkip = false;
30+
this.bReady = false;
31+
this.bSkip = false;
3232
}
3333

3434
setTeller(boolean) {
35-
this.isTeller = boolean;
35+
this.bTeller = boolean;
3636
}
3737

38-
setReady(isReady) {
39-
this.isReady = isReady;
38+
setReady(bReady) {
39+
this.bReady = bReady;
4040
}
4141

4242
setSkip() {
43-
this.isSkip = true;
43+
this.bSkip = true;
4444
}
4545

4646
setColor(color) {
@@ -57,16 +57,12 @@ class User {
5757

5858
submitCard(cardID) {
5959
this.submittedCard = cardID;
60-
61-
// ๋ฝ‘์€ ์นด๋“œ๋ฅผ ๋ฆฌ์ŠคํŠธ์—์„œ ์ง€์›€
6260
this.cards = this.cards.filter((card) => card !== cardID);
6361
}
6462

6563
voteCard(cardID) {
66-
// ์•…์„ฑ ์œ ์ €๊ฐ€ ์žˆ์„๊นŒ๋ด ์ž๊ธฐ ์นด๋“œ ์„ ํƒํ•˜๋Š”๊ฑฐ ๋ฐฉ์ง€
6764
if (cardID === this.submittedCard) return;
68-
// ํ…”๋Ÿฌ๊ฐ€ vote ๋ชปํ•˜๊ฒŒ ๋ง‰๊ธฐ
69-
if (this.isTeller) return;
65+
if (this.bTeller) return;
7066

7167
this.votedCard = cardID;
7268
}
@@ -83,10 +79,10 @@ class User {
8379
turnID,
8480
submittedCard,
8581
votedCard,
86-
isTeller,
82+
bTeller,
8783
cards,
8884
score,
89-
isReady,
85+
bReady,
9086
} = this;
9187

9288
return {
@@ -96,20 +92,20 @@ class User {
9692
turnID,
9793
submittedCard,
9894
votedCard,
99-
isTeller,
95+
bTeller,
10096
cards,
10197
score,
102-
isReady,
98+
bReady,
10399
};
104100
}
105101

106102
getProfile() {
107-
const { nickname, color, score, isReady } = this;
103+
const { nickname, color, score, bReady } = this;
108104
return {
109105
nickname,
110106
color,
111107
score,
112-
isReady,
108+
bReady,
113109
};
114110
}
115111

โ€Žsrc/backend/sockets/discussion.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ function onSkipPlayer() {
55
if (!user || !game) return;
66

77
user.setSkip();
8-
9-
// ๋ชจ๋“  ์œ ์ €๊ฐ€ ์Šคํ‚ต์„ ๋ˆŒ๋ €์„ ๊ฒฝ์šฐ
10-
if (game.getUsers().every((u) => u.isSkip)) {
11-
game.endDiscussionScene(true);
12-
}
8+
if (game.getUsers().every((u) => u.bSkip)) game.endDiscussionScene(true);
139
}
1410

1511
export default function onDiscussion(socket) {

โ€Žsrc/backend/sockets/waitingRoom.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ function onUpdatePlayer(updatedUserProfile = {}) {
5151
const timeoutMap = new Map();
5252

5353
const isPossibleStartGame = ({ users }) => {
54-
const isAllReady = [...users].every(([, user]) => user.isReady);
55-
const isValidSize = users.size >= PLAYER.MIN && users.size <= PLAYER.MAX;
56-
return isAllReady && isValidSize;
54+
const bAllReady = [...users].every(([, user]) => user.bReady);
55+
const bValidSize = users.size >= PLAYER.MIN && users.size <= PLAYER.MAX;
56+
return bAllReady && bValidSize;
5757
};
5858

5959
const deleteGameStartTimeout = (roomID) => {
@@ -63,7 +63,7 @@ const deleteGameStartTimeout = (roomID) => {
6363
};
6464

6565
// ์‚ฌ์šฉ์ž๊ฐ€ ๋ ˆ๋””๋ฅผ ๋ˆŒ๋ €์„ ๋•Œ or ๋ ˆ๋””๋ฅผ ํ’€์—ˆ์„ ๋•Œ
66-
function onReadyChange({ isReady }) {
66+
function onReadyChange({ bReady }) {
6767
const socket = this;
6868
const { user, game } = socket;
6969

@@ -77,8 +77,8 @@ function onReadyChange({ isReady }) {
7777
const { users, roomID } = game;
7878

7979
// ํ”Œ๋ ˆ์ด์–ด์˜ ๋ ˆ๋”” ์ƒํƒœ๋ฅผ ๋ณ€๊ฒฝ
80-
users.get(socket.id).setReady(isReady);
81-
socket.in(roomID).emit('ready player', { playerID: socket.id, isReady });
80+
users.get(socket.id).setReady(bReady);
81+
socket.in(roomID).emit('ready player', { playerID: socket.id, bReady });
8282

8383
const validationToStart = isPossibleStartGame({ users });
8484
// ๋ชจ๋“  ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ ˆ๋”” ์ƒํƒœ์ผ ๋•Œ

โ€Žsrc/backend/utils/calcScore.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ const mapScore = (correctScore, bonusScore) => ({ correctScore, bonusScore });
3030
const getScoreMap = (game) => {
3131
const scoreMap = new Map();
3232
const users = game.getUsers();
33-
const [teller] = users.filter((user) => user.isTeller);
34-
const guessers = users.filter((user) => !user.isTeller);
33+
const [teller] = users.filter((user) => user.bTeller);
34+
const guessers = users.filter((user) => !user.bTeller);
3535

3636
// Teller
3737
// [๋‹ค ๋งž์ถ”๊ฑฐ๋‚˜ ์•„๋ฌด๋„ ๋ชป ๋งž์ถค]์ธ์ง€ [ํ•œ๋ช…์ด๋ผ๋„ ๋งž์ถค]์ธ์ง€ ํ™•์ธ

โ€Žsrc/backend/utils/number.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const TIME = {
1616
WAIT_DISCUSSION: 60000,
1717
SKIP_DISCUSSION: 3000,
1818
WAIT_VOTE: 10000,
19-
WAIT_RESULT: 20000,
19+
WAIT_RESULT: 15000,
2020
WAIT_SCORE_BOARD: 10000,
2121
};
2222

โ€Žsrc/frontend/engine/CardObject.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import ImageObject from './ImageObject';
66
const getFacingStyle = (isUp) => (isUp ? 'rotateY(0deg)' : 'rotateY(180deg)');
77
const deg2rad = (deg) => (deg * Math.PI) / 180;
88
const MOVE_PERCENT = 10;
9+
const HIGH_DEPTH = 7;
910

1011
const CardObject = class extends GameObject {
1112
constructor({
@@ -73,7 +74,7 @@ const CardObject = class extends GameObject {
7374
return () => {
7475
const movedX = this.fixedX + Math.sin(deg2rad(this.angle)) * MOVE_PERCENT;
7576
const movedY = this.fixedY - Math.cos(deg2rad(this.angle)) * MOVE_PERCENT;
76-
this.setDepth('7');
77+
this.setDepth(HIGH_DEPTH);
7778
this.move(movedX, movedY);
7879

7980
if (this.tellerCard)

โ€Žsrc/frontend/engine/DuckCursorObject.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import TIME from '@type/time';
55
import DuckObejct from './DuckObject';
66

77
class DuckCursorObject extends DuckObejct {
8-
constructor({ isReady, ...props }) {
8+
constructor({ bReady, ...props }) {
99
super(props);
1010
this.addClass('cursor-duck-wrapper');
1111
this.setOriginCenter();
@@ -16,7 +16,7 @@ class DuckCursorObject extends DuckObejct {
1616
this.mouseHandler = this.makeFollowMouse.bind(this);
1717
this.width = 100;
1818
this.render();
19-
this.setVisibility(isReady);
19+
this.setVisibility(bReady);
2020
}
2121

2222
addMouseMoveEvent() {

โ€Žsrc/frontend/engine/DuckLeftTabObject.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class DuckLeftTabObject extends DuckObject {
1212
this.hatWidth = 45;
1313

1414
this.addClass('left-duck-wrapper');
15+
this.instance.dataset.socketId = this.socketID;
1516
this.render();
1617
}
1718

@@ -32,6 +33,7 @@ class DuckLeftTabObject extends DuckObject {
3233
${DuckHat({ width: hatWidth })}
3334
${Duck({ color, width: duckWidth })}
3435
<span class="duck-score">${score}</span>
36+
<img alt="speaker button" class="duck-speaker"/>
3537
</div>
3638
<span class="duck-nickname">${nickname}</span>
3739
`;

โ€Žsrc/frontend/engine/ProgressBarObject.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import GameObject from './GameObject';
55
const RED_COLOR = '#d82e21';
66
const YELLOW_COLOR = '#ffd600';
77
const GREEN_COLOR = '#3ed78d';
8+
const SMALL_WIDTH = 30;
9+
const MID_WIDTH = 60;
810

911
const ProgressBarObject = class extends GameObject {
1012
constructor() {
@@ -64,8 +66,11 @@ const ProgressBarObject = class extends GameObject {
6466
const remainTime = endTime - new Date().getTime();
6567
const widthSize = (remainTime / this.time) * 100;
6668
progressBar.style.width = `${widthSize}%`;
67-
if (widthSize < 30) progressBar.style.backgroundColor = RED_COLOR;
68-
else if (widthSize < 60) progressBar.style.backgroundColor = YELLOW_COLOR;
69+
if (widthSize < SMALL_WIDTH) {
70+
progressBar.style.backgroundColor = RED_COLOR;
71+
} else if (widthSize < MID_WIDTH) {
72+
progressBar.style.backgroundColor = YELLOW_COLOR;
73+
}
6974
timeText.innerText = (remainTime / 1000).toFixed(0);
7075
}, TIME.HALF_SECOND);
7176

โ€Žsrc/frontend/game/LeftTab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class LeftTab {
4444
updateDuck(playerInfo) {
4545
const updatedDuck = this.findDuck(playerInfo.socketID);
4646
if (updatedDuck) {
47-
updatedDuck.setHat(playerInfo.isTeller);
47+
updatedDuck.setHat(playerInfo.bTeller);
4848
updatedDuck.update(playerInfo);
4949
} else this.addDuck(playerInfo);
5050
}

โ€Žsrc/frontend/game/game.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
<span id="participants-count" class="left-title-number">0</span>
2020
</div>
2121
<div id="participants-wrapper" class="participants-wrapper"></div>
22-
<div class="microphone-controller" id="microphone-controller">
23-
<span>๋งˆ์ดํฌ ์—ฐ๊ฒฐ</span>
22+
<button class="microphone-controller" id="microphone-controller">
23+
<span>์Œ์„ฑ ์ฑ„ํŒ… ์ฐธ์—ฌ</span>
2424
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z"/></svg>
25-
</div>
25+
</button>
2626
</div>
2727
<div id="background" class="background">
2828
<div id="root" class="main"></div>

โ€Žsrc/frontend/game/left.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
font-weight: 700;
3333
}
3434

35+
.microphone-controller-exit {
36+
background-color: $red-color;
37+
}
38+
3539
.participants-wrapper {
3640
@include flex-column;
3741
height: 100%;
@@ -63,6 +67,24 @@
6367
background-color: $gray-color;
6468
border-radius: 1rem;
6569
}
70+
71+
.duck-speaker {
72+
position: absolute;
73+
top: 0%;
74+
left: 45%;
75+
width: 100px;
76+
height: 100px;
77+
cursor: pointer;
78+
visibility: hidden;
79+
}
80+
.duck-speaker-active {
81+
content: url('@resources/speaker-active.png');
82+
visibility: visible;
83+
}
84+
.duck-speaker-deactive {
85+
content: url('@resources/speaker-deactive.png');
86+
visibility: visible;
87+
}
6688
}
6789

6890
.duck-hat {

0 commit comments

Comments
ย (0)