Search code examples
androidgoogle-play-games

Google Play Games - Turn Based or Real Time multiplayer API?


Am developing a turn based multiplayer Cards Game using Google Play Games API.

In this game minimum 3 players must be online before starting & while playing the game. If I use TurnBased Multiplayer API with AutoMatching criteria then Game starts quickly after the createMatch code call like below. And it's not waiting until remaining two players to join

// Create a one-on-one automatch game.
public void startQuickMatch() {
    Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(
            2, 4, 0);

    TurnBasedMatchConfig tbmc = TurnBasedMatchConfig.builder()
            .setAutoMatchCriteria(autoMatchCriteria).build();

    // Start the match
    ResultCallback<TurnBasedMultiplayer.InitiateMatchResult> cb = new ResultCallback<TurnBasedMultiplayer.InitiateMatchResult>() {
        @Override
        public void onResult(TurnBasedMultiplayer.InitiateMatchResult result) {
            processResult(result);
        }
    };
    Games.TurnBasedMultiplayer.createMatch(Context.getApiClient(), tbmc).setResultCallback(cb);
}

If I used Realtime Multiplayer API, Then I can show user the Waiting Room until other players join. But it is not friendly to handle turn-based game actions.

So help me to choose between TurnBased and Realtime multiplayer API. If still TurnBased API is best then how to handle players waiting process before game start like in Realtime API


Solution

  • I think the answer here depends on the style of game you're developing. * If the gameplay is supposed to be synchronous (ie, all of us are moving around at once), you want to use the RTMP APIs. * If the gameplay is asynchronous (ie, I take my turn, two days later you take a turn, next week I come back and respond), the TBMP APIs are the right choice.