Package com.appspot.bambugame.server

Examples of com.appspot.bambugame.server.HangmanQuestionSuggestionCommand


                JSONObject tPrivatePlurkResponse = PlurkService.getInstance().responseGet( String.valueOf( tPlurkID ) ); //getPlurkService().using( Responses.class ).get( tPlurkID );
                JSONArray tPrivatePlurkResponseArray = tPrivatePlurkResponse.getJSONArray("responses");
               
                System.out.println("Suggestion private plurk response is : " + tPrivatePlurkResponse);
               
                HangmanQuestionSuggestionCommand tSuggestionCommand = new HangmanQuestionSuggestionCommand( tPrivatePlurkResponseArray );
               
                System.out.println("Suggestion command status is : " + tSuggestionCommand.toString());
               
                if (!tSuggestionCommand.hasGreetingBeingPlurked())
                {
                    for (int i = 0; i < HangmanQuestionSuggestionCommand.cGreetingResponseStringArray.length; i++)
                    {
                        PlurkService.getInstance().responseAdd( String.valueOf (tPlurkID), HangmanQuestionSuggestionCommand.cGreetingResponseStringArray[i], Qualifier.SAYS );
                        try { Thread.sleep(100); } catch (Exception ex) {}
                    }
                }
               
                if (!tSuggestionCommand.hasSentenceOfferBeingPlurked())
                {
                    PlurkService.getInstance().responseAdd( String.valueOf (tPlurkID), HangmanQuestionSuggestionCommand.cSentenceOfferResponseString, Qualifier.SAYS );
                    return;
                }
               
                if (!tSuggestionCommand.hasQuestionBeenSubmittedByUser()) return;
               
                if (!tSuggestionCommand.isSubmittedQuestionValid())
                {
                    if (!tSuggestionCommand.hasInvalidReasonBeenPlurked())
                    {
                        // sorry, the sentence is not valid due to..
                        String tInvalidReason = HangmanQuestionSuggestionCommand.cInvalidReasonResponseString + tSuggestionCommand.getQuestionInvalidityReason();
                        PlurkService.getInstance().responseAdd( String.valueOf (tPlurkID), tInvalidReason, Qualifier.SAYS );
                       
                        try { Thread.sleep(100); } catch (Exception ex) {}
                       
                        PlurkService.getInstance().responseAdd( String.valueOf (tPlurkID), "please re-type the question by using the !question command again", Qualifier.SAYS );
                    }
                    return;
                }
               
                // at this point, the question would be valid
               
                if (!tSuggestionCommand.hasConfirmationBeenPlurked())
                {
                    // plurk confirmation
                    String tConfirmationString = HangmanQuestionSuggestionCommand.cNeedConfirmationResponseStringStart +
                                                 "the question is " +
                                                 tSuggestionCommand.getValidQuestionString() +
                                                 " and with hint " +
                                                 tSuggestionCommand.getValidHintString() +
                                                 HangmanQuestionSuggestionCommand.cNeedConfirmationResponseStringEnd;
                   
                    PlurkService.getInstance().responseAdd( String.valueOf (tPlurkID), tConfirmationString, Qualifier.SAYS );
                    try { Thread.sleep(100); } catch (Exception ex) {}
                    PlurkService.getInstance().responseAdd( String.valueOf (tPlurkID), "or type !newquestion to cancel and re-start the question submission", Qualifier.SAYS );
                    return;
                }
               
                if (!tSuggestionCommand.hasConfirmationBeenGivenByUser())
                {
                    return;
                }
               
                // at this point, if the question is not stored yet, we should store the question given by the user
                if (!tSuggestionCommand.hasQuestionBeenAccepted())
                {
                    // store at datastore
                    String tSuggesterUserName = tPrivatePlurkResponse.getJSONObject("friends").getJSONObject( "" + tSuggestionCommand.getSubmitterID() ).getString( "nick_name" );
                   
                    HangmanQuestionSuggestion tSuggestion = new HangmanQuestionSuggestion(tSuggestionCommand.getValidQuestionString(),
                                                                                          tSuggestionCommand.getValidHintString(),
                                                                                          null, // extras
                                                                                          tSuggestionCommand.getSubmitterID(),
                                                                                          tSuggesterUserName,
                                                                                          tPlurkID);
                   
                    ObjectifyService.begin().put( tSuggestion );
                   
View Full Code Here

TOP

Related Classes of com.appspot.bambugame.server.HangmanQuestionSuggestionCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.