/** Tests for successful placement of an offer. */
  @Test
  public void testSuccessfullOfferPlacement() {
    final SpeakerNPC npc = getNPC("Harold");
    final Engine en = npc.getEngine();
    player.addXP(1700);

    Item item = SingletonRepository.getEntityManager().getItem("axe");
    StackableItem playersMoney =
        (StackableItem) SingletonRepository.getEntityManager().getItem("money");
    Integer price = Integer.valueOf(1500);
    playersMoney.setQuantity(price);
    player.equipToInventoryOnly(item);
    player.equipToInventoryOnly(playersMoney);

    assertTrue(en.step(player, "hello"));
    assertEquals("Welcome to Semos trading center. How can I #help you?", getReply(npc));

    assertTrue(en.step(player, "sell axe 150000"));
    assertEquals(
        "Do you want to sell an axe for 150000 money? It would cost you 1500 money.",
        getReply(npc));

    assertTrue(en.step(player, "yes"));
    assertEquals(
        "I added your offer to the trading center and took the fee of 1500.", getReply(npc));

    assertTrue(en.step(player, "bye"));
    assertEquals(
        "Visit me again to see available offers, make a new offer or fetch your earnings!",
        getReply(npc));
  }
  /** Tests for executeNonameSeed. */
  @Test
  public void testExecuteNonameSeed() {
    final Seed seed = (Seed) SingletonRepository.getEntityManager().getItem("seed");
    final Player player = PlayerTestHelper.createPlayer("bob");
    assertNotNull(player);
    final StendhalRPZone zone = new StendhalRPZone("zone");
    SingletonRepository.getRPWorld().addRPZone(zone);
    zone.add(player);

    assertNotNull(seed);
    zone.add(seed);
    seed.setPosition(1, 0);

    assertTrue(seed.onUsed(player));

    final Entity entity = player.getZone().getEntityAt(1, 0);
    assertNotNull(entity);
    if (entity instanceof FlowerGrower) {
      final FlowerGrower flg = (FlowerGrower) entity;
      flg.setToFullGrowth();
      flg.onUsed(player);
      assertNull(player.getZone().getEntityAt(1, 0));
      assertTrue(player.isEquipped("lilia"));
    } else {
      fail("seed produced non flowergrower");
    }
  }
  /**
   * Places the player (and his/her sheep if there is one) into the world on login.
   *
   * @param object RPObject representing the player
   * @param player Player-object
   */
  public static void placePlayerIntoWorldOnLogin(final RPObject object, final Player player) {
    StendhalRPZone zone = null;

    String zoneName = System.getProperty("stendhal.forcezone");
    if (zoneName != null) {
      zone = SingletonRepository.getRPWorld().getZone(zoneName);
      zone.placeObjectAtEntryPoint(player);
      return;
    }

    try {
      if (object.has("zoneid") && object.has("x") && object.has("y")) {
        if (Version.checkCompatibility(object.get("release"), Debug.VERSION)) {
          zone = SingletonRepository.getRPWorld().getZone(object.get("zoneid"));
        } else {
          if (player.getLevel() >= 2) {
            TutorialNotifier.newrelease(player);
          }
        }
        player.put("release", Debug.VERSION);
      }
    } catch (final RuntimeException e) {
      // If placing the player at its last position
      // fails, we reset to default zone
      logger.warn("Cannot place player at its last position. Using default", e);
    }

    if (zone != null) {
      /*
       * Put the player in their zone (use placeat() for collision rules)
       */
      if (!StendhalRPAction.placeat(zone, player, player.getX(), player.getY())) {
        logger.warn("Cannot place player at their last position: " + player.getName());
        zone = null;
      }
    }

    if (zone == null) {
      /*
       * Fallback to default zone
       */
      final String defaultZoneName = getDefaultZoneForPlayer(player);
      zone = SingletonRepository.getRPWorld().getZone(defaultZoneName);

      if (zone == null) {
        logger.error("Unable to locate default zone [" + defaultZoneName + "]");
        return;
      }

      zone.placeObjectAtEntryPoint(player);
    }
  }
  /** Tests for executeSeedInBag. */
  @Test
  public void testExecuteSeedInBag() {
    final Seed seed = (Seed) SingletonRepository.getEntityManager().getItem("seed");
    final Player player = PlayerTestHelper.createPlayer("bob");
    assertNotNull(player);
    final StendhalRPZone zone = new StendhalRPZone("zone");
    SingletonRepository.getRPWorld().addRPZone(zone);
    zone.add(player);

    assertNotNull(seed);
    player.equip("bag", seed);

    assertFalse(seed.onUsed(player));
  }
