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.ados.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.SingletonRepository;
21 import games.stendhal.server.core.engine.StendhalRPZone;
22 import games.stendhal.server.core.pathfinder.FixedPath;
23 import games.stendhal.server.core.pathfinder.Node;
24 import games.stendhal.server.entity.CollisionAction;
25 import games.stendhal.server.entity.npc.ShopList;
26 import games.stendhal.server.entity.npc.SpeakerNPC;
27 import games.stendhal.server.entity.npc.behaviour.adder.SellerAdder;
28 import games.stendhal.server.entity.npc.behaviour.impl.SellerBehaviour;
29 
30 /**
31  * Builds ados mayor NPC.
32  * He may give an items quest later
33  * Now he sells ados scrolls
34  * @author kymara
35  */
36 public class MayorNPC implements ZoneConfigurator {
37 	private final ShopList shops = SingletonRepository.getShopList();
38 
39 	/**
40 	 * Configure a zone.
41 	 *
42 	 * @param	zone		The zone to be configured.
43 	 * @param	attributes	Configuration attributes.
44 	 */
45 	@Override
configureZone(final StendhalRPZone zone, final Map<String, String> attributes)46 	public void configureZone(final StendhalRPZone zone, final Map<String, String> attributes) {
47 		buildMayor(zone);
48 	}
49 
buildMayor(final StendhalRPZone zone)50 	private void buildMayor(final StendhalRPZone zone) {
51 		final SpeakerNPC mayor = new SpeakerNPC("Mayor Chalmers") {
52 
53 			@Override
54 			protected void createPath() {
55 				final List<Node> nodes = new LinkedList<Node>();
56 				nodes.add(new Node(3, 9));
57 				nodes.add(new Node(8, 9));
58 				nodes.add(new Node(8, 16));
59 				nodes.add(new Node(25, 16));
60 				nodes.add(new Node(25, 13));
61 				nodes.add(new Node(37, 13));
62 				nodes.add(new Node(25, 13));
63 				nodes.add(new Node(25, 16));
64 				nodes.add(new Node(8, 16));
65 				nodes.add(new Node(8, 9));
66 				setPath(new FixedPath(nodes, true));
67 			}
68 
69 			@Override
70 			protected void createDialog() {
71 				addGreeting("On behalf of the citizens of Ados, welcome.");
72 				addJob("I'm the mayor of Ados. I can #offer you the chance to return here easily.");
73 				addHelp("Ask me about my #offer to return here.");
74 				//addQuest("I don't know you well yet. Perhaps later in the year I can trust you with something.");
75 				new SellerAdder().addSeller(this, new SellerBehaviour(shops.get("adosscrolls")));
76 				addGoodbye("Good day to you.");
77 			}
78 		};
79 
80 		mayor.setDescription("You see the respected mayor of Ados.");
81 		mayor.setEntityClass("badmayornpc");
82 		mayor.setPosition(3, 9);
83 		mayor.setCollisionAction(CollisionAction.STOP);
84 		mayor.initHP(100);
85 		zone.add(mayor);
86 	}
87 }
88