package net.sf.arianne.marboard.server.core.engine;
import java.awt.Color;
import marauroa.common.game.IRPZone;
import marauroa.common.game.RPObject;
import marauroa.server.game.rp.RPWorld;
import net.sf.arianne.marboard.server.entity.shape.Dot;
import net.sf.arianne.marboard.server.entity.shape.Shape;
/**
* the world of all drawing boards
*
* @author hendrik
*/
public class MarboardWorld extends RPWorld {
private static MarboardWorld instance;
/**
* returns the RPWorld
*
* @return RPWorld
*/
public static MarboardWorld get() {
if (instance == null) {
instance = new MarboardWorld();
instance.initialize();
}
return instance;
}
/**
* initializes the world
*/
@Override
protected void initialize() {
super.initialize();
MarboardRPClassGenerator.generate();
MarboardZone zone = new MarboardZone("initial_zone");
super.addRPZone(zone);
for (int i = 0; i < 20; i++) {
Shape shape = new Dot(Color.BLACK.getRGB(), i, i * 25 + 25, i * 25 + 25, i);
zone.add(shape);
}
Shape shape = new Dot(Color.RED.getRGB(), 10, 50, 25, 30);
zone.add(shape);
}
/**
* gets the MarboardZone in which the specified object is at the moment
*
* @param objectid specifed object
* @return MarboardZone
*/
public MarboardZone getMarboardZone(RPObject.ID objectid) {
IRPZone zone = super.getRPZone(objectid);
if (zone == null) {
return null;
}
if (zone instanceof MarboardZone) {
return (MarboardZone) zone;
}
throw new IllegalArgumentException("Excepted a MarboardZone but got something of class " + zone.getClass().getName() + ": " + zone);
}
}