Skip to content

Feature: Share the game link with Opponent - #296

Merged
siinghd merged 8 commits into
code100x:mainfrom
VK-RED:feature-share-game-link
Jun 18, 2024
Merged

Feature: Share the game link with Opponent#296
siinghd merged 8 commits into
code100x:mainfrom
VK-RED:feature-share-game-link

Conversation

@VK-RED

Copy link
Copy Markdown
Contributor

What does this PR do ?

  • Modified the JOIN_ROOM logic in GameManager.ts to handle the secondPlayer when joined via the game link.
  • Created ShareGame Component to display and copy the gameLink.

Resolves: #294

Screencast

Screencast.from.06-05-24.10.18.34.PM.IST.webm

@hkirat

Copy link
Copy Markdown
Contributor

/bounty $50

@VK-RED

Copy link
Copy Markdown
ContributorAuthor

Thanks Kirat !! Resolving the conflicts..

@hkirat
hkirat requested a review from siinghdJune 16, 2024 15:23
@siinghd

Copy link
Copy Markdown
Collaborator

@VK-RED will check it soon

@VK-RED

Copy link
Copy Markdown
ContributorAuthor

Thanks @siinghd !!

const [player1TimeConsumed, setPlayer1TimeConsumed] = useState(0);
const [player2TimeConsumed, setPlayer2TimeConsumed] = useState(0);

const [gameID,setGameID] = useState("");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why this?

doesnt const { gameId } = useParams(); work?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

No ser, that won't work. When the first player initially joins he will be at the route /game/random. After receiving the game_added message we will actually get the game ID, using which we create the link ..

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

oh, i see the login is different, would be better if we push the user who is wainting to the actual url with the ID: /game/id...

for now mergin this.


export const ShareGame = ({className,gameId}:{className?:string,gameId:string}) => {

const [url] = useState(window.origin+"/game/"+gameId);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why usestate here sir?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Agreed , will convert to a normal var.

@VK-RED

Copy link
Copy Markdown
ContributorAuthor

@siinghd you can check it now ...

@siinghd
siinghd merged commit 80464c0 into code100x:mainJun 18, 2024
Sign up for freeto 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.

Shareable links

3 participants

@VK-RED@hkirat@siinghd