@Override public void conversationResuming(Conversation conversation, HttpServletRequest request) { ConversationContext<?> ctx = conversation.getCurrentContext(); if (ctx.useConversationEntityManager()) { if (conversation.getEntityManager() == null) { EntityManager em = entityManagerFactory.createEntityManager(); conversation.setEntityManager(em); if (log.isDebugEnabled()) { log.debug( "conv. " + conversation.getId() + " resuming: conversation's entityManager created: " + em.hashCode()); } } if (PrimeFacesUtil.isAjax(request)) { String componentId = request.getParameter("javax.faces.source"); if (componentId != null && ctx.ignoreUseConversationEntityManager(componentId)) { // _HACK_ as it is a tricky subject if (log.isDebugEnabled()) { log.debug( "Skip conversation's entityManager binding for ajax request coming from id: " + componentId); } return; } } bindEntityManager(conversation.getEntityManager()); } }
@Override public List<Response> getReplyPhrases(ConversationContext conversationContext) { WorldObject target = conversationContext.getTarget(); World world = conversationContext.getWorld(); YesNoResponse yesNoResponse = getYesNoResponse(target, world); return Arrays.asList( new Response(YES, "Yes" + yesNoResponse.getYesResponse()), new Response(NO, "No" + yesNoResponse.getNoResponse())); }
@Override public Response getReplyPhrase(ConversationContext conversationContext) { WorldObject performer = conversationContext.getPerformer(); WorldObject target = conversationContext.getTarget(); World world = conversationContext.getWorld(); if (isConversationAvailable(performer, target, world)) { int replyId = SEE_THROUGH; return getReply(getReplyPhrases(conversationContext), replyId); } return null; }
@Override public List<Response> getReplyPhrases(ConversationContext conversationContext) { WorldObject performer = conversationContext.getPerformer(); WorldObject target = conversationContext.getTarget(); World world = conversationContext.getWorld(); if (isConversationAvailable(performer, target, world)) { return Arrays.asList( new Response( SEE_THROUGH, "A good try, " + performer.getProperty(Constants.NAME) + ", but I saw you disguise yourself earlier")); } else { return new ArrayList<>(); } }
@Override public void handleResponse( int replyIndex, ConversationContext conversationContext, Conversation originalConversation) { WorldObject performer = conversationContext.getPerformer(); WorldObject target = conversationContext.getTarget(); World world = conversationContext.getWorld(); if (isConversationAvailable(performer, target, world)) { if (replyIndex == SEE_THROUGH) { RelationshipPropertyUtils.changeRelationshipValue( performer, target, -50, Actions.TALK_ACTION, Conversations.createArgs(originalConversation), world); } } }
@Override public void handleResponse(int replyIndex, ConversationContext conversationContext) { WorldObject performer = conversationContext.getPerformer(); WorldObject target = conversationContext.getTarget(); World world = conversationContext.getWorld(); if (replyIndex == THANKS || replyIndex == THANKS_AGAIN) { int relationshipBonus = calculateRelationshipIncrease(target, intPropertyToGive); RelationshipPropertyUtils.changeRelationshipValue( performer, target, relationshipBonus, Actions.TALK_ACTION, Conversations.createArgs(this), world); BuySellUtils.performerGivesItemToTarget(performer, target, intPropertyToGive, quantity); } else if (replyIndex == GET_LOST) { RelationshipPropertyUtils.changeRelationshipValue( performer, target, -20, Actions.TALK_ACTION, Conversations.createArgs(this), world); } }
@Override public Response getReplyPhrase(ConversationContext conversationContext) { WorldObject target = conversationContext.getTarget(); final int replyId; if ((target.getProperty(Constants.MATE_ID) != null) || (target.getProperty(Constants.CHILDREN).size() > 0)) { replyId = YES; } else { replyId = NO; } return getReply(getReplyPhrases(conversationContext), replyId); }