}
@Override
public void addToWorld() {
final CroupierNPC ricardo = (CroupierNPC) SingletonRepository.getNPCList().get("Ricardo");
final Map<Integer, Pair<String, String>> prizes = initPrices();
ricardo.setPrizes(prizes);
final StendhalRPZone zone = ricardo.getZone();
Sign blackboard = new Sign();
blackboard.setPosition(25, 0);
blackboard.setEntityClass("blackboard");
StringBuilder prizelistBuffer = new StringBuilder("PRIZES:\n");
for (int i = 18; i >= 13; i--) {
prizelistBuffer.append("\n" + i + ": " + prizes.get(i).first());
}
blackboard.setText(prizelistBuffer.toString());
zone.add(blackboard);
blackboard = new Sign();
blackboard.setPosition(26, 0);
blackboard.setEntityClass("blackboard");
prizelistBuffer = new StringBuilder("PRIZES:\n");
for (int i = 12; i >= 7; i--) {
prizelistBuffer.append("\n" + i + ": " + prizes.get(i).first());
}
blackboard.setText(prizelistBuffer.toString());
zone.add(blackboard);
ricardo.add(ConversationStates.ATTENDING, "play", null,
ConversationStates.QUESTION_1,
"In order to play, you have to stake " + STAKE
+ " gold. Do you want to pay?", null);
ricardo.add(ConversationStates.QUESTION_1,
ConversationPhrases.YES_MESSAGES,
new PlayerHasItemWithHimCondition("money", STAKE),
ConversationStates.ATTENDING,
"OK, here are the dice. Just throw them when you're ready. Good luck!",
new ChatAction() {
public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
player.drop("money", STAKE);
final Dice dice = (Dice) SingletonRepository.getEntityManager()
.getItem("dice");
dice.setCroupierNPC((CroupierNPC) npc.getEntity());
player.equipOrPutOnGround(dice);
}
});
ricardo.add(ConversationStates.QUESTION_1,
ConversationPhrases.YES_MESSAGES,
new NotCondition(new PlayerHasItemWithHimCondition("money", STAKE)),
ConversationStates.ATTENDING,
"Hey! You don't have enough money!", null);
ricardo.add(
ConversationStates.QUESTION_1,
ConversationPhrases.NO_MESSAGES,
null,
ConversationStates.ATTENDING,
"Coward! How will you ever become a hero when you risk nothing?",