Package marauroa.common.game

Examples of marauroa.common.game.RPSlot


    if (action.has(LIST)) {
      // if we don't test this then getSlot and it was empty does something bad to client.
      if (player.getSlot("!ignore").size() > 0) {
        // clone the !ignore slot to avoid a ConcurrentModificationException
        // as the check in getIgnore modifies !ignore
        final RPSlot ignoreSlot = (RPSlot) player.getSlot("!ignore").clone();
        final RPObject ignorelist = ignoreSlot.iterator().next();
        List<String> namesAndReasons = new LinkedList<String>();
        for (final String playerName : ignorelist) {
          String name;
          // Can remove handling of '_' prefix if ID is made completely virtual
          if (playerName.charAt(0) == '_') {
View Full Code Here


  private List<Pair<RPObject, RPSlot>> retrieveAllDroppableObjects() {
    final List<Pair<RPObject, RPSlot>> objects = new LinkedList<Pair<RPObject, RPSlot>>();

    for (final String slotName : Constants.CARRYING_SLOTS) {
      if (player.hasSlot(slotName)) {
        final RPSlot slot = player.getSlot(slotName);

        // a list that will contain the objects that could
        // be dropped.
        for (final RPObject objectInSlot : slot) {
          // don't drop special quest rewards as there is no way to
View Full Code Here

    this.player = player;
  }

  public void storeSheep(final Sheep sheep) {
    if (!player.hasSlot("#flock")) {
      player.addSlot(new RPSlot("#flock"));
    }

    final RPSlot slot = player.getSlot("#flock");
    slot.clear();

    /*
     * RPSlot.add() destroys zoneid, so preserve/restore it.
     *
     * TODO: Remove if getID()/setID() are made purely virtual.
     */
    String zoneid;

    if (sheep.has("zoneid")) {
      zoneid = sheep.get("zoneid");
    } else {
      zoneid = null;
    }

    slot.add(sheep);

    if (zoneid != null) {
      sheep.put("zoneid", zoneid);
    }

View Full Code Here

   *
   * @return A sheep, or <code>null</code> if none.
   */
  public Sheep retrieveSheep() {
    if (player.hasSlot("#flock")) {
      final RPSlot slot = player.getSlot("#flock");

      if (slot.size() > 0) {
        final RPObject object = slot.getFirst();
        slot.remove(object.getID());
        player.removeSlot("#flock");
        object.put("x", player.getX());
        object.put("y", player.getY());
        return new Sheep(object, player);
      }
View Full Code Here

    } else if (!offerer.drop(item)) {
      return null;
    }

    Offer offer = new Offer(item, money, offerer);
    RPSlot slot = this.getSlot(OFFERS_SLOT_NAME);
    slot.add(offer);
    getZone().storeToDatabase();

    new ItemLogger().addLogItemEventCommand(new LogSimpleItemEventCommand(
        item, offerer, "slot-to-market", item.get("name"), Integer
            .toString(getQuantity(item)), "new offer",
View Full Code Here

  public Offer prolongOffer(Offer offer) {
    offer.updateTimestamp();
    if (getSlot(EXPIRED_OFFERS_SLOT_NAME).has(offer.getID())) {
      // It had expired. Move to active offers slot.
      this.getSlot(EXPIRED_OFFERS_SLOT_NAME).remove(offer.getID());
      RPSlot slot = this.getSlot(OFFERS_SLOT_NAME);
      slot.add(offer);
    } else if (!getSlot(OFFERS_SLOT_NAME).has(offer.getID())) {
      // Such an offer does not exist anymore
      return null;
    }
View Full Code Here

   * @param seconds
   *            age of offers in seconds
   * @return list of earnings that are older than the specified time
   */
  public List<Earning> getEarningsOlderThan(int seconds) {
    RPSlot slot = this.getSlot(EARNINGS_SLOT_NAME);
    List<Earning> earnings = new LinkedList<Earning>();
    for (RPObject o : slot) {
      earnings.add((Earning) o);
    }
    return getOlderThan(earnings, seconds);
View Full Code Here

   */
  protected boolean syncContent() {
    if (attending != null) {
      /* Can be replaced when we add Equip event */
      /* Mirror chest content into player's bank slot */
      final RPSlot bank = getBankSlot();
      bank.clear();

      for (final RPObject item : getSlot("content")) {
        try {
          bank.addPreservingId(cloneItem(item));
        } catch (final Exception e) {
          LOGGER.error("Cannot clone item " + item, e);
        }
      }

View Full Code Here

    attending = user;

    chestSynchronizer = new SyncContent();
    SingletonRepository.getTurnNotifier().notifyInTurns(0, chestSynchronizer);

    final RPSlot content = getSlot("content");
    content.clear();

    for (final RPObject item : getBankSlot()) {
      try {
        content.addPreservingId(cloneItem(item));
      } catch (final Exception e) {
        LOGGER.error("Cannot clone item " + item, e);
      }
    }
View Full Code Here

    this.player = player;
  }

  public void storePet(final Pet pet) {
    if (!player.hasSlot("#pets")) {
      player.addSlot(new RPSlot("#pets"));
    }

    final RPSlot slot = player.getSlot("#pets");
    slot.clear();

    /*
     * RPSlot.add() destroys zoneid, so preserve/restore it.
     *
     * TODO: Remove if getID()/setID() are made purely virtual.
     */
    String zoneid;

    if (pet.has("zoneid")) {
      zoneid = pet.get("zoneid");
    } else {
      zoneid = null;
    }

    slot.add(pet);

    if (zoneid != null) {
      pet.put("zoneid", zoneid);
    }

View Full Code Here

TOP

Related Classes of marauroa.common.game.RPSlot

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.