示例#5
0
 @Before
 public void setUp() {
   player = PlayerTestHelper.createPlayer("player");
   configureZone(basement, null);
   npc = SingletonRepository.getNPCList().get("Morgrin");
   en = npc.getEngine();
 }
  @Override
  public void execute(final Player admin, final List<String> args) {
    int outdated = 0;
    final ObjectCounter<Class<?>> counter = new ObjectCounter<Class<?>>();

    final TurnNotifier turnNotifier = SingletonRepository.getTurnNotifier();
    final int currentTurn = turnNotifier.getCurrentTurnForDebugging();
    final Map<Integer, Set<TurnListener>> events = turnNotifier.getEventListForDebugging();

    for (final Map.Entry<Integer, Set<TurnListener>> it : events.entrySet()) {
      final Integer turn = it.getKey();

      // count outdated
      if (turn.intValue() < currentTurn) {
        outdated++;
      }

      // count classes
      for (final TurnListener event : it.getValue()) {
        counter.add(event.getClass());
      }
    }

    // send result
    admin.sendPrivateText(
        "Statistics: "
            + "\n"
            + counter.getMap()
            + "\nCounted turn events:"
            + events.size()
            + "\nOutdated turn events: "
            + outdated);
  }
  /**
   * Completes handling the buddy action.
   *
   * @param currentTurn ignored
   */
  @Override
  public void onTurnReached(int currentTurn) {
    QueryCanonicalCharacterNamesCommand checkcommand =
        DBCommandQueue.get().getOneResult(QueryCanonicalCharacterNamesCommand.class, handle);

    if (checkcommand == null) {
      TurnNotifier.get().notifyInTurns(0, new TurnListenerDecorator(this));
      return;
    }

    Player player = checkcommand.getPlayer();

    Collection<String> queriedNames = checkcommand.getQueriedNames();
    String who = queriedNames.iterator().next(); // We know, we queried exactly one character.

    Collection<String> validNames = checkcommand.getValidNames();
    if (validNames.isEmpty()) {
      player.sendPrivateText(NotificationType.ERROR, "Sorry, " + who + " could not be found.");
      return;
    }

    // get the canonical name
    who = validNames.iterator().next();
    final Player buddy = SingletonRepository.getRuleProcessor().getPlayer(who);

    if (player.addBuddy(who, (buddy != null) && !buddy.isGhost())) {
      new GameEvent(player.getName(), "buddy", "add", who).raise();
      player.sendPrivateText(who + " was added to your buddy list.");
    } else {
      player.sendPrivateText(who + " was already on your buddy list.");
    }

    new BuddyCleanup(player).cleanup();
  }
  /** Tests for getHistory. */
  @Test
  public void testgetHistory() {
    final Player player = PlayerTestHelper.createPlayer("bob");
    assertTrue(bfh.getHistory(player).isEmpty());
    player.setQuest("beer_hayunn", "");
    final List<String> history = new LinkedList<String>();
    history.add("I have talked to Hayunn.");
    assertEquals(history, bfh.getHistory(player));

    player.setQuest("beer_hayunn", "rejected");
    history.add("I do not want to make Hayunn drunk.");
    assertEquals(history, bfh.getHistory(player));

    player.setQuest("beer_hayunn", "start");
    history.remove("I do not want to make Hayunn drunk.");
    history.add("I promised to buy him a beer from Margaret in Semos Tavern.");
    assertEquals(history, bfh.getHistory(player));

    player.equipToInventoryOnly(SingletonRepository.getEntityManager().getItem("beer"));
    history.add("I have a bottle of beer.");
    assertEquals(history, bfh.getHistory(player));
    player.setQuest("beer_hayunn", "done");
    history.add("I gave the beer to Hayunn. He paid me 20 gold coins and I got some experience.");
    assertEquals(history, bfh.getHistory(player));
  }
  @Override
  public void addToWorld() {
    zone = SingletonRepository.getRPWorld().getZone("0_semos_mountain_n2");

    addBoard();
    addNPC();
    board.setNPC(npc);
  }
 private double adjustFactorBasedOnMinLevel(String item) {
   if (itemToRepair == null) {
     itemToRepair = SingletonRepository.getEntityManager().getItem(item);
   }
   // reset again
   itemToRepair = null;
   // TODO adjust similar to min level adjustment
   return REPAIR_PRICE_FACTOR;
 }
 /** Create the script and initialize the list of zones */
 public ContMoveAndStrengthenOnlinePlayers() {
   StendhalRPWorld rpWorld = SingletonRepository.getRPWorld();
   for (IRPZone irpZone : rpWorld) {
     StendhalRPZone irpZone2 = (StendhalRPZone) irpZone;
     if (!irpZone2.getName().startsWith("int")) {
       zones.add(irpZone2);
     }
   }
 }
  /** Tests for execute. */
  @Test
  public void testExecute() {
    final Seed seed = (Seed) SingletonRepository.getEntityManager().getItem("seed");
    final Player player = PlayerTestHelper.createPlayer("bob");
    assertNotNull(player);
    final StendhalRPZone zone = new StendhalRPZone("zone");
    SingletonRepository.getRPWorld().addRPZone(zone);
    zone.add(player);

    assertNotNull(seed);
    zone.add(seed);
    seed.setPosition(1, 0);

    assertTrue(seed.onUsed(player));

    assertNotNull(player.getZone().getEntityAt(1, 0));
    assertTrue(player.getZone().getEntityAt(1, 0) instanceof FlowerGrower);
  }
