1 /* $Id$ */
2 /***************************************************************************
3  *                   (C) Copyright 2003-2010 - Stendhal                    *
4  ***************************************************************************
5  ***************************************************************************
6  *                                                                         *
7  *   This program is free software; you can redistribute it and/or modify  *
8  *   it under the terms of the GNU General Public License as published by  *
9  *   the Free Software Foundation; either version 2 of the License, or     *
10  *   (at your option) any later version.                                   *
11  *                                                                         *
12  ***************************************************************************/
13 package games.stendhal.server.maps.magic.school;
14 
15 import java.util.LinkedList;
16 import java.util.List;
17 import java.util.Map;
18 
19 import games.stendhal.server.core.config.ZoneConfigurator;
20 import games.stendhal.server.core.engine.StendhalRPZone;
21 import games.stendhal.server.core.pathfinder.FixedPath;
22 import games.stendhal.server.core.pathfinder.Node;
23 import games.stendhal.server.entity.CollisionAction;
24 import games.stendhal.server.entity.npc.ConversationPhrases;
25 import games.stendhal.server.entity.npc.SpeakerNPC;
26 
27 /**
28  * Builds the groundskeeper NPC.
29  *
30  * @author Teiv
31  */
32 public class GroundskeeperNPC implements ZoneConfigurator {
33 
34 	//
35 	// ZoneConfigurator
36 	//
37 
38 	/**
39 	 * Configure a zone.
40 	 *
41 	 * @param	zone		The zone to be configured.
42 	 * @param	attributes	Configuration attributes.
43 	 */
44 	@Override
configureZone(final StendhalRPZone zone, final Map<String, String> attributes)45 	public void configureZone(final StendhalRPZone zone, final Map<String, String> attributes) {
46 		buildNPC(zone);
47 	}
48 
49 
buildNPC(final StendhalRPZone zone)50 	private void buildNPC(final StendhalRPZone zone) {
51 		final SpeakerNPC groundskeeperNPC = new SpeakerNPC("Morgrin") {
52 
53 			@Override
54 			protected void createPath() {
55 				final List<Node> nodes = new LinkedList<Node>();
56 				nodes.add(new Node(35, 13));
57 				nodes.add(new Node(35, 7));
58 				nodes.add(new Node(34, 7));
59 				nodes.add(new Node(34, 4));
60 				nodes.add(new Node(30, 4));
61 				nodes.add(new Node(30, 14));
62 				nodes.add(new Node(32, 14));
63 				nodes.add(new Node(32, 13));
64 				setPath(new FixedPath(nodes, true));
65 			}
66 
67 			@Override
68 			protected void createDialog() {
69 				addGreeting("Hello my friend. Nice day for walking isn't it?");
70 				addReply(ConversationPhrases.NO_MESSAGES, "Oh sorry. Hope tomorrow your day is a better one.");
71 				addReply(ConversationPhrases.YES_MESSAGES, "Fine fine, I hope you enjoy your day.");
72 				addJob("My job is to clean up school, repair broken things! That's enough to do for a whole day!");
73 				addHelp("I can not help you, I am busy all the day. But you could help me with a 'little' #task!");
74 				addGoodbye("Bye.");
75 			}
76 		};
77 
78 		groundskeeperNPC.setEntityClass("groundskeepernpc");
79 		groundskeeperNPC.setPosition(35, 13);
80 		groundskeeperNPC.setCollisionAction(CollisionAction.STOP);
81 		groundskeeperNPC.initHP(1000);
82 		groundskeeperNPC.setDescription("You see Morgrin, the facility manager of the Magic City school. He is always busy and needs a helping hand.");
83 		zone.add(groundskeeperNPC);
84 	}
85 }
86