Package games.stendhal.server.core.rule

Examples of games.stendhal.server.core.rule.EntityManager


        final Sheep sheep = new Sheep();
        sheep.setPosition(x, y);
        add(sheep);
      } else if (clazz.contains("logic/creature")) {
        // get the default EntityManager
        final EntityManager manager = SingletonRepository.getEntityManager();

        // Is the entity a creature
        if (manager.isCreature(clazz, type)) {
          final Creature creature = manager.getCreature(clazz, type);
          final CreatureRespawnPoint point = new CreatureRespawnPoint(this,
              x, y, creature, 1);
          add(point);
        } else {
          logger.error("Unknown Entity (class/type: " + clazz + ":"
View Full Code Here


            + "\" does not have an RPSlot named \"" + slotName
            + "\".");
        return;
      }

      final EntityManager manager = SingletonRepository.getEntityManager();
      final String typeName = action.get(ITEM);
      String type = typeName;

      // Is the entity an item
      if (!manager.isItem(type)) {
        // see it the name was in plural
        type = Grammar.singular(typeName);

        if (!manager.isItem(type)) {
          // see it the name was in singular but the registered type is in plural
          type = Grammar.plural(typeName);

          if (!manager.isItem(type)) {
            player.sendPrivateText(typeName + " is not an item.");
            type = null;
          }
        }
      }

      if (type != null) {
        new GameEvent(player.getName(), SUMMONAT, changed.getName(), slotName, type).raise();
        final Item item = manager.getItem(type);

        if (action.has(AMOUNT) && (item instanceof StackableItem)) {
          ((StackableItem) item).setQuantity(action.getInt(AMOUNT));
        }
View Full Code Here

   *            The level of the player who used the staff
   * @return creature the chosen undead creature
   *
   */
  private AttackableCreature pickSuitableCreature(final int playerlevel) {
    final EntityManager manager = SingletonRepository.getEntityManager();

    Creature pickedCreature = null;

    final Collection<Creature> creatures = manager.getCreatures();
      final List<Creature> possibleCreatures = new ArrayList<Creature>();
      for (final Creature creature : creatures) {
        if (creature.getLevel() <= LEVEL_FACTOR * playerlevel && creature.get("class").equals("undead")
            && !creature.isRare()) {
         
View Full Code Here

  /**
   * Update the quest slot to the current version.
   * @param player
   */
  public static void updateQuests(final Player player) {
    final EntityManager entityMgr = SingletonRepository.getEntityManager();

    // rename old quest slot "Valo_concoct_potion" to "valo_concoct_potion"
    // We avoid to lose potion in case there is an entry with the old and the new name at the same
    // time by combining them by calculating the minimum of the two times and the sum of the two amounts.
    migrateSumTimedQuestSlot(player, "Valo_concoct_potion", "valo_concoct_potion");

    // From 0.66 to 0.67
    // update quest slot content,
    // replace "_" with " ", for item/creature names
    for (final String questSlot : player.getQuests()) {

      if (player.hasQuest(questSlot)) {
        final String itemString = player.getQuest(questSlot);

        final String[] parts = itemString.split(";");

        final StringBuilder buffer = new StringBuilder();
        boolean first = true;

        for (int i = 0; i < parts.length; ++i) {
          final String oldName = parts[i];

          // Convert old item names to their new representation with correct grammar
          // and without underscores.
          String newName = UpdateConverter.updateItemName(oldName);

          // check for valid item and creature names if the update converter changed the name
          if (!newName.equals(oldName)) {
            if (!entityMgr.isCreature(newName) && !entityMgr.isItem(newName)) {
              newName = oldName;
            }
          }

          if (first) {
View Full Code Here

      if (loaded.getSlot("bag").size() > 0) {
        loaded.getSlot("bag").remove(loaded.getSlot("bag").getFirst().getID());
      }
      //assertEquals(null, loaded.getSlot("bag").getFirst());
     
      EntityManager em = SingletonRepository.getEntityManager();
      Item item = (Item) em.getItem("leather armor");
      item.put("name", "leather_armor_+1");
      loaded.equipToInventoryOnly(item);
      assertTrue(loaded.getSlot("bag").has(item.getID()));
 
      assertTrue(pm.savePlayer(transaction, loaded));
View Full Code Here

      atkLevels[level] = (int) Math.round(Math.log(level + 4) * - 10);
      defLevels[level] = (int) Math.round(Math.log(level + 4) * 20
          + level - 26);
    }

    final EntityManager em = SingletonRepository.getEntityManager();

    final Item shield = em.getItem("wooden shield");

    final Item armor = em.getItem("dress");

    final Item helmet = em.getItem("leather helmet");

    final Item legs = em.getItem("leather legs");

    final Item boots = em.getItem("leather boots");

    player = Player.createZeroLevelPlayer("Tester", null);

    player.equipToInventoryOnly(shield);
    player.equipToInventoryOnly(armor);
View Full Code Here

    }

    final int x = player.getInt("x");
    final int y = player.getInt("y");

    final EntityManager manager = SingletonRepository.getEntityManager();

    Creature pickedCreature = null;

    final String type = getInfoString();

    if (type != null) {
      // scroll for special monster
      pickedCreature = manager.getCreature(type);
    } else {
      // pick it randomly
      final Collection<Creature> creatures = manager.getCreatures();
      final int magiclevel = 4;
      final List<Creature> possibleCreatures = new ArrayList<Creature>();
      for (final Creature creature : creatures) {
        if (creature.getLevel() <= magiclevel && !creature.isRare()) {
          possibleCreatures.add(creature);
View Full Code Here

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

  private void buildTwilightArea(final StendhalRPZone zone, final Map<String, String> attributes) {
    final EntityManager manager = SingletonRepository.getEntityManager();
    final Creature creature = new ItemGuardCreature(manager.getCreature("twilight slime"), "twilight elixir", "mithril_cloak", "twilight_zone");
    final CreatureRespawnPoint point = new CreatureRespawnPoint(zone, 5, 5, creature, 1);
    zone.add(point);
  }
View Full Code Here

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

  private void buildSixthFloor(final StendhalRPZone zone, final Map<String, String> attributes) {
    final EntityManager manager = SingletonRepository.getEntityManager();

    final Creature creature = manager.getCreature("littlefairy");
    final Creature creature1 = manager.getCreature("pegasus");
    final Creature creature2 = manager.getCreature("unicorn");
    final Creature creature3 = manager.getCreature("archangel");

    creature.setAIProfiles(new HashMap<String, String>());
    creature1.setAIProfiles(new HashMap<String, String>());
    creature2.setAIProfiles(new HashMap<String, String>());
    creature3.setAIProfiles(new HashMap<String, String>());
View Full Code Here

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

  private void buildFirstFloor(final StendhalRPZone zone, final Map<String, String> attributes) {
    final EntityManager manager = SingletonRepository.getEntityManager();

    final Creature creature = manager.getCreature("fire elemental");
    final Creature creature1 = manager.getCreature("demon");
    final Creature creature2 = manager.getCreature("imp");
    final Creature creature3 = manager.getCreature("red dragon");

    creature1.setName("fire demon");

    creature1.setDescription("You see a fire demon. His body is paled in flames, which will burn your skin.");
 
View Full Code Here

TOP

Related Classes of games.stendhal.server.core.rule.EntityManager

Copyright © 2018 www.massapicom. 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.