示例#13
0
  /** Test selling a container item. */
  @Test
  public void testSellContainer() {
    final SpeakerNPC npc = getNPC("Harold");
    final Engine en = npc.getEngine();
    player.addXP(1700);

    Item item = SingletonRepository.getEntityManager().getItem("keyring");
    StackableItem playersMoney =
        (StackableItem) SingletonRepository.getEntityManager().getItem("money");
    Integer price = Integer.valueOf(1500);
    playersMoney.setQuantity(price);
    player.equipToInventoryOnly(item);
    player.equipToInventoryOnly(playersMoney);

    Item key = SingletonRepository.getEntityManager().getItem("dungeon silver key");
    item.getSlot("content").add(key);

    assertTrue(en.step(player, "hello"));
    assertEquals("Welcome to Semos trading center. How can I #help you?", getReply(npc));

    // Try first selling it when it's not empty
    assertTrue(en.step(player, "sell keyring 150000"));
    assertEquals("Please empty your keyring first.", getReply(npc));
    assertTrue(player.isEquipped("keyring"));
    assertTrue(player.isEquipped("dungeon silver key"));

    // Then after emptying it
    item.getSlot("content").clear();
    assertTrue(en.step(player, "sell keyring 150000"));
    assertEquals(
        "Do you want to sell a keyring for 150000 money? It would cost you 1500 money.",
        getReply(npc));

    assertTrue(en.step(player, "yes"));
    assertEquals(
        "I added your offer to the trading center and took the fee of 1500.", getReply(npc));
    assertFalse(player.isEquipped("keyring"));
    assertFalse(player.isEquipped("dungeon silver key"));

    assertTrue(en.step(player, "bye"));
    assertEquals(
        "Visit me again to see available offers, make a new offer or fetch your earnings!",
        getReply(npc));
  }
/**
 * Builds an NPC to buy gems and gold and sell engagement ring.
 *
 * <p>He is also the NPC who can fix a broken emerald ring (../../quests/Ringmaker.java)
 *
 * <p>He is also the NPC who casts the wedding ring (../../quests/Marriage.java)
 *
 * @author kymara
 */
public class RingSmithNPC implements ZoneConfigurator {
  private final ShopList shops = SingletonRepository.getShopList();

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

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

