Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arthur #34

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Arthur #34

wants to merge 5 commits into from

Conversation

LDeng0205
Copy link
Contributor

No description provided.

…and eliminated create button on home page. new process should be home --> join --> lobby --> game. at the join page, the user is given the choice to either create a new lobby or join an existing one
<input id="msg" type="text" placeholder="Enter Message" required autocomplete="off" maxlength="60" />
</form>
</div>
</div>
Copy link
Contributor

@royh02 royh02 May 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to look at the backend to figure out how to properly create socket rooms and have players join them. Take a look at public/js/chat.js and public/js/save.js to see how the players and rooms are created. Specifically, try to understand this section in chat.js:

// Store player info locally
playerSave(username, room);

// Join chatroom
const info = JSON.parse(localStorage.getItem('user-info'));
socket.emit('joinRoom', info);

Then, you will need to port this over to lobby.js so that the room creation happens upon joining the lobby. You will need to make a room joining function that gets called in init() within lobby.js.

@royh02
Copy link
Contributor

royh02 commented May 30, 2021

@LDeng0205 I have added some TODOs and documentation in the recent commit. Go through them and re-request a review from me.

socket.emit('joinRoom', info);
document.getElementById('button-send').addEventListener('click', send);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Now add an event listener to the join/create game button (merge them) and once clicked, send a socket emission to the backend to check room code (call it room-check and add it in index.js)
Then have a socket emission go back to the frontend. Check how this is done with examples in index.js.

No current room with code -> create and join room
Exists room with code, game not started-> join room
Exists room with code, game started-> display error message in join.html using alerts or SweetAlert2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants