Package net.sf.arianne.marboard.server.action

Source Code of net.sf.arianne.marboard.server.action.ClearAction

package net.sf.arianne.marboard.server.action;

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

import marauroa.common.game.RPAction;
import marauroa.common.game.RPObject;
import net.sf.arianne.marboard.server.core.engine.MarboardZone;
import net.sf.arianne.marboard.server.entity.meta.User;
import net.sf.arianne.marboard.server.entity.shape.Shape;

/**
* clears the board
*
* @author hendrik
*/
public class ClearAction implements Action {

  /**
   * clears the board.
   *
   * @param user the user wanting to execute the action
   * @param action the action to be executed   */
  public void onAction(User user, RPAction action) {
    MarboardZone zone = user.getZone();

    // create a copy of the list to prevent ConcurrentModificationException
    List<Shape> shapes = new LinkedList<Shape>();
    for (RPObject object : zone) {
      if (object instanceof Shape) {
        shapes.add((Shape) object);
      }
    }

    // remove all shapes
    for (Shape shape : shapes) {
      zone.remove(shape.getID());
    }
  }

}
TOP

Related Classes of net.sf.arianne.marboard.server.action.ClearAction

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.