I'm making a Pokémon clone in java as a student project. I'm using javafx for this. One of the features I need to work on is letting players play against each others. Only local multiplayer is required. Implement other words, the players can open up 2 instances of the game on the same pc and be able to play against each other.
I'm done with implementing the logic necessary for the core game but I'm not sure about how to connect it to networking. In my game their is a trainer class. I have a loop for battle where I wait for commands ( an object) each trainer has chosen for the turn. For players, that's the move they selected. For the ai, it's a move chosen at random. The loop will end only when all trainers ( including player) has chosen commands and the turn will play out.
I'm a novice at network programming but here's what I want to try. I know that you can send strings through sockets. The networked trainer class will work like the player trainer class but will wait for instructions from the other player's socket and convert them to commands which my game loop can use. Is this a viable approach?