          @Override
          protected void createPath() {
            final List<Node> nodes = new LinkedList<Node>();
            nodes.add(new Node(18, 8));
            nodes.add(new Node(15, 8));
            nodes.add(new Node(15, 10));
            nodes.add(new Node(16, 10));
            nodes.add(new Node(16, 14));
            nodes.add(new Node(18, 14));
            setPath(new FixedPath(nodes, true));
          }

          @Override
          protected void createDialog() {
            addGreeting("Hi! Can I #help you?");
            addJob("I work with #gold, to fix and make jewellery.");
            addOffer(
                "I sell engagement rings which I make myself. I also buy gems and gold, see the red catalogue on the table.");
            addReply(
                "gold",
                "It's cast from gold nuggets which you can pan for on Or'ril river. I don't cast it myself, but a smith in Ados does.");
            addHelp(
                "I am an expert on #'wedding rings' and #'emerald rings', sometimes called the ring of #life.");
            addQuest(
                "Well, you could consider getting married to be a quest! Ask me about #'wedding rings' if you need one.");
            new SellerAdder().addSeller(this, new SellerBehaviour(shops.get("sellrings")), false);
            new BuyerAdder().addBuyer(this, new BuyerBehaviour(shops.get("buyprecious")), false);
            addGoodbye("Bye, my friend.");
          }
        };

    npc.setDescription("You see Ognir, a friendly bearded chap.");
    npc.setEntityClass("ringsmithnpc");
    npc.setPosition(18, 8);
    npc.initHP(100);
    zone.add(npc);
  }
}
 public int calculatePrice(String item, Player p) {
   double itemvalue = SingletonRepository.getEconomy().getValue(item);
   double adjustedFactor = adjustFactorBasedOnMinLevel(item);
   double repairPrice = itemvalue * adjustedFactor;
   // consider bad boy flag for price calculation
   if (p.isBadBoy()) {
     repairPrice = repairPrice * PLAYER_KILLER_MALUS;
   }
   return Double.valueOf(repairPrice).intValue();
 }
  @Override
  public void execute(final Player admin, final List<String> args) {

    // help text
    if (args.size() < 2) {
      admin.sendPrivateText(
          "Usage /script AlterQuest.class <player> <questname> <state>. Ommit <state> to remove the quest.");
      return;
    }

    // find player
    final StendhalRPRuleProcessor rules = SingletonRepository.getRuleProcessor();
    final Player target = rules.getPlayer(args.get(0));
    if (target != null) {

      // old state
      final String questName = args.get(1);
      String oldQuestState = null;
      if (target.hasQuest(questName)) {
        oldQuestState = target.getQuest(questName);
      }

      // new state (or null to remove the quest)
      String newQuestState = null;
      if (args.size() > 2) {
        newQuestState = args.get(2);
      }

      // set the quest
      target.setQuest(questName, newQuestState);

      // notify admin and altered player
      target.sendPrivateText(
          NotificationType.SUPPORT,
          "Admin "
              + admin.getTitle()
              + " changed your state of the quest '"
              + questName
              + "' from '"
              + oldQuestState
              + "' to '"
              + newQuestState
              + "'");
      admin.sendPrivateText(
          "Changed the state of quest '"
              + questName
              + "' from '"
              + oldQuestState
              + "' to '"
              + newQuestState
              + "'");
    } else {
      admin.sendPrivateText(args.get(0) + " is not logged in");
    }
  }
示例#17
0
  @Before
  public void setup() {
    PlayerTestHelper.removeAllPlayers();
    StendhalRPZone zone = new StendhalRPZone("admin_test");
    new RetiredAdventurerNPC().configureZone(zone, null);
    hayunn = SingletonRepository.getNPCList().get("Hayunn Naratha");

    bfh = new BeerForHayunn();

    bfh.addToWorld();
  }
  @Before
  public void setUp() {
    StendhalRPZone zone = new StendhalRPZone("admin_test");
    new CustomerAdvisorNPC().configureZone(zone, null);

    npc = SingletonRepository.getNPCList().get("Dagobert");
    quest = new ArmorForDagobert();
    quest.addToWorld();
    en = npc.getEngine();

    player = PlayerTestHelper.createPlayer("player");
  }
