} else if (head.equals("#ship")) {
String name = name(t.child(0));
String type = string(t.child(1));
- Ship ship = null;
-
- if (fleet instanceof FleetWithDynamicShips) {
- FleetWithDynamicShips dyn = ((FleetWithDynamicShips)fleet);
- ship = dyn.createShip(type, name);
- if (ship==null)
- throw new RuntimeException("couldn't find a ship called \""+type+"\"");
- } else {
- ship = allocateShip(type);
- }
+ Ship ship = allocateShip(type);
shipMap.put(name, ship);
} else if (head.equals("#expect")) {
allocated--;
}
}
- throw new RuntimeException("no more ships of type \""+shipType+"\"");
+ if (fleet instanceof FleetWithDynamicShips) {
+ FleetWithDynamicShips dyn = ((FleetWithDynamicShips)fleet);
+ Ship ship = dyn.createShip(shipType, shipType+allocated);
+ if (ship==null)
+ throw new RuntimeException("couldn't find a ship called \""+shipType+"\"");
+ return ship;
+ } else {
+ throw new RuntimeException("no more ships of type \""+shipType+"\"");
+ }
}
private long parseSSL(Tree t) {