-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e681dc2
commit e2cf347
Showing
4 changed files
with
138 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/games/stendhal/server/maps/deniran/cityoutside/CloverHunterNPC.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/*************************************************************************** | ||
* Copyright © 2024 - Faiumoni e. V. * | ||
*************************************************************************** | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
package games.stendhal.server.maps.deniran.cityoutside; | ||
|
||
import java.util.Map; | ||
|
||
import games.stendhal.server.core.config.ZoneConfigurator; | ||
import games.stendhal.server.core.engine.StendhalRPZone; | ||
import games.stendhal.server.entity.npc.ConversationPhrases; | ||
import games.stendhal.server.entity.npc.ConversationStates; | ||
import games.stendhal.server.entity.npc.SpeakerNPC; | ||
import games.stendhal.server.entity.npc.behaviour.impl.idle.WanderIdleBehaviour; | ||
import games.stendhal.server.entity.npc.condition.NotCondition; | ||
import games.stendhal.server.entity.npc.condition.QuestRegisteredCondition; | ||
|
||
|
||
public class CloverHunterNPC implements ZoneConfigurator { | ||
|
||
@Override | ||
public void configureZone(StendhalRPZone zone, Map<String, String> attributes) { | ||
zone.add(buildNPC()); | ||
} | ||
|
||
private SpeakerNPC buildNPC() { | ||
SpeakerNPC npc = new SpeakerNPC("Maple"); | ||
npc.setEntityClass("cloverhunternpc"); | ||
npc.setDescription("You see a young woman scanning the ground with her magnifying glass."); | ||
npc.setPosition(68, 67); | ||
npc.setIdleBehaviour(new WanderIdleBehaviour()); | ||
|
||
buildDialogue(npc); | ||
|
||
return npc; | ||
} | ||
|
||
private void buildDialogue(SpeakerNPC npc) { | ||
npc.addGreeting("Hello fellow clover hunter!"); | ||
npc.addGoodbye("May luck shine brightly o'er you!"); | ||
npc.addJob("I'm a clover hunter. I'm searching for the lucky four-leaf #clover."); | ||
npc.addHelp("Four-leaf #clovers are extremely rare. If you find one, it is said you will have" | ||
+ " excellent luck!"); | ||
npc.addOffer("I can tell you a little about #clovers."); | ||
npc.addReply("clover", "Clovers can grow just about anywhere in the sunlight. So don't go" | ||
+ " looking for any underground. Ones with four leaves are especially rare and are a" | ||
+ " challenging #task to find."); | ||
|
||
npc.add( | ||
ConversationStates.ATTENDING, | ||
ConversationPhrases.QUEST_MESSAGES, | ||
new NotCondition(new QuestRegisteredCondition("lucky_four_leaf_clover")), | ||
ConversationStates.ATTENDING, | ||
"No, no thank you. I can find a four-leaf clover on my own.", | ||
null); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
tests/games/stendhal/server/maps/deniran/cityoutside/CloverHunterNPCTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/*************************************************************************** | ||
* Copyright © 2024 - Faiumoni e. V. * | ||
*************************************************************************** | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
package games.stendhal.server.maps.deniran.cityoutside; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
import static org.junit.Assert.assertThat; | ||
import static utilities.SpeakerNPCTestHelper.getReply; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import games.stendhal.server.entity.npc.ConversationStates; | ||
import games.stendhal.server.entity.npc.SpeakerNPC; | ||
import games.stendhal.server.entity.npc.fsm.Engine; | ||
import utilities.ZonePlayerAndNPCTestImpl; | ||
|
||
|
||
public class CloverHunterNPCTest extends ZonePlayerAndNPCTestImpl { | ||
|
||
@Override | ||
@Before | ||
public void setUp() throws Exception { | ||
setupZone("test_zone", new CloverHunterNPC()); | ||
setNpcNames("Maple"); | ||
setZoneForPlayer("test_zone"); | ||
|
||
super.setUp(); | ||
} | ||
|
||
@Test | ||
public void testDialogue() { | ||
assertThat(player, notNullValue()); | ||
SpeakerNPC npc = getNPC("Maple"); | ||
Engine en = npc.getEngine(); | ||
|
||
en.step(player, "hi"); | ||
assertThat(getReply(npc), is("Hello fellow clover hunter!")); | ||
en.step(player, "job"); | ||
assertThat(getReply(npc), | ||
is("I'm a clover hunter. I'm searching for the lucky four-leaf #clover.")); | ||
en.step(player, "help"); | ||
assertThat(getReply(npc), is("Four-leaf #clovers are extremely rare. If you find one, it is" | ||
+ " said you will have excellent luck!")); | ||
en.step(player, "offer"); | ||
assertThat(getReply(npc), is("I can tell you a little about #clovers.")); | ||
en.step(player, "clover"); | ||
assertThat(getReply(npc), is("Clovers can grow just about anywhere in the sunlight. So don't go" | ||
+ " looking for any underground. Ones with four leaves are especially rare and are a" | ||
+ " challenging #task to find.")); | ||
en.step(player, "clovers"); | ||
assertThat(getReply(npc), is("Clovers can grow just about anywhere in the sunlight. So don't go" | ||
+ " looking for any underground. Ones with four leaves are especially rare and are a" | ||
+ " challenging #task to find.")); | ||
en.step(player, "task"); | ||
// reply when quest is not loaded | ||
assertThat(getReply(npc), is("No, no thank you. I can find a four-leaf clover on my own.")); | ||
en.step(player, "bye"); | ||
assertThat(getReply(npc), is("May luck shine brightly o'er you!")); | ||
assertThat(en.getCurrentState(), is(ConversationStates.IDLE)); | ||
} | ||
} |