Skip to content

Commit

Permalink
This list doesn't need to be instantiated like an array
Browse files Browse the repository at this point in the history
  • Loading branch information
tehdiplomat authored and Hanmac committed Jan 13, 2025
1 parent b8b2fd4 commit 2ce91a0
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion forge-game/src/main/java/forge/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ public synchronized void setGameOver(GameEndReason reason) {
}

public Zone getZoneOf(final Card card) {
return card.getLastKnownZone();
return card == null ? null : card.getLastKnownZone();
}

public synchronized CardCollectionView getCardsIn(final ZoneType zone) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ private static void endRearrange() {
}

// Remove old cell if necessary, or, enforce rough bounds on new cell.
if (cellSrc.getDocs().size() == 0) {
if (cellSrc.getDocs().isEmpty()) {
fillGap();
FView.SINGLETON_INSTANCE.removeDragCell(cellSrc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ private <T extends InventoryItem> void moveSelectedItems(final ItemManager<T> it

@SuppressWarnings("unchecked")
public void addSelectedCards(final boolean toAlternate, final int number) {
if (childController == null || childController.getCatalogManager() == null) {
return;
}

moveSelectedItems(childController.getCatalogManager(), new _MoveAction() {
@Override public <T extends InventoryItem> void move(final Iterable<Entry<T, Integer>> items) {
((ACEditorBase<T, ?>)childController).addItems(items, toAlternate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ private static String getCombatDescription(final CombatView localCombat, final G
display.append("\n");
if (defender instanceof CardView) {
PlayerView controller = ((CardView) defender).getController();
if (controller == null)
if (controller == null) {
//shouldn't be null but display card's + controller ie Black Knight's controller
display.append(Lang.getInstance().getPossesive(defender.getName())).append(" controller");
else
} else {
display.append(Lang.getInstance().getPossesive(controller.getName())).append(" ");
}
}
display.append(defender).append(" is attacked by:\n");
display.append(defender).append(" is attacked by:\n`");

// Associate Bands, Attackers Blockers
boolean previousBand = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ public CCombat getLayoutControl() {

//========= Observer update methods

/** @param s0 &emsp; {@link java.lang.String} */
public void updateCombat(final int cntAttackers, final String desc) {
// No need to update this unless it's showing
if (!this.equals(parentCell.getSelected())) { return; }
if (parentCell == null || !this.equals(parentCell.getSelected())) { return; }

tab.setText(cntAttackers > 0 ? (Localizer.getInstance().getMessage("lblCombatTab") + " : " + cntAttackers) : Localizer.getInstance().getMessage("lblCombatTab"));
tar.setText(desc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void updateConsole() {
}

private boolean isGameLogConsoleVisible() {
return parentCell.getSelected().equals(this);
return parentCell != null && parentCell.getSelected().equals(this);
}

private void resetDisplayIfNewGame(final GameView model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void updateStack() {
tab.setText(Localizer.getInstance().getMessage("lblStack") + " : " + items.size());

// No need to update the rest unless it's showing
if (!parentCell.getSelected().equals(this)) { return; }
if (parentCell == null || !parentCell.getSelected().equals(this)) { return; }

hoveredItem = null;
scroller.removeAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public CardPanel addCard(final CardView card) {

public final CardPanel getCardPanel(final int gameCardID) {
for (final CardPanel panel : this.getCardPanels()) {
if (panel.getCard().getId() == gameCardID) {
if (panel.getCard() != null && panel.getCard().getId() == gameCardID) {
return panel;
}
}
Expand Down

0 comments on commit 2ce91a0

Please sign in to comment.