示例#1
0
 private void step2FindStorables()
 {
     NuggetaQuery nuggetaQuery = new NuggetaQuery();
     nuggetaQuery.setDomain(nameSpace);
     nuggetaQuery.setQuery("$WHERE content $LIKE '%RawMessage%' ");
     sampleIO.log("Step 2 : Find Storables ");
     gameApi.findStorablesRequest(nuggetaQuery, (FindStorablesResponse response)=>
     {
         if (response.getFindStorablesStatus() == FindStorablesStatus.SUCCESS)
         {
             List<Storable> storables = response.getStorables();
             if (storables.Count != 0)
             {
                 sampleIO.log("Step 2 : Find Storables successfull : found " + storables.Count + " storables\r\n");
                 storable = ((NRawMessage) storables[0]);
                 step3SaveStorable();
             } else
             {
                 sampleIO.log("Step 2 :Error Find Storables return no result \r\n");
                 onExit();
             }
         } else
         {
             sampleIO.log("Step 2 : Fail to Find Storables\r\n");
             onExit();
         }
     });
 }
 private void getInvitations()
 {
     NuggetaQuery nuggetaQuery = new NuggetaQuery();
     String playerId = "setPlayerId";
     nuggetaQuery.setQuery("$WHERE Invitee.Id = '" + playerId + "' $AND Status.Value = 0");
     gameApi.getInvitationsRequest(nuggetaQuery, (GetInvitationsResponse getInvitationsResponse)=>
     {
         GetInvitationsStatus getInvitationsStatus = getInvitationsResponse.getGetInvitationsStatus();
         if (getInvitationsStatus == GetInvitationsStatus.SUCCESS)
         {
             sampleIO.log("Get invitations response : " + getInvitationsResponse);
         } else
         {
             sampleIO.log("GetInvitations failed : " + getInvitationsStatus.ToString());
         }
     });
 }
 private void step2GetPlayers()
 {
     sampleIO.log("Step 2 : Get Players");
     NuggetaQuery playersQuery = new NuggetaQuery();
     playersQuery.setQuery("$WHERE Login='******'");
     gameApi.getPlayersRequest(playersQuery, (GetPlayersResponse response)=>
     {
         GetPlayersStatus status = response.getGetPlayersStatus();
         if (GetPlayersStatus.SUCCESS == status)
         {
             List<NPlayer> players = response.getPlayers();
             sampleIO.log("Step 1 : Get Players successfull : found " + players.Count + " players \r\n");
         } else
         {
             sampleIO.log("Step 1 : Fail to  Get Players reason: " + status.name() + "\r\n");
             onExit();
         }
     });
 }
 private void step4GetPlayerTwo()
 {
     sampleIO.log("Step 4 : GetPlayerTwo");
     NuggetaQuery playersQuery = new NuggetaQuery();
     playersQuery.setQuery("$WHERE Login = '******'");
     gameApi.getPlayersRequest(playersQuery, (GetPlayersResponse getPlayersResponse)=>
     {
         if (GetPlayersStatus.SUCCESS == getPlayersResponse.getGetPlayersStatus())
         {
             List<NPlayer> players = getPlayersResponse.getPlayers();
             if (players.Count == 1)
             {
                 playerTwo = players[0];
                 step5AskForFriendPlayerTwo();
             } else
             {
                 sampleIO.log("Step 4 : GetPlayerTwo :  retrieve more than one player !");
                 onExit();
             }
         } else
         {
             sampleIO.log("Step 4 : GetPlayerTwo failure " + getPlayersResponse.getGetPlayersStatus());
             onExit();
         }
     });
 }