Skip to content

Commit

Permalink
handle overlapping start positions and player display
Browse files Browse the repository at this point in the history
  • Loading branch information
kuronekochomusuke committed Nov 24, 2023
1 parent 2d419e1 commit c4cd96c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ ChatLounge.notDone=Not Done
ChatLounge.PartialRepairs=Partial Repairs
ChatLounge.Player=Player
ChatLounge.Players=Players
ChatLounge.Player0=Player0
ChatLounge.quickView=Unit Quick View
ChatLounge.OverlapDeploy.title=Must choose exclusive deployment zone
ChatLounge.OverlapDeploy.msg=When using double blind, each player needs to have an exclusive deployment zone.
Expand Down
15 changes: 13 additions & 2 deletions megamek/src/megamek/client/ui/swing/lobby/LobbyUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,22 @@ static boolean isValidStartPos(Game game, Player player, int pos) {
if (!isExclusiveDeployment(game)) {
return true;
} else {
final GameOptions gOpts = game.getOptions();
List<Player> players = game.getPlayersList();

if (gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0) && !player.isBot() && player.getId() != 0) {
return true;
}

if (gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0)) {
players = players.stream().filter(p -> p.isBot() || p.getId() == 0).collect(Collectors.toList());
}

if (isTeamsShareVision(game)) {
return game.getPlayersVector().stream().filter(p -> p.isEnemyOf(player))
return players.stream().filter(p -> p.isEnemyOf(player))
.noneMatch(p -> startPosOverlap(pos, p.getStartingPos()));
} else {
return game.getPlayersVector().stream().filter(p -> !p.equals(player))
return players.stream().filter(p -> !p.equals(player))
.noneMatch(p -> startPosOverlap(pos, p.getStartingPos()));
}
}
Expand Down
7 changes: 6 additions & 1 deletion megamek/src/megamek/client/ui/swing/lobby/PlayerTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import megamek.client.ui.swing.util.UIUtil;
import megamek.common.IStartingPositions;
import megamek.common.Player;
import megamek.common.options.GameOptions;
import megamek.common.options.OptionsConstants;

import javax.swing.*;
Expand Down Expand Up @@ -195,7 +196,11 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
result.append(guiScaledFontHTML());

String msg_start = Messages.getString("ChatLounge.Start");
if ((player.getStartingPos() >= 0) && (player.getStartingPos() <= IStartingPositions.START_LOCATION_NAMES.length)) {

final GameOptions gOpts = lobby.game().getOptions();
if (gOpts.booleanOption(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0) && !player.isBot() && player.getId() != 0) {
result.append(msg_start + ": " + Messages.getString("ChatLounge.Player0"));
} else if ((player.getStartingPos() >= 0) && (player.getStartingPos() <= IStartingPositions.START_LOCATION_NAMES.length)) {
result.append(msg_start + ": " + IStartingPositions.START_LOCATION_NAMES[player.getStartingPos()]);
int so = player.getStartOffset();
int sw = player.getStartWidth();
Expand Down

0 comments on commit c4cd96c

Please sign in to comment.