Skip to content

Commit

Permalink
generalized remaining occurrences of "pizza"
Browse files Browse the repository at this point in the history
  • Loading branch information
nhnb committed Sep 17, 2023
1 parent 247eea1 commit 373151d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ public void fire(final Player player, final Sentence sentence, final EventRaiser
Map<String, Object> params = new HashMap<>();
params.put("flavor", data.getFlavor());
params.put("tip", data.getTip());
for (final Item pizza : player.getAllEquipped(deliverItemTask.getItemName())) {
final String flavor = pizza.getInfoString();
for (final Item item : player.getAllEquipped(deliverItemTask.getItemName())) {
final String flavor = item.getInfoString();
if (data.getFlavor().equals(flavor)) {
player.drop(pizza);
// Check whether the player was supposed to deliver the
// pizza.
player.drop(item);
// Check whether the player was supposed to deliver this item.
if (player.hasQuest(questSlot) && !player.isQuestCompleted(questSlot)) {
if (deliverItemTask.isDeliveryTooLate(player, questSlot)) {
npc.say(StringUtils.substitute(data.getRespondToSlowDelivery(), params));
Expand All @@ -93,16 +92,13 @@ public void fire(final Player player, final Sentence sentence, final EventRaiser
new IncrementQuestAction(questSlot, 2, 1).fire(player, null, npc);
deliverItemTask.putOffUniform(player);
} else {
// This should not happen: a player cannot pick up a pizza from the ground
// that did have a flavor, those are bound. If a pizza has flavor the player
// should only have got it from the quest.
// But could be from a previous attempt to deliver.
// Item could be from a previous failed attempt to do this quest.
npc.say(respondToItemWithoutQuest);
}
return;
}
}
// The player has brought the pizza to the wrong NPC, or it's a plain pizza.
// The player has brought the item to the wrong NPC, or it's a plain item.
npc.say(StringUtils.substitute(respondToItemForOtherNPC, params));

} else {
Expand Down Expand Up @@ -144,7 +140,7 @@ void build(SpeakerNPC mainNpc, String questSlot, ChatCondition questCompletedCon
for (final String name : deliverItemTask.getOrders().keySet()) {
final SpeakerNPC npc = NPCList.get().get(name);
if (npc == null) {
logger.error("NPC " + name + " is used in the Pizza Delivery quest but does not exist in game.", new Throwable());
logger.error("NPC " + name + " is used in the DeliveryItemQuest " + questSlot + " but they do not exist in game.", new Throwable());
continue;
}

Expand Down
10 changes: 5 additions & 5 deletions src/games/stendhal/server/entity/npc/quest/DeliverItemTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ public void fire(final Player player, final Sentence sentence, final EventRaiser
params.put("customerName", Grammar.quoteHash("#" + customerName));

if (isDeliveryTooLate(player, questSlot)) {
// If the player still carries any pizza due for an NPC,
// take it away because the baker is angry,
// If the player still carries any item due for a customer NPC,
// take it away because the quest giver NPC is angry,
// and because the player probably won't
// deliver it anymore anyway.
for (final Item pizza : player.getAllEquipped("pizza")) {
if (pizza.getInfoString()!=null) {
player.drop(pizza);
for (final Item item : player.getAllEquipped(itemName)) {
if (item.getInfoString() != null) {
player.drop(item);
}
}
npc.say(StringUtils.substitute(respondIfLastQuestFailed, params));
Expand Down

0 comments on commit 373151d

Please sign in to comment.