示例#19
0
  @Override
  public void execute(final Player admin, final List<String> args) {
    final StendhalRPWorld world = SingletonRepository.getRPWorld();
    for (final IRPZone irpZone : world) {
      final StendhalRPZone zone = (StendhalRPZone) irpZone;
      for (CreatureRespawnPoint point : zone.getRespawnPointList()) {
        CountCreature creature = new CountCreature(point.getPrototypeCreature());
        processCreature(creature);
      }
    }

    sendResults(admin);
  }
示例#20
0
 @Override
 protected boolean useMe(final Player player) {
   this.removeOne();
   String itemName;
   itemName = ITEMS[Rand.rand(ITEMS.length)];
   final Item item = SingletonRepository.getEntityManager().getItem(itemName);
   if ("easter egg".equals(itemName)) {
     item.setBoundTo(player.getName());
   }
   player.sendPrivateText("Congratulations, you've got " + Grammar.a_noun(itemName) + "!");
   player.equipOrPutOnGround(item);
   player.notifyWorldAboutChanges();
   return true;
 }
示例#21
0
  @Override
  public void execute(final Player admin, final List<String> args) {
    super.execute(admin, args);

    if (args.size() < 3) {
      admin.sendPrivateText("Usage: /script NPCShoutZone.class npc zone text");
    } else {
      final StringBuilder sb = new StringBuilder();
      sb.append(args.get(0));
      sb.append(" shouts ");

      StendhalRPZone targetZone;
      String targetZoneName = args.get(1);
      if ("-".equals(targetZoneName)) {
        targetZone = admin.getZone();
        targetZoneName = targetZone.getName();
      } else {
        targetZone = SingletonRepository.getRPWorld().getZone(targetZoneName);
      }

      if (targetZone != null) {
        sb.append("to those in " + targetZoneName + ": ");
        for (int i = 2; i < args.size(); i++) {
          sb.append(args.get(i));
          sb.append(" ");
        }
        final String text = sb.toString();
        for (Player player : targetZone.getPlayers()) {
          player.sendPrivateText(text);
        }
        SingletonRepository.getRuleProcessor().sendMessageToSupporters(text);
      } else {
        admin.sendPrivateText("zone " + targetZoneName + "not found");
      }
    }
  }
 private void equipPlayer(Player player) {
   StackableItem money = (StackableItem) SingletonRepository.getEntityManager().getItem("money");
   money.setQuantity(5000);
   player.equipToInventoryOnly(money);
   StackableItem potions =
       (StackableItem) SingletonRepository.getEntityManager().getItem("greater potion");
   potions.setQuantity(5000);
   player.equipToInventoryOnly(potions);
   if (!player.isEquipped("chaos dagger")) {
     Item first = (Item) player.getSlot("rhand").getFirst();
     player.drop(first);
     Item dagger = SingletonRepository.getEntityManager().getItem("chaos dagger");
     player.equip("rhand", dagger);
   }
   if (!player.isEquipped("chaos shield")) {
     Item first = (Item) player.getSlot("lhand").getFirst();
     player.drop(first);
     Item shield = SingletonRepository.getEntityManager().getItem("chaos shield");
     player.equip("lhand", shield);
   }
   if (!player.isEquipped("black helmet")) {
     Item first = (Item) player.getSlot("head").getFirst();
     player.drop(first);
     Item helmet = SingletonRepository.getEntityManager().getItem("black helmet");
     player.equip("head", helmet);
   }
   if (!player.isEquipped("elvish legs")) {
     Item first = (Item) player.getSlot("legs").getFirst();
     player.drop(first);
     Item legs = SingletonRepository.getEntityManager().getItem("elvish legs");
     player.equip("legs", legs);
   }
   if (!player.isEquipped("killer boots")) {
     Item first = (Item) player.getSlot("feet").getFirst();
     player.drop(first);
     Item boots = SingletonRepository.getEntityManager().getItem("killer boots");
     player.equip("feet", boots);
   }
   if (!player.isEquipped("green dragon cloak")) {
     Item first = (Item) player.getSlot("cloak").getFirst();
     player.drop(first);
     Item cloak = SingletonRepository.getEntityManager().getItem("green dragon cloak");
     player.equip("cloak", cloak);
   }
 }
