I’m making a browser-based card game (think Magic: The Gathering) and looking to use Nakama, but there’s one part I’m not sure about.
A player’s library, where they draw cards from to their hand, has to be “secret” – to prevent cheating the player(s) cannot know what the next card will be until they draw it. This of course means that piece of game state cannot be stored on the client side, but when they draw it there needs to be little or no latency in revealing the card so as to have a smooth play experience.
So while most of the freely viewable shared state of the game (the cards in play) is shared equivalently to all players, a player’s library only exists server-side and can only be accessed through an API call so that whenever a player looks at their library, all players know that they looked because the API call will also update the little log of actions taken by players. So in this way the players cannot secretly cheat without anyone knowing.
My initial effort to build this was with firebase, and the latency was too much – calls to their cloud functions API had around 0.5s - 1.5s delay. It felt clumsy.
Will I be able to accomplish this with nakama in a latency-free way? In short, will I be able to make parts of game state only accessible through dedicated API calls, and when those API calls update game state, will client state update fast enough that nobody will notice a delay?
(Also if anyone thinks of a better way of accomplishing this I’m by all means open to suggestions!)
1 Like
Hi @nakamatester1 welcome
I’m making a browser-based card game (think Magic: The Gathering) and looking to use Nakama, but there’s one part I’m not sure about.
This is a perfect game type for Nakama. You could implement it with the authoritative multiplayer engine as an active turn-based multiplayer game or you could use RPCs and the storage engine to implement it with a more asynchronous turn-based approach (I’m not familiar with the specifics of the game design in MtG).
A player’s library, where they draw cards from to their hand, has to be “secret” – to prevent cheating the player(s) cannot know what the next card will be until they draw it.
This card draw phase is best implemented as a phase of match handler logic if you want the game to play out as an active multiplayer experience.
Will I be able to accomplish this with nakama in a latency-free way? In short, will I be able to make parts of game state only accessible through dedicated API calls, and when those API calls update game state, will client state update fast enough that nobody will notice a delay?
Yes absolutely. Have a look at the authoritative multiplayer engine documentation and also have a look at our TicTacToe multi-round active turn-based multiplayer example. While the logic in Tic Tac Toe is much much simpler the patterns for how to design and structure your code for this kind of multiplayer project are exactly the same.
1 Like
Thanks very much! The game actually isn’t enforcing a turn-based play since players can take actions during each other’s turns, but from what you’ve said it sounds like even without enforcing turns Nakama will allow what I want.
@nakamatester1 Yep the authoritative multiplayer engine in Nakama is not limited to turn-based games in fact its used in many realtime party games and other more complex multiplayer game types like Battle Royale. Let me know if you’d like to discuss what your multiplayer netcode could look like for the MtG game and I’ll try to share some suggestions.
1 Like