public MoveInfo getMovementChanges(Game game, MoveStep step)
throws MovementException {
MapObjectReader moReader = game.getMapObjectReader();
Coordinate to = step.getTo();
if (step.getNumberOfUnits() == 0) {
// there are no Units to move
throw new MovementException("UnitMover.getMovementChanges: "
+ "Where are my Units??? "
+ "I need them!!!");
}
Iterator<Long> iterator = step.getUnitIterator();
int numberOfUnits = 1;
// exists because of test above
Long aUnit = iterator.next();
Coordinate from = moReader.getMapObjectPosition(aUnit);
// all units need to be on the same field
while (iterator.hasNext()) {
if (!(from.equals(moReader.getMapObjectPosition(iterator.next())))) {
// for now
throw new MovementException("UnitMover.getMovementChanges: "
+ "All given Units need to be "
+ "located on the same field!");
}
numberOfUnits++;
}
Long[] units = new Long[numberOfUnits];
int z = 0;
iterator = step.getUnitIterator();
while (iterator.hasNext()) {
units[z] = iterator.next();
z++;
}
if (from.equals(to)) {
throw new MovementException("UnitMover.getMovementChanges: "
+ "From != To is required!");
}