Skip to content

Commit

Permalink
converted tests to QuestManuscript
Browse files Browse the repository at this point in the history
  • Loading branch information
nhnb committed Oct 21, 2023
1 parent 8cfee9a commit 47a5874
Show file tree
Hide file tree
Showing 27 changed files with 630 additions and 1,894 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ public Collection<Achievement> createAchievements() {
// Anna, in Ados
new QuestCompletedCondition("toys_collector"),
// Sally, Orril River
// 'completed' doesn't work for Sally - return player.hasQuest(QUEST_SLOT) && !"start".equals(player.getQuest(QUEST_SLOT)) && !"rejected".equals(player.getQuest(QUEST_SLOT));
new AndCondition(
new QuestActiveCondition("campfire"),
new QuestNotInStateCondition("campfire", "start")),
new QuestCompletedCondition("campfire"),
// Annie, Kalavan city gardens
new QuestStateStartsWithCondition("icecream_for_annie","eating;"),
// Elisabeth, Kirdneh
Expand All @@ -86,9 +83,7 @@ public Collection<Achievement> createAchievements() {
// Finn Farmer, George
new QuestCompletedCondition("coded_message"),
// Marianne, Deniran City S
new AndCondition(
new QuestActiveCondition("eggs_for_marianne"),
new QuestNotInStateCondition("eggs_for_marianne", "start"))
new QuestCompletedCondition("eggs_for_marianne")
)));

// quests about finding people
Expand Down
41 changes: 35 additions & 6 deletions src/games/stendhal/server/entity/npc/quest/QuestOfferBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import games.stendhal.server.entity.npc.action.SetQuestAndModifyKarmaAction;
import games.stendhal.server.entity.npc.condition.AndCondition;
import games.stendhal.server.entity.npc.condition.NotCondition;
import games.stendhal.server.entity.npc.condition.OrCondition;
import games.stendhal.server.entity.npc.condition.QuestActiveCondition;
import games.stendhal.server.entity.npc.condition.QuestCompletedCondition;
import games.stendhal.server.entity.npc.condition.QuestNotStartedCondition;
Expand All @@ -39,6 +40,7 @@
* @author hendrik
*/
public class QuestOfferBuilder<T extends QuestOfferBuilder<T>> {
protected String begOnGreeting = null;
protected String respondToRequest = null;
protected String respondToUnrepeatableRequest = "Thanks for your help. I have no new task for you.";
protected String respondToRepeatedRequest = null;
Expand All @@ -54,6 +56,12 @@ public class QuestOfferBuilder<T extends QuestOfferBuilder<T>> {
super();
}

@SuppressWarnings("unchecked")
public T begOnGreeting(String begOnGreeting) {
this.begOnGreeting = begOnGreeting;
return (T) this;
}

@SuppressWarnings("unchecked")
public T respondToRequest(String respondToRequest) {
this.respondToRequest = respondToRequest;
Expand Down Expand Up @@ -113,25 +121,31 @@ public T rejectionKarmaPenalty(double rejectionKarmaPenalty) {

void simulateFirst(String npc, QuestSimulator simulator) {
simulator.playerSays("hi");
simulator.playerSays("quest");
if (begOnGreeting == null) {
simulator.playerSays("quest");
}
simulator.npcSays(npc, respondToRequest);
simulator.playerSays("no");
simulator.npcSays(npc, respondToReject);
simulator.playerSays("bye");
simulator.info("");

simulator.playerSays("hi");
simulator.playerSays("quest");
if (begOnGreeting == null) {
simulator.playerSays("quest");
}
simulator.npcSays(npc, respondToRequest);
simulator.playerSays("yes");
simulator.npcSays(npc, respondToAccept);
simulator.playerSays("bye");
simulator.info("");

simulator.playerSays("hi");
simulator.playerSays("quest");
simulator.npcSays(npc, remind);
simulator.info("");
if (begOnGreeting == null) {
simulator.playerSays("hi");
simulator.playerSays("quest");
simulator.npcSays(npc, remind);
simulator.info("");
}
}

void simulateNotRepeatable(String npc, QuestSimulator simulator) {
Expand All @@ -156,6 +170,21 @@ public void build(SpeakerNPC npc, String questSlot, QuestTaskBuilder task, ChatC
ChatAction startQuestAction = task.buildStartQuestAction(questSlot);
ChatAction rejectQuestAction = task.buildRejectQuestAction(questSlot);

if (begOnGreeting != null) {
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new OrCondition(
new QuestNotStartedCondition(questSlot),
new AndCondition(
new QuestActiveCondition(questSlot),
new NotCondition(questCompletedCondition)
)
),
ConversationStates.QUEST_OFFERED,
begOnGreeting,
null);
}

npc.add(ConversationStates.ATTENDING,
ConversationPhrases.QUEST_MESSAGES,
new QuestNotStartedCondition(questSlot),
Expand Down
20 changes: 20 additions & 0 deletions src/games/stendhal/server/entity/player/UpdateConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,26 @@ public static void updateQuests(final Player player) {
player.setQuest(questSlot, "start;;;" + player.getQuest(questSlot));
}
}

// 1.44: Amazon Princess
questSlot = "amazon_princess";
if (player.hasQuest(questSlot)) {
final String fsState = player.getQuest(questSlot, 0);
if (fsState.equals("drinking")) {
player.setQuest(questSlot, 0, "done");
}
}

// 1.44: Campfire and Eggs for marianne
for (String slot : Arrays.asList("campfire", "eggs_for_marianne")) {
if (player.hasQuest(slot)) {
final String fsState = player.getQuest(slot, 0);
if (!fsState.equals("start") && !fsState.equals("rejected")) {
player.setQuest(slot, 1, fsState);
player.setQuest(slot, 0, "done");
}
}
}
}


Expand Down
2 changes: 1 addition & 1 deletion src/games/stendhal/server/maps/amazon/hut/PrincessNPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected void createPath() {

@Override
protected void createDialog() {
addGreeting("Huh, what are you doing here?");
addGreeting("Huh, what are you doing here?");
addReply("sorry", "Well, so you should be, sneaking up on me like that!");
addReply("look", "You had better not poke around, this is all mine!");
addReply("nothing", "Go away and do this somewhere else but not in my hut!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected void createPath() {

@Override
protected void createDialog() {
//addGreeting();
addGreeting("Hi, how are you?");
addJob("Work? I'm just a little girl! I'm a scout, you know.");
addHelp("You can find lots of useful stuff in the forest; wood and mushrooms, for example. But beware, some mushrooms are poisonous!");
addGoodbye();
Expand Down
Loading

0 comments on commit 47a5874

Please sign in to comment.