0

I'd like to try to create an application where 2 players can play chess online. The (possibly) novel feature would be that the process for joining a game would be similar to how Typeracer works. The first player creates a lobby then shares a link. The friend can then click the link to join the session immediately.

However, I'm a beginner when it comes to how information is shared over the internet. I've only created a few REST APIs and games in Java/Python so a lot of this would be new to me.

The first question I have is how/where would I actually implement the logic for this game? Would everything be done client-side (I'd probably use React so I'd then have a js library to hold all game rules) Or is everything done on the server?

Also, how would I keep the player's game clients in sync? I've heard about websockets but any elaboration would be helpful.

Lastly, how could I go about implementing the feature where users can share their game link to get the other player to join?

For context, I have quite a bit of experience with React for UI, I've used NodeJS on the server, and I'm currently learning about how to create web APIs with ASP.NET web API (C#). I figure that I'll be able to create the board UI in React and handle any animations with CSS. If that's not a good idea let me know!

Overall I'm not really sure how I'll tie this all together so a big picture view might help; and I've love to hear about any frameworks or tools that might make this job easier; thanks for the help in advance!

2
  • 1
    So what exactly is the question? As it stands all I can really say is: Yes, you've got as high level description of your problem. Keep on working on it. – Kain0_0 May 25 '20 at 2:57
  • @Kain0_0 Looking for advice on how people have dealt with the 3 problems stated, and any other help I could get so I don't go down the wrong path. But yes, I'll keep working on it. – Brad Stevanus May 26 '20 at 14:14
2

The first question I have is how/where would I actually implement the logic for this game? Would everything be done client-side (I'd probably use React so I'd then have a js library to hold all game rules) Or is everything done on the server?

That's completely up to you. I've done exactly this with a project that used no fixed server. It was fully peer to peer. But someone has to be able to publicly open ports.

Also, how would I keep the player's game clients in sync? I've heard about websockets but any elaboration would be helpful.

We did it with a timestamped md5 digest of the game state. So long as that matched we knew things were good. If it failed we resynced state. A digest might be a bit much for chess since its state is small. We were letting you play any board game in existance.

Lastly, how could I go about implementing the feature where users can share their game link to get the other player to join?

A connection string needs a ip and a port. Just let your player copy that into an email/chat/post it with their friend and they're good to go.

If you have a fixed server this can become a URL with a site and a protocol.

1
  • This is very helpful, thank you! I'Il look into these things. – Brad Stevanus May 26 '20 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.