/*
 * Inside Magic Theater)
 */
public class MagicBarmaidNPC implements ZoneConfigurator {
  private final ShopList shops = SingletonRepository.getShopList();

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

  private void buildmagicbarmaid(final StendhalRPZone zone) {
    final SpeakerNPC magicbarmaid =
        new SpeakerNPC("Trillium") {

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

          @Override
          protected void createDialog() {
            addGreeting("Hi. Hope you are enjoying our wonderful theater.");
            addJob("I sell the most delectable foods in Magic City.");
            addHelp("If you are hungry, check out the blackboard for foods and prices.");
            new SellerAdder().addSeller(this, new SellerBehaviour(shops.get("sellmagic")), false);
            addOffer("See the blackboard for my prices.");
            addQuest("I have no need of your help, thanks.");
            addReply("licorice", "Poor Baldemar, he is so very alergic to licorice.");
            addGoodbye("Great to see you. Come again.");
          }
        };

    magicbarmaid.setEntityClass("woman_015_npc");
    magicbarmaid.setPosition(13, 3);
    magicbarmaid.initHP(100);
    magicbarmaid.setDescription(
        "You see Trillium. She is the Magic City barmaid of the theater and offers nice drinks and food.");
    zone.add(magicbarmaid);
  }
}
示例#24
0
    public void onTurnReached(final int currentTurn) {
      if (!access.isFinished()) {
        SingletonRepository.getTurnNotifier().notifyInTurns(3, new WikipediaWaiter(npc, access));
        return;
      }
      if (access.getError() != null) {
        npc.say("Sorry, I cannot access the bookcase at the moment.");
        return;
      }

      if ((access.getText() != null) && (access.getText().length() > 0)) {
        final String content = access.getProcessedText();
        npc.say(content);
      } else {
        npc.say("Sorry, this book has still to be written.");
      }
    }
示例#25
0
  public void onAction(final Player player, final RPAction action) {
    if (!StandardActionValidations.CHAT.validateAndInformPlayer(player, action)) {
      return;
    }

    final String text = action.get(TEXT);
    player.put("text", text);
    new GameEvent(
            player.getName(),
            "chat",
            null,
            Integer.toString(text.length()),
            text.substring(0, Math.min(text.length(), 1000)))
        .raise();

    player.notifyWorldAboutChanges();
    SingletonRepository.getRuleProcessor().removePlayerText(player);
  }
  public Player create(final RPObject object) {

    removeVolatile(object);

    // add attributes and slots
    UpdateConverter.updatePlayerRPObject(object);

    final Player player = new Player(object);
    player.stop();
    player.stopAttack();

    loadItemsIntoSlots(player);
    loadSpellsIntoSlots(player);
    player.cancelTradeInternally(null);

    // buddy handling with maps
    if (player.hasBuddies()) {
      for (String buddyName : player.getBuddies()) {
        final Player buddy = SingletonRepository.getRuleProcessor().getPlayer(buddyName);
        if ((buddy != null) && !buddy.isGhost()) {
          player.setBuddyOnlineStatus(buddyName, true);
        } else {
          player.setBuddyOnlineStatus(buddyName, false);
        }
      }
    }

    convertOldfeaturesList(player);

    player.updateItemAtkDef();
    StendhalQuestSystem.updatePlayerQuests(player);

    UpdateConverter.updateQuests(player);
    // Should be at least after converting the features list, as this
    // depends on checking the keyring feature.

    if (System.getProperty("stendhal.container") != null) {
      UpdateConverter.updateKeyring(player);
    }

    logger.debug("Finally player is :" + player);
    return player;
  }
/** Inside Nalwor Assassin Headquarters - cellar . */
public class ChiefFalatheenDishwasherNPC implements ZoneConfigurator {

  private final ShopList shops = SingletonRepository.getShopList();

  public void configureZone(StendhalRPZone zone, Map<String, String> attributes) {
    buildNPC(zone);
  }

