-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: master
Are you sure you want to change the base?
Conversation
…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
public/lobby.html
Outdated
<input id="msg" type="text" placeholder="Enter Message" required autocomplete="off" maxlength="60" /> | ||
</form> | ||
</div> | ||
</div> |
There was a problem hiding this comment.
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
.
Added todos and documentation
@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); | ||
} | ||
|
There was a problem hiding this comment.
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
No description provided.