Skip to content

Commit

Permalink
Refacotr : 헝가리안 표기법 적용 (#199)
Browse files Browse the repository at this point in the history
- 크롱님 코드리뷰 : 함수가 아닌 변수는 is~가 아니라 b~로 해라!
  • Loading branch information
sbyeol3 committed Dec 17, 2020
1 parent 0f727e1 commit ec2d76a
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 33 deletions.
22 changes: 11 additions & 11 deletions src/backend/game/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class User {

this.submittedCard = null;
this.votedCard = null;
this.isReady = false;
this.isSkip = false;
this.bReady = false;
this.bSkip = false;
}

initOnStart({ turnID } = {}) {
Expand All @@ -27,20 +27,20 @@ class User {
initOnRound() {
this.submittedCard = null;
this.votedCard = null;
this.isReady = false;
this.isSkip = false;
this.bReady = false;
this.bSkip = false;
}

setTeller(boolean) {
this.isTeller = boolean;
}

setReady(isReady) {
this.isReady = isReady;
setReady(bReady) {
this.bReady = bReady;
}

setSkip() {
this.isSkip = true;
this.bSkip = true;
}

setColor(color) {
Expand Down Expand Up @@ -86,7 +86,7 @@ class User {
isTeller,
cards,
score,
isReady,
bReady,
} = this;

return {
Expand All @@ -99,17 +99,17 @@ class User {
isTeller,
cards,
score,
isReady,
bReady,
};
}

getProfile() {
const { nickname, color, score, isReady } = this;
const { nickname, color, score, bReady } = this;
return {
nickname,
color,
score,
isReady,
bReady,
};
}

Expand Down
6 changes: 1 addition & 5 deletions src/backend/sockets/discussion.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ function onSkipPlayer() {
if (!user || !game) return;

user.setSkip();

// 모든 유저가 스킵을 눌렀을 경우
if (game.getUsers().every((u) => u.isSkip)) {
game.endDiscussionScene(true);
}
if (game.getUsers().every((u) => u.bSkip)) game.endDiscussionScene(true);
}

export default function onDiscussion(socket) {
Expand Down
8 changes: 4 additions & 4 deletions src/backend/sockets/waitingRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function onUpdatePlayer(updatedUserProfile = {}) {
const timeoutMap = new Map();

const isPossibleStartGame = ({ users }) => {
const isAllReady = [...users].every(([, user]) => user.isReady);
const isAllReady = [...users].every(([, user]) => user.bReady);
const isValidSize = users.size >= PLAYER.MIN && users.size <= PLAYER.MAX;
return isAllReady && isValidSize;
};
Expand All @@ -63,7 +63,7 @@ const deleteGameStartTimeout = (roomID) => {
};

// 사용자가 레디를 눌렀을 때 or 레디를 풀었을 때
function onReadyChange({ isReady }) {
function onReadyChange({ bReady }) {
const socket = this;
const { user, game } = socket;

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

// 플레이어의 레디 상태를 변경
users.get(socket.id).setReady(isReady);
socket.in(roomID).emit('ready player', { playerID: socket.id, isReady });
users.get(socket.id).setReady(bReady);
socket.in(roomID).emit('ready player', { playerID: socket.id, bReady });

const validationToStart = isPossibleStartGame({ users });
// 모든 플레이어가 레디 상태일 때
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/engine/DuckCursorObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import TIME from '@type/time';
import DuckObejct from './DuckObject';

class DuckCursorObject extends DuckObejct {
constructor({ isReady, ...props }) {
constructor({ bReady, ...props }) {
super(props);
this.addClass('cursor-duck-wrapper');
this.setOriginCenter();
Expand All @@ -16,7 +16,7 @@ class DuckCursorObject extends DuckObejct {
this.mouseHandler = this.makeFollowMouse.bind(this);
this.width = 100;
this.render();
this.setVisibility(isReady);
this.setVisibility(bReady);
}

addMouseMoveEvent() {
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/scenes/waitingRoom/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ export const changeNickname = (NicknameInput) => {

export const toggleReady = ({ target }) => {
const currentPlayer = PlayerManager.getCurrentPlayer();
const { isReady } = currentPlayer;
const nextStatus = !isReady;
const { bReady } = currentPlayer;
const nextStatus = !bReady;

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

PlayerManager.getCurrentPlayer().setReady(nextStatus);
socket.emit('ready player', { isReady: nextStatus });
socket.emit('ready player', { bReady: nextStatus });
};

export const changeColor = ({ target }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/scenes/waitingRoom/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const renderWaitingRoom = (roomID = '') => {
ButtonReady.setContent('준비 완료');
ButtonReady.addClass('button-primary');
ButtonReady.attachToObject(ActionWrapper);
ButtonReady.instance.dataset.data = JSON.stringify({ isReady: false });
ButtonReady.instance.dataset.data = JSON.stringify({ bReady: false });
ButtonReady.addClickHandler(toggleReady);

const GameCodeWrapper = new ButtonObject();
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/socket/waitingRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ const setupWaitingRoomSocket = () => {
PlayerManager.delete(socketID);
};

const onReadyPlayer = ({ playerID, isReady }) => {
const onReadyPlayer = ({ playerID, bReady }) => {
if (!SceneManager.isCurrentScene(WaitingRoom)) return;
const player = PlayerManager.get(playerID);
if (player) player.setReady(isReady);
if (player) player.setReady(bReady);
};

const onGetRoundData = ({ tellerID, cards, endTime }) => {
Expand Down
10 changes: 5 additions & 5 deletions src/frontend/utils/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Player = class {
color,
isTeller = false,
isCurrentPlayer = false,
isReady = false,
bReady = false,
} = {}) {
this.socketID = socketID;
this.nickname = nickname;
Expand All @@ -20,8 +20,8 @@ const Player = class {
};
this.isTeller = isTeller;
this.isCurrentPlayer = isCurrentPlayer;
this.isReady = isReady;
this.duck = new DuckCursorObject({ isReady, color });
this.bReady = bReady;
this.duck = new DuckCursorObject({ bReady, color });
this.votedCardID = null;
this.submittedCardID = null;
}
Expand All @@ -44,8 +44,8 @@ const Player = class {
}

setReady(value) {
if (this.isReady === value) return;
this.isReady = value;
if (this.bReady === value) return;
this.bReady = value;
this.duck.setVisibility(value, this.isCurrentPlayer);
}

Expand Down

0 comments on commit ec2d76a

Please sign in to comment.