* Add the model fragments to the given NPC
*
* @param npc the NPC to enrich
*/
public void addRepairer(final SpeakerNPC npc) {
final RepairerBehaviour repairerBehaviour = new RepairerBehaviour(
new RepairingPriceCalculationStrategy(new HashSet<String>()),
new HashSet<String>(Arrays.asList("buckler")));
final Engine engine = npc.getEngine();
//sentence was not recognized
ChatCondition errorCondition = new SentenceHasErrorCondition();
engine.add(ConversationStates.ATTENDING, "repair", errorCondition,
false, ConversationStates.ATTENDING,
null, new ComplainAboutSentenceErrorAction());
//sentence recognized but not able to repair
ChatCondition cannotRepair = new AndCondition(
new NotCondition(new SentenceHasErrorCondition()),
new NotCondition(repairerBehaviour.getTransactionCondition()));
engine.add(ConversationStates.ATTENDING, "repair", cannotRepair,
false, ConversationStates.ATTENDING,
null, repairerBehaviour.getRejectedTransactionAction());
//recognized and able to repair
ChatCondition recognizedCondition = new AndCondition(
new NotCondition(new SentenceHasErrorCondition()),
repairerBehaviour.getTransactionCondition());
engine.add(ConversationStates.ATTENDING, "repair",
recognizedCondition, false, ConversationStates.REPAIR_OFFERED,
null, new RepairingBehaviourAction(repairerBehaviour));
engine.add(ConversationStates.ATTENDING,
ConversationPhrases.OFFER_MESSAGES, null,
false, ConversationStates.ATTENDING, "I can #repair items for you.", null);
ChatAction behaviourAcceptedAction =new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser raiser) {
repairerBehaviour.transactAgreedDeal(repairerBehaviour.parse(sentence), raiser, player);
}
};
engine.add(ConversationStates.REPAIR_OFFERED,
ConversationPhrases.YES_MESSAGES, null,