Clips3 Posted July 5, 2017 Share Posted July 5, 2017 Hello all, I'm working on a standard poker game and I have a few questions pertaining to handling the turn based functionality. First, this poker game is heads up so there are only two players. The deck is split evenly (26 cards a player), and at the beginning of the game each player draws 5 cards from their respective decks. On each player's turn, they draw a card from their deck and then play one card from their hand into the play area/discard area. My question is, if this turn based game is played on one device, how would i handle the different views? i.e. once a player draws and places a card, their turn is over and next player draws a card from their deck then plays. This continues until all the cards are played, but obviously you're not supposed to see the other player's cards. As a follow up, how would I handle the same scenario if I wanted to make the game available for multiplayer online? Any help will be greatly appreciated! Link to comment Share on other sites More sharing options...
Skeptron Posted July 5, 2017 Share Posted July 5, 2017 This kind of game might require a server. You could go with a full peer-to-peer networking solution if the game isn't really serious and you allow cheating, but if you want to app to be cheating-proof you'll need to have a server. The server will shuffle the cards and send to the players their cards (and not their opponents'), will time the player turns (and probably do something if time is out), and decide who wins and who looses. This isn't real-time stuff so it should be quite easy to implement. You could use websockets or even long-polling, whatever you prefer. Link to comment Share on other sites More sharing options...
Clips3 Posted July 5, 2017 Author Share Posted July 5, 2017 Thanks for the advice Skeptron. I'm a complete noob at this. I would like it to be cheat proof, and thus per your recommendation would need a server. How the heck would I go about this? Can you recommend any resources. Link to comment Share on other sites More sharing options...
raaaahman Posted July 6, 2017 Share Posted July 6, 2017 For your "hot seat" mode (one device), I remember playing Heroes of Might & Magic III/V with friends and family a lot, and a simple black screen between each player's turn with a "ready" button totally did the trick. If you want to program a server for a game and you're already into javascript, Node.js could be a solution. Free Code Camp offers lessons and activities about it for free, though I didn't try it out myself so I can't tell you what it's worth. Stay motivated! Link to comment Share on other sites More sharing options...
Recommended Posts