android - Cannot close turnbased multiplayer match with Google Play Games -


i have problem closing game after last player close last match. turn scheme is:

  1. player a
  2. player b
  3. player b
  4. player a
  5. player a
  6. player b

the game works in turn "6" when player b try close match, player see matsh "my turn" , not "completed"

here there code thar rules turns , game ended:

@override     public void ongameend(final nmxgamedata updateddata) {         super.ongameend(updateddata);          if (updateddata.getmatchnumber() == nmxgameconfig.matches) {             boolean iwin = updateddata.getresultpoints()[1] > updateddata.getresultpoints()[0];             boolean tile = updateddata.getresultpoints()[1] == updateddata.getresultpoints()[0];              participantresult opponentparticipantresult;             participantresult myparticipantresult;              if (tile) {                 opponentparticipantresult = new participantresult(getopponentid(), participantresult.match_result_tie, 1);                 myparticipantresult = new participantresult(getcurrentplayerid(), participantresult.match_result_tie, 1);             } else {                 if (iwin) {                     opponentparticipantresult = new participantresult(getopponentid(), participantresult.match_result_loss, 2);                     myparticipantresult = new participantresult(getcurrentplayerid(), participantresult.match_result_win, 1);                 } else {                     opponentparticipantresult = new participantresult(getopponentid(), participantresult.match_result_win, 1);                     myparticipantresult = new participantresult(getcurrentplayerid(), participantresult.match_result_loss, 2);                 }             }              arraylist<participantresult> participantresultarraylist = new arraylist<>();             participantresultarraylist.add(opponentparticipantresult);             participantresultarraylist.add(myparticipantresult);              games.turnbasedmultiplayer.finishmatch(getapiclient(), match.getmatchid(), new gson().tojson(updateddata).getbytes(), opponentparticipantresult, myparticipantresult).setresultcallback(new resultcallback<turnbasedmultiplayer.updatematchresult>() {                 @override                 public void onresult(turnbasedmultiplayer.updatematchresult updatematchresult) {                     finish();                 }             });          } else if (updateddata.getmatchnumber() < nmxgameconfig.matches) {              if (getnextplayerindex(updateddata.getmatchnumber()) != getnextplayerindex(updateddata.getmatchnumber() - 1)) {                 games.turnbasedmultiplayer.taketurn(getapiclient(), match.getmatchid(), new gson().tojson(updateddata).getbytes(), getnextparticipantid());             } else {                 games.turnbasedmultiplayer.taketurn(getapiclient(), match.getmatchid(), new gson().tojson(updateddata).getbytes(), getcurrentplayerid());                 startactivity(startnewonlinegameintent(this, updateddata, match.getmatchid()));             }             finish();         }       }      private string getcurrentplayerid() {         return match.getparticipantid(games.players.getcurrentplayerid(getapiclient()));      }      private string getopponentid() {         (string id : match.getparticipantids()) {             if (!id.equals(getcurrentplayerid())) {                 return id;             }         }         return null;     }      private int getnextplayerindex(int nextroundindex) {         nextroundindex = nextroundindex + 1;         return (nextroundindex / 2) % 2;     } 

i figured out.

i don't know if desired behavior when in round 6 player_b calls:

games.turnbasedmultiplayer.finishmatch(getapiclient(), match.getmatchid(), new gson().tojson(updateddata).getbytes(), opponentparticipantresult, myparticipantresult).setresultcallback(new resultcallback<turnbasedmultiplayer.updatematchresult>() {                 @override                 public void onresult(turnbasedmultiplayer.updatematchresult updatematchresult) {                     finish();                 }             }); 

the turn goes player_a see match "my turn". @ point player must call games.turnbasedmultiplayer.finishmatch(getapiclient(), match.getmatchid()) (without playing real game) , game completed both players


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -