MCPcopy Create free account
hub / github.com/Neop/mudmap2 / connectPath

Method connectPath

src/main/java/mudmap2/backend/Place.java:263–289  ·  view source on GitHub ↗

Connects a place to another one tht is specified in path If 'this place' is not in path an exception will be thrown @param path

(final Path path)

Source from the content-addressed store, hash-verified

261 * @param path
262 */
263 public void connectPath(final Path path) throws RuntimeException, NullPointerException {
264 final Place[] pp = path.getPlaces();
265 Place other;
266
267 if (pp[0] == this) {
268 other = pp[1];
269 } else if (pp[1] == this) {
270 other = pp[0];
271 } else {
272 throw new RuntimeException("Wrong place in given path");
273 }
274
275 // check whether other place is null
276 if (other == null) {
277 throw new NullPointerException();
278 }
279
280 // check whether the path connects a place with itself on the same exit
281 if (other == this && path.getExitDirections()[0].equals(path.getExitDirections()[1])) {
282 throw new RuntimeException("Can not connect path to the same exit of one place");
283 }
284
285 paths.add(path);
286 other.paths.add(path);
287
288 callWorldChangeListeners();
289 }
290
291 /**
292 * Get a set of paths connected to exit

Callers 15

testGetExitMethod · 0.95
testGetPaths_PlaceMethod · 0.95
testGetPaths_0argsMethod · 0.95
testRemovePathMethod · 0.95
testConnectPathMethod · 0.95
testGetPathToMethod · 0.95
testRemoveConnectionsMethod · 0.95
testBreadthSearchMethod · 0.95
testReadWriteFileMethod · 0.95
testReadWriteFileMethod · 0.95

Calls 3

getExitDirectionsMethod · 0.80
getPlacesMethod · 0.45

Tested by 13

testGetExitMethod · 0.76
testGetPaths_PlaceMethod · 0.76
testGetPaths_0argsMethod · 0.76
testRemovePathMethod · 0.76
testConnectPathMethod · 0.76
testGetPathToMethod · 0.76
testRemoveConnectionsMethod · 0.76
testBreadthSearchMethod · 0.76
testReadWriteFileMethod · 0.76
testReadWriteFileMethod · 0.76