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());
}
}
}