Skip to content

Commit

Permalink
New NPC: Maple, a clover hunter
Browse files Browse the repository at this point in the history
  • Loading branch information
AntumDeluge committed Jul 20, 2024
1 parent e681dc2 commit e2cf347
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 3 deletions.
5 changes: 2 additions & 3 deletions data/conf/zones/deniran.xml
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,13 @@
</zone>


<zone name="0_deniran_city_se" level="0" x="499360" y="500128"
file="Level 0/deniran/city_se.tmx">

<zone name="0_deniran_city_se" level="0" x="499360" y="500128" file="Level 0/deniran/city_se.tmx">
<attributes>
<parameter name="color_method">time</parameter>
<parameter name="weather">varying</parameter>
</attributes>

<configurator class-name="games.stendhal.server.maps.deniran.cityoutside.CloverHunterNPC"/>
</zone>


Expand Down
1 change: 1 addition & 0 deletions doc/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Changelog
- added wander behavior to crab in addition to patrol
- new item: four-leaf clover
- new achievement: Luck O' the Irish: Find the lucky four-leaf clover
- new NPC: Maple, a clover hunter

*chat*
- new offers with Harold are announced in chat
Expand Down
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);
}
}
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));
}
}

0 comments on commit e2cf347

Please sign in to comment.