Package games.stendhal.server.maps.fado.weaponshop

Source Code of games.stendhal.server.maps.fado.weaponshop.BuyerNPC

/* $Id: BuyerNPC.java,v 1.19 2010/09/19 02:31:00 nhnb Exp $ */
/***************************************************************************
*                   (C) Copyright 2003-2010 - Stendhal                    *
***************************************************************************
***************************************************************************
*                                                                         *
*   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.fado.weaponshop;

import games.stendhal.server.core.config.ZoneConfigurator;
import games.stendhal.server.core.engine.SingletonRepository;
import games.stendhal.server.core.engine.StendhalRPZone;
import games.stendhal.server.core.pathfinder.FixedPath;
import games.stendhal.server.core.pathfinder.Node;
import games.stendhal.server.entity.npc.ShopList;
import games.stendhal.server.entity.npc.SpeakerNPC;
import games.stendhal.server.entity.npc.behaviour.adder.BuyerAdder;
import games.stendhal.server.entity.npc.behaviour.impl.BuyerBehaviour;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
* Builds an NPC to buy previously un bought weapons.
*
* @author kymara
*/
public class BuyerNPC implements ZoneConfigurator {
  private final ShopList shops = SingletonRepository.getShopList();

  /**
   * Configure a zone.
   *
   * @param  zone    The zone to be configured.
   * @param  attributes  Configuration attributes.
   */
  public void configureZone(final StendhalRPZone zone, final Map<String, String> attributes) {
    buildNPC(zone);
  }

  private void buildNPC(final StendhalRPZone zone) {
    final SpeakerNPC npc = new SpeakerNPC("Yorphin Baos") {

      @Override
      protected void createPath() {
        final List<Node> nodes = new LinkedList<Node>();
        nodes.add(new Node(4, 5));
        nodes.add(new Node(7, 5));
        nodes.add(new Node(7, 3));
        nodes.add(new Node(7, 5));
        nodes.add(new Node(4, 5));
        nodes.add(new Node(4, 3));
        setPath(new FixedPath(nodes, true));
      }

      @Override
      protected void createDialog() {
        addGreeting("Welcome to my shop.");
        addJob("I #trade in weapons. I sell only to the locals here in Fado, but I will buy from you.");
        addHelp("I #deal in rare weapons. Ognir there is the ring maker, he buys the odd gem too.");
        addOffer("Please look at the blackboard on the wall to see what I buy.");
        addQuest("Thanks, but no thanks. I don't need anything.");
        new BuyerAdder().add(this, new BuyerBehaviour(shops.get("buyrare2")), false);
        addGoodbye("Bye - and see you soon.");
      }
    };

    npc.setDescription("You see Yorphin Baos, the friendly shop keeper.");
    npc.setEntityClass("weaponsellernpc");
    npc.setPosition(4, 5);
    npc.initHP(100);
    zone.add(npc);
  }
}
TOP

Related Classes of games.stendhal.server.maps.fado.weaponshop.BuyerNPC

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.