|
50 | 50 | import megamek.Version; |
51 | 51 | import megamek.client.ui.swing.util.PlayerColour; |
52 | 52 | import megamek.codeUtilities.StringUtility; |
53 | | -import megamek.common.Coords; |
54 | 53 | import megamek.common.Game; |
55 | 54 | import megamek.common.IGame; |
56 | 55 | import megamek.common.Player; |
57 | 56 | import megamek.common.Roll; |
58 | 57 | import megamek.common.annotations.Nullable; |
59 | 58 | import megamek.common.commandline.AbstractCommandLineParser.ParseException; |
60 | | -import megamek.common.enums.GamePhase; |
61 | | -import megamek.common.event.GameListenerAdapter; |
62 | | -import megamek.common.event.GamePhaseChangeEvent; |
63 | 59 | import megamek.common.icons.Camouflage; |
64 | 60 | import megamek.common.net.connections.AbstractConnection; |
65 | 61 | import megamek.common.net.enums.PacketCommand; |
@@ -1369,80 +1365,6 @@ protected void handle(int connId, Packet packet) { |
1369 | 1365 |
|
1370 | 1366 | private void wargamesResponse() { |
1371 | 1367 | sendServerChat(WARGAMES_RESPONSE); |
1372 | | - wargamesAttack(3, new Random().nextInt(5, 13)); |
1373 | | - } |
1374 | | - |
1375 | | - private void wargamesAttack(int rounds, int numberOfStrikes) { |
1376 | | - if (rounds <= 0) { |
1377 | | - return; |
1378 | | - } |
1379 | | - |
1380 | | - if (this.getGame() != null && this.getGame().getBoard() != null) { |
1381 | | - int height = this.getGame().getBoard().getHeight(); |
1382 | | - int width = this.getGame().getBoard().getWidth(); // Fixed width retrieval |
1383 | | - |
1384 | | - Random random = new Random(); |
1385 | | - List<Coords> selectedCoords = new ArrayList<>(); |
1386 | | - |
1387 | | - int maxAttempts = 100; |
1388 | | - int maxStrikes = rounds == 1 ? numberOfStrikes : new Random().nextInt(1, numberOfStrikes + 1); |
1389 | | - for (int i = 0; i < maxStrikes; i++) { |
1390 | | - Coords newCoord = null; |
1391 | | - |
1392 | | - for (int attempt = 0; attempt < maxAttempts; attempt++) { |
1393 | | - int x = random.nextInt(width); |
1394 | | - int y = random.nextInt(height); |
1395 | | - Coords candidate = new Coords(x, y); |
1396 | | - |
1397 | | - boolean isValid = true; |
1398 | | - for (Coords coords : selectedCoords) { |
1399 | | - int dx = Math.abs(coords.getX() - x); |
1400 | | - int dy = Math.abs(coords.getY() - y); |
1401 | | - if (Math.max(dx, dy) <= 9) { |
1402 | | - isValid = false; |
1403 | | - break; |
1404 | | - } |
1405 | | - } |
1406 | | - |
1407 | | - if (isValid) { |
1408 | | - newCoord = candidate; |
1409 | | - break; |
1410 | | - } |
1411 | | - } |
1412 | | - |
1413 | | - if (newCoord != null) { |
1414 | | - selectedCoords.add(newCoord); |
1415 | | - } else { |
1416 | | - break; // Stop if we can't find a valid coordinate |
1417 | | - } |
1418 | | - } |
1419 | | - |
1420 | | - if (!selectedCoords.isEmpty()) { |
1421 | | - sendServerChat("!!!WARNING!!! LAUNCH OF STRATEGIC WEAPONS DETECTED"); |
1422 | | - sendServerChat("!!!WARNING!!! LAUNCH OF STRATEGIC WEAPONS DETECTED"); |
1423 | | - sendServerChat("!!!WARNING!!! LAUNCH OF STRATEGIC WEAPONS DETECTED"); |
1424 | | - } |
1425 | | - |
1426 | | - for (Coords coords : selectedCoords) { |
1427 | | - numberOfStrikes--; |
1428 | | - processCommand(SERVER_CONN, "/ob " + coords.getX() + 1 + " " + coords.getY() + 1); |
1429 | | - sendServerChat("DANGER ZONE: Incoming strategic strike at " + |
1430 | | - (coords.getX() + 1) + |
1431 | | - ", " + |
1432 | | - (coords.getY() + 1)); |
1433 | | - } |
1434 | | - } |
1435 | | - |
1436 | | - final int strikesRemaining = numberOfStrikes; |
1437 | | - this.getGame().addGameListener(new GameListenerAdapter() { |
1438 | | - @Override |
1439 | | - public void gamePhaseChange(GamePhaseChangeEvent e) { |
1440 | | - if (e.getNewPhase() == GamePhase.PREMOVEMENT) { |
1441 | | - wargamesAttack(rounds - 1, strikesRemaining); |
1442 | | - getGame().removeGameListener(this); |
1443 | | - } |
1444 | | - } |
1445 | | - }); |
1446 | 1368 | } |
1447 | 1369 |
|
1448 | 1370 | /** |
|
0 commit comments