AppWarpS2 server turn modification

0 votes
Hi,

I am making a turn based game using appwarps2 server as I need custom move managment. For my game to work perfectly I need to work the server like this-

1. Client Sends a move

2. Server handel the move request. Validate the move and add some additional info with it

3. Server sets the next turn player

4. Finally server send the updated move info/ notify the clients onMoveComplet.

Currently I am follwing the RummyDemoCard game server side sample. In the handelMoveRequest section I can modify and validate the moveData and set the next turn player using SetNextTrun and then I can send the updated move info (and the next turn player) using SendMoveUpdate().

My Problem is, when a client sends a move, all client get two notifications. One is the original move info from the client and the other is modified move info from the server. Now I only need the info from the server. So how can I do it? Do I need to change my approach?

Thanks.
asked Oct 30, 2014 in AppWarpS2 by apratim.056 (28 points)

1 Answer

+1 vote
 
Best answer
Hi,
 
When a player sends a move, all players get this notification. And since you are also using sendMoveUpdate on server, players again receives a notification. Therefore your players get notifications two times. You can disable the notifications for first move so that players receive notifications only when you call sendMoveUpdate().
 
You can disable the sending of notifications by setting the sendNotification parameter of HandlingResult to false in handleMoveRequest of BaseTurnRoomAdaptor.
 
If all you want is to change the next turn, you can simply use setNextTurn without disabling notifications or using sendMoveUpdate. All players will receive move notification with new next turn.
 
Thanks 
answered Oct 30, 2014 by Suyash Mohan (900 points)
selected Oct 31, 2014 by apratim.056
I have set the SendNotification parameter of HandlingResult to false in handelMoverRequest, but still I am getting two notification per move. Also would you please explain the parameters of SendMoveUpdate method.
Here is a summary about what I am trying to do-
  
@Override
    public void handleMoveRequest(IUser sender, String moveData, HandlingResult result){
       
        //disable this notification
        result.sendNotification=false;
               
        try{
            JSONObject data = new JSONObject(moveData);
     
            //Add validation message
           if(isMoveValid(data))
         data.put("isValid", "1");
          else return;

            gameRoom.SetNextTurn(GetNextTurnPlayer());
            gameRoom.sendMoveUpdate(sender,data.toString(),"what is this for?");
           
        }catch(Exception e){
            e.printStackTrace();
        }
Sorry, I mistakenly told you regarding normal rooms. For turnbased rooms, there is a special parameter 'doDefaultTurnLogic'. You have to set this parameter to false if you are changing the turn logic. This will also disable the notification.
public boolean sendMoveUpdate(IUser nextTurnUser, String moveData, String sender)

Here nextTurnUser is the IUser who's next turn has been set. moveData is the move message the players will receive. sender is the name of user who is sending this message. For e.g. there are three users A, B and C. A sent a move update 'abc'. On Server you have modified the logic for turn and set the next turn to C. Here C is nextTurnUser, 'abc' is moveUpdate and 'A' is sender. You can also use some custom string name like 'admin' , etc as sender to represent that you have modified the turn logic.
So, I am sending the next turn user through sendMoveUpdate. Then what is the use of SetNextTurn(IUser) method? Got little confused about this.
Setting up the doDefaultTurnLogic=false solves my problem :D
I guess I found my answer. Would you please explain me where I should use the SetNextTurn(IUser user) method?
You don't need to call setNextTurn. sendMoveUpdate will set the next turn itself. setNextTurn is provided in case you want to change the turn but don't want to use sendMoveUpdate
Thanks a lot for your help. :)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...