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

Make the UNO button functioning #166

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

Abhishek-Punhani
Copy link

Making the uno button functioning
Set uno button to trigger Announce_Uno Event and added a handler for this event" -m
Fixes : #159

Checklist

  • I have tested these changes locally.
  • I have reviewed the code and ensured it follows the project's coding guidelines.
  • I have updated the documentation, if necessary.
  • I have assigned reviewers to this pull request.

Screenshots (if applicable)

[If your changes include any visual updates, provide screenshots here.]

Copy link

vercel bot commented Jun 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
multiplayer-uno ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2024 6:34am

Copy link
Collaborator

@kuv2707 kuv2707 left a comment

Choose a reason for hiding this comment

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

The second commit is alright, left suggestions for the first.

Also I notice that we aren't updating vulnerableToUno on throw_card, as we are in the backend.

image

See throwCard.ts
You can add a commit adding this, or make a separate PR.

Comment on lines 12 to 16
if (gameState?.players) {
modal.show(<GamePropertiesModal />, 'large', [], false);
}
// eslint-disable-next-line
}, [gameState]);
}, [gameState?.players.length, gameState.id]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be better to make the dependency array empty. So that the modal pops up only once at the start of the game.
In a different PR, we are introducing a button to show the modal in the middle of the game, and are also adding more options to the modal.

So this modal will be automatically shown once, when the user joins. The if statement is therefore not required too

Copy link
Author

@Abhishek-Punhani Abhishek-Punhani Jun 25, 2024

Choose a reason for hiding this comment

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

But we need to show the number of players joined so it will update only if the modal is updated following a change in length of players array and also for the one who joins the game game id also changes(from null) so to show the game id we need to reload the modal .
We can incorporate a creator or admin in game and instead of showing Start Game , can show Username's Room Created ! , and the players that join will see Join Username's Room?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good points.

  • We do want the modal content to change based on some changes to game state. Also, we only need to change the content if the modal is in display in the first place. I think we'd want to update the content on JOIN_GAME (since player count increases) and START_GAME (we'd want to close the modal once the admin starts the game).
  • The change of gameId from null to a value won't be visible to the modal, since i have added a commit which mounts the Game component (of which the modal is a part) only after we have a non-null game id. So we dont need to worry about re-rendering the modal then.
  • A room is created the moment a user clicks on Create Game. We can show a toast saying "Room Created!"
  • Once the joining players have opened a room, it wouldn't make much sense asking them if they want to join. If they didn't, they wouldn't have entered the game code / clicked on the url.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should improve the modal system to be able to efficiently handle dynamic content.
The current implementation is such that if the user has opened some other modal (like rules etc) and someone joins the game, the GamePropertiesModal will pop up abruptly. That is just bad UX

Copy link
Collaborator

Choose a reason for hiding this comment

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

Here's something we can do -

  • Remove the dependencies from this useEffect, so that it only appears once when the game page loads (with valid game data)

  • Make the following changes to the modal context -

  • Add a field id to uniquely identify each modal. We pass the id when calling modal.show

  • Add a function to only change the content of the modal if the modal of given id is rendering.
    So sth like modal.setContent("abc",<p>hii</p> will only set the content to hii if a modal with id abc is already visible on the screen.

  • Then here, in this modal.show call, we pass in the id for this modal (say "gameProperties")

  • Add another useEffect which calls modal.setContent("gameProperties",<...>) and include in its dependency array gameState.players etc

Copy link
Collaborator

Choose a reason for hiding this comment

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

What are your thoughts on this?

Copy link
Author

@Abhishek-Punhani Abhishek-Punhani Jun 25, 2024

Choose a reason for hiding this comment

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

Yeah I agree that joining player will see different content in this way

modal.show(<GamePropertiesModal />, 'large', [], false);
}
// eslint-disable-next-line
}, [gameState]);
}, []); // todo :Fix the dependency array
const announceGame = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can better be called as announceUNO

Copy link
Collaborator

@kuv2707 kuv2707 left a comment

Choose a reason for hiding this comment

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

Left a minor comment. Also please amend the commit message to match the format

There's also a merge conflict to be resolved

Set uno button to trigger Announce_Uno Event

 Also added a handler for this event

Fixes : shivansh-bhatnagar18#159
Copy link
Collaborator

@kuv2707 kuv2707 left a comment

Choose a reason for hiding this comment

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

LGTM

@kuv2707 kuv2707 merged commit 72ddf1c into shivansh-bhatnagar18:master Jun 26, 2024
8 checks passed
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.

Make the UNO button functioning
2 participants