  private void buildNPC(StendhalRPZone zone) {
    final SpeakerNPC npc =
        new SpeakerNPC("Chief Falatheen Humble Dishwasher") {

          @Override
          protected void createPath() {
            setPath(null);
          }

          @Override
          public void createDialog() {
            addGreeting(
                "You better have a good excuse for bothering me. I'm up to my neck in dishwater!");
            addJob("It is my job to wash all the dishes for all these pesky little brats.");
            addHelp(
                "I can buy your vegetables and herbs.  Please see blackboards on wall for what I need.");
            addOffer("Look at blackboards on wall to see my prices.");
            addQuest("You could try to help me #escape from these hoodlums. Well... maybe not.");
            addGoodbye(
                "Don't forget where I am now. Come back and see me some time. I do get lonely.");
            addReply(
                "escape",
                "Yes! I want to pursue my dream. Mother Helena offered me a most wonderful job.  She needs a dishwasher. Lots of complaining customers!!!");
            new BuyerAdder()
                .addBuyer(this, new BuyerBehaviour(shops.get("buyveggiesandherbs")), false);
          }
        };
    npc.setPosition(20, 3);
    npc.setDescription(
        "You see a strong looking man. He ate lots of healthy vegetables to look like that!");
    npc.setEntityClass("chieffalatheennpc");
    zone.add(npc);
  }
}
    @Override
    public void onTurnReached(int currentTurn) {
      List<Player> list = new LinkedList<Player>();
      list.addAll(zoneGuardHouse.getPlayers());
      list.addAll(zoneAfterlife.getPlayers());

      for (Player player : list) {

        equipPlayer(player);
        player.setDefXP(999999999);
        player.addXP(999999999);
        StendhalRPZone zone = zones.get(Rand.rand(zones.size()));
        int x = Rand.rand(zone.getWidth() - 4) + 2;
        int y = Rand.rand(zone.getHeight() - 5) + 2;
        player.teleport(zone, x, y, Direction.DOWN, player);
      }

      SingletonRepository.getTurnNotifier()
          .notifyInSeconds(5, new ContMoveAndStrengthenPlayersTurnListener());
    }
示例#29
0
  /** Tests for isValidContained. */
  @Test
  public void testIsValidContained() {
    MockStendlRPWorld.get();
    final Player bob = PlayerTestHelper.createPlayer("bob");
    final StendhalRPZone zone = new StendhalRPZone("dropzone");
    final Item dropitem = SingletonRepository.getEntityManager().getItem("money");
    assertNotNull(dropitem);
    zone.add(bob);
    assertTrue(bob.equipToInventoryOnly(dropitem));
    assertNotNull(dropitem.getID().getObjectID());
    final RPAction action = new RPAction();
    action.put(EquipActionConsts.BASE_ITEM, dropitem.getID().getObjectID());

    action.put(EquipActionConsts.BASE_OBJECT, bob.getID().getObjectID());
    action.put(EquipActionConsts.BASE_SLOT, "bag");
    MockStendlRPWorld.get().addRPZone(zone);
    assertNotNull(bob.getZone());

    final SourceObject so = SourceObject.createSourceObject(action, bob);
    assertTrue("Unreachable slot", so.isValid());
  }
  /**
   * Places a domestic animal in the world. If it matches it's owner's zone, then try to keep it's
   * position.
   *
   * @param animal The domestic animal.
   * @param player The owner.
   * @return <code>true</code> if placed.
   */
  protected static boolean placeAnimalIntoWorld(final DomesticAnimal animal, final Player player) {
    final StendhalRPZone playerZone = player.getZone();

    /*
     * Only add directly if required attributes are present
     */
    if (animal.has("zoneid") && animal.has("x") && animal.has("y")) {
      final StendhalRPZone zone = SingletonRepository.getRPWorld().getZone(animal.get("zoneid"));

      /*
       * Player could have been forced to change zones
       */
      if (zone == playerZone) {
        if (StendhalRPAction.placeat(zone, animal, animal.getX(), animal.getY())) {
          return true;
        }
      }
    }

    return StendhalRPAction.placeat(playerZone, animal, player.getX(), player.getY());
  }