1
\$\begingroup\$

This is the first game I have developed. Please correct me if I'm mistaken.

I want to build an online 2-player turn based card game (Shithead). I want to code it in Java as that is what I have most experience in.


Networking

From my research, I've gathered that for turn based card games a TCP connection is best (reliability over the need for constant packets). I plan to have a single Java game server that will be able to host multiple concurrent games using sockets to pair clients together in an events-based manor. I've read that it makes most sense to have the game state on the server in order to protect against cheating etc.

  1. Client1 (C1) sends move to server.
  2. Server validates move. If valid - Server sends updated game state (with certain information hidden such as opponents hand) to clients & tells C1 to wait for C2 and for C2 to make a move.
  3. C2 sends move to server. Repeat.

Does my plan sound sensible? I don't want to start going down this route if I've miss-understood something.

A problem I am having is knowing which java frameworks (if any? SpringBoot?) to use to achieve this. Could anyone recommend any to me?


Client

I was planning on making the client browser-based but after some thought I think I would prefer to make a desktop client. I plan to make a Java client that uses the JavaFX GUI library that the user interacts with by clicking on cards to perform certain actions - would I be able to embed this in a webpage if I changed my mind? Would it take a lot of work?

At this point I don't want to put too much time into making a fancy GUI (by using a more sophisticated game engine) as I'd rather focus on making a mini-max AI player (and given I have time, a neural network AI to learn from playing tons of games against the mini-max AI).

\$\endgroup\$
  • 2
    \$\begingroup\$ Generally StackExchange Q&A does much better with questions of the form "How do I solve this specific problem?" than it does with "Here is how I'm thinking of solving my problem, is that OK?" You do not need the blessing of Internet strangers to try putting your plan into practice. If it works, great, you're done, without waiting and wading through a pile of opinions. If it doesn't work, then you'll have a concrete problem to ask about, and much deeper knowledge from this experience to inform your question. I'd say try it! \$\endgroup\$ – DMGregory Jan 28 at 13:58
  • \$\begingroup\$ Your idea is good in general. However, a little bit of software architecture would go a long way. There are decision here that you can push back. You have already figured out that you can deal with graphics later. You can do something similar with the network if you have a good architecture. What you want is to isolate external systems (such as the UI and the network), and have a library that is purely the game logic. You might be able to prototype with a text interface and the library, and then move to a networked solution where the library is in the server. By the way, I suggest a Web API. \$\endgroup\$ – Theraot Jan 28 at 14:58
  • \$\begingroup\$ @Theraot I was planning to build a text based interface first as I built the game logic. Could you expand on what you mean by a web API please? Thanks for the comments. \$\endgroup\$ – theJavaGuy Jan 28 at 17:47
  • \$\begingroup\$ it might sound obvious - but there is a very good example on how to network on 1024monkeys \$\endgroup\$ – Martin Frank Feb 20 at 7:34

Your Answer

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

Browse other questions tagged or ask your own question.