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.semos.townhall;
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.SpeakerNPC;
25 
26 public class MayorNPC implements ZoneConfigurator {
27 	/**
28 	 * Configure a zone.
29 	 *
30 	 * @param	zone		The zone to be configured.
31 	 * @param	attributes	Configuration attributes.
32 	 */
33 	@Override
configureZone(final StendhalRPZone zone, final Map<String, String> attributes)34 	public void configureZone(final StendhalRPZone zone, final Map<String, String> attributes) {
35 		buildSemosTownhallAreaMayor(zone);
36 	}
37 
38 	/**
39 	 * Adds a Mayor to the townhall who gives out daily quests.
40 	 * @param zone zone to be configured with this
41 	 */
buildSemosTownhallAreaMayor(final StendhalRPZone zone)42 	private void buildSemosTownhallAreaMayor(final StendhalRPZone zone) {
43 		// We create an NPC
44 		final SpeakerNPC npc = new SpeakerNPC("Mayor Sakhs") {
45 
46 			@Override
47 			protected void createPath() {
48 				final List<Node> nodes = new LinkedList<Node>();
49 				nodes.add(new Node(13, 3));
50 				nodes.add(new Node(19, 3));
51 				setPath(new FixedPath(nodes, true));
52 			}
53 
54 			@Override
55 			protected void createDialog() {
56 				addGreeting("Welcome citizen! Do you need #help?");
57 				addJob("I'm the mayor of Semos village.");
58 				addHelp("You will find a lot of people in Semos that offer you help on different topics.");
59 				addGoodbye("Have a good day and enjoy your stay!");
60 			}
61 		};
62 
63 		npc.setEntityClass("mayornpc");
64 		npc.setDescription("The mighty mayor of Semos, Mayor Sakhs, is walking infront of you. He seems to be nervous...");
65 		npc.setPosition(13, 3);
66 		npc.setCollisionAction(CollisionAction.STOP);
67 		npc.initHP(100);
68 		zone.add(npc);
69 	}
70 }
71