Skip to content

Commit ec2d76a

Browse files
committed
Refacotr : 헝가리안 표기법 적용 (#199)
- 크롱님 코드리뷰 : 함수가 아닌 변수는 is~가 아니라 b~로 해라!
1 parent 0f727e1 commit ec2d76a

File tree

8 files changed

+29
-33
lines changed

8 files changed

+29
-33
lines changed

src/backend/game/User.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class User {
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) {
3535
this.isTeller = 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) {
@@ -86,7 +86,7 @@ class User {
8686
isTeller,
8787
cards,
8888
score,
89-
isReady,
89+
bReady,
9090
} = this;
9191

9292
return {
@@ -99,17 +99,17 @@ class User {
9999
isTeller,
100100
cards,
101101
score,
102-
isReady,
102+
bReady,
103103
};
104104
}
105105

106106
getProfile() {
107-
const { nickname, color, score, isReady } = this;
107+
const { nickname, color, score, bReady } = this;
108108
return {
109109
nickname,
110110
color,
111111
score,
112-
isReady,
112+
bReady,
113113
};
114114
}
115115

src/backend/sockets/discussion.js

+1-5
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

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function onUpdatePlayer(updatedUserProfile = {}) {
5151
const timeoutMap = new Map();
5252

5353
const isPossibleStartGame = ({ users }) => {
54-
const isAllReady = [...users].every(([, user]) => user.isReady);
54+
const isAllReady = [...users].every(([, user]) => user.bReady);
5555
const isValidSize = users.size >= PLAYER.MIN && users.size <= PLAYER.MAX;
5656
return isAllReady && isValidSize;
5757
};
@@ -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/frontend/engine/DuckCursorObject.js

+2-2
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/scenes/waitingRoom/events.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ export const changeNickname = (NicknameInput) => {
3434

3535
export const toggleReady = ({ target }) => {
3636
const currentPlayer = PlayerManager.getCurrentPlayer();
37-
const { isReady } = currentPlayer;
38-
const nextStatus = !isReady;
37+
const { bReady } = currentPlayer;
38+
const nextStatus = !bReady;
3939

4040
target.innerText = nextStatus ? '준비 해제' : '준비 완료';
4141
target.classList.toggle('button-primary');
4242
target.classList.toggle('button-primary-clicked');
4343

4444
PlayerManager.getCurrentPlayer().setReady(nextStatus);
45-
socket.emit('ready player', { isReady: nextStatus });
45+
socket.emit('ready player', { bReady: nextStatus });
4646
};
4747

4848
export const changeColor = ({ target }) => {

src/frontend/scenes/waitingRoom/render.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const renderWaitingRoom = (roomID = '') => {
145145
ButtonReady.setContent('준비 완료');
146146
ButtonReady.addClass('button-primary');
147147
ButtonReady.attachToObject(ActionWrapper);
148-
ButtonReady.instance.dataset.data = JSON.stringify({ isReady: false });
148+
ButtonReady.instance.dataset.data = JSON.stringify({ bReady: false });
149149
ButtonReady.addClickHandler(toggleReady);
150150

151151
const GameCodeWrapper = new ButtonObject();

src/frontend/socket/waitingRoom.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ const setupWaitingRoomSocket = () => {
4646
PlayerManager.delete(socketID);
4747
};
4848

49-
const onReadyPlayer = ({ playerID, isReady }) => {
49+
const onReadyPlayer = ({ playerID, bReady }) => {
5050
if (!SceneManager.isCurrentScene(WaitingRoom)) return;
5151
const player = PlayerManager.get(playerID);
52-
if (player) player.setReady(isReady);
52+
if (player) player.setReady(bReady);
5353
};
5454

5555
const onGetRoundData = ({ tellerID, cards, endTime }) => {

src/frontend/utils/Player.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const Player = class {
88
color,
99
isTeller = false,
1010
isCurrentPlayer = false,
11-
isReady = false,
11+
bReady = false,
1212
} = {}) {
1313
this.socketID = socketID;
1414
this.nickname = nickname;
@@ -20,8 +20,8 @@ const Player = class {
2020
};
2121
this.isTeller = isTeller;
2222
this.isCurrentPlayer = isCurrentPlayer;
23-
this.isReady = isReady;
24-
this.duck = new DuckCursorObject({ isReady, color });
23+
this.bReady = bReady;
24+
this.duck = new DuckCursorObject({ bReady, color });
2525
this.votedCardID = null;
2626
this.submittedCardID = null;
2727
}
@@ -44,8 +44,8 @@ const Player = class {
4444
}
4545

4646
setReady(value) {
47-
if (this.isReady === value) return;
48-
this.isReady = value;
47+
if (this.bReady === value) return;
48+
this.bReady = value;
4949
this.duck.setVisibility(value, this.isCurrentPlayer);
5050
}
5151

0 commit comments

Comments
 (0)