diff --git a/src/games/stendhal/server/entity/npc/quest/DeliverItemTask.java b/src/games/stendhal/server/entity/npc/quest/DeliverItemTask.java index 79752dab242..67742f8d2f6 100644 --- a/src/games/stendhal/server/entity/npc/quest/DeliverItemTask.java +++ b/src/games/stendhal/server/entity/npc/quest/DeliverItemTask.java @@ -116,21 +116,18 @@ public void fire(final Player player, final Sentence sentence, final EventRaiser final String name = Rand.rand(getAllowedCustomers(player)); final DeliverItemOrder data = orders.get(name); + Map params = new HashMap<>(); + params.put("flavor", data.getFlavor()); + params.put("customerName", Grammar.quoteHash("#" + name)); + params.put("time", Grammar.quantityplnoun(data.getExpectedMinutes(), "minute", "one")); + final Item pizza = SingletonRepository.getEntityManager().getItem("pizza"); pizza.setInfoString(data.getFlavor()); - pizza.setDescription("You see a " + data.getFlavor() + "."); - pizza.setBoundTo(name); + pizza.setDescription(StringUtils.substitute("You see a [flavor].", params)); + pizza.setBoundTo(player.getName()); if (player.equipToInventoryOnly(pizza)) { - npc.say("You must bring this " - + data.getFlavor() - + " to " - + Grammar.quoteHash("#" + name) - + " within " - + Grammar.quantityplnoun(data.getExpectedMinutes(), "minute", "one") - + ". Say \"pizza\" so that " - + name - + " knows that I sent you. Oh, and please wear this uniform on your way and don't drop this " + data.getFlavor() + " on the ground! Our customers want it fresh."); + npc.say(StringUtils.substitute("You must bring this [flavor] to [customerName] within [time]. Say \"pizza\" so that [customerName] knows that I sent you. Oh, and please wear this uniform on your way.", params)); player.setOutfit(UNIFORM, true); player.setQuest(QUEST_SLOT, 0, name); new SetQuestToTimeStampAction(questSlot, 1).fire(player, null, npc); @@ -162,13 +159,14 @@ ChatAction buildRemindQuestAction(String questSlot) { return new ChatAction() { @Override public void fire(final Player player, final Sentence sentence, final EventRaiser npc) { - final String[] questData = player.getQuest(QUEST_SLOT) - .split(";"); - final String customerName = questData[0]; + final String customerName = player.getQuest(QUEST_SLOT, 0); if (customerName.equals("rejected")) { buildStartQuestAction(questSlot).fire(player, sentence, npc); return; } + Map params = new HashMap<>(); + params.put("customerName", Grammar.quoteHash("#" + customerName)); + if (isDeliveryTooLate(player)) { // If the player still carries any pizza due for an NPC, // take it away because the baker is angry, @@ -179,13 +177,10 @@ public void fire(final Player player, final Sentence sentence, final EventRaiser player.drop(pizza); } } - npc.say("I see you failed to deliver the pizza to " - + customerName - + " in time. Are you sure you will be more reliable this time?"); + npc.say(StringUtils.substitute("I see you failed to deliver the pizza to [customerName] in time. Are you sure you will be more reliable this time?", params)); npc.setCurrentState(ConversationStates.QUEST_OFFERED); } else { - npc.say("You still have to deliver a pizza to " - + customerName + ", and hurry!"); + npc.say(StringUtils.substitute("You still have to deliver a pizza to [customerName], and hurry!", params)); npc.setCurrentState(ConversationStates.ATTENDING); } } diff --git a/tests/games/stendhal/server/maps/quests/PizzaDeliveryTest.java b/tests/games/stendhal/server/maps/quests/PizzaDeliveryTest.java index 8771aaad1bf..248705576bb 100644 --- a/tests/games/stendhal/server/maps/quests/PizzaDeliveryTest.java +++ b/tests/games/stendhal/server/maps/quests/PizzaDeliveryTest.java @@ -434,7 +434,7 @@ public void testQuest() { en.step(player, "pizza"); assertEquals("I need someone who helps me delivering pizza. Maybe you could do that #task.", getReply(npc1)); en.step(player, "task"); - assertEquals("You still have to deliver a pizza to Cyk, and hurry!", getReply(npc1)); + assertEquals("You still have to deliver a pizza to #Cyk, and hurry!", getReply(npc1)); en.step(player, "bye"); assertEquals("Bye.", getReply(npc1)); @@ -491,7 +491,7 @@ public void testQuest() { en.step(player, "hi"); assertEquals("Hallo! Glad to see you in my kitchen where I make #pizza and #sandwiches.", getReply(leander)); en.step(player, "task"); - assertEquals("I see you failed to deliver the pizza to Haizen in time. Are you sure you will be more reliable this time?", getReply(leander)); + assertEquals("I see you failed to deliver the pizza to #Haizen in time. Are you sure you will be more reliable this time?", getReply(leander)); // Leander will take the pizza List pizzas = player.getAllEquipped("pizza"); assertEquals(pizzas.size(), 1);