This list doesn't need to be instantiated like an array

This commit is contained in:
Chris H
2025-01-12 20:09:51 -05:00
committed by Hans Mackowiak
parent b8b2fd40d7
commit 2ce91a04f1
8 changed files with 14 additions and 10 deletions

View File

@@ -593,7 +593,7 @@ public class Game {
}
public Zone getZoneOf(final Card card) {
return card.getLastKnownZone();
return card == null ? null : card.getLastKnownZone();
}
public synchronized CardCollectionView getCardsIn(final ZoneType zone) {

View File

@@ -291,7 +291,7 @@ public final class SRearrangingUtil {
}
// 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);
}

View File

@@ -184,6 +184,10 @@ public enum CDeckEditorUI implements ICDoc {
@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);

View File

@@ -79,13 +79,14 @@ public class CCombat implements ICDoc {
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;

View File

@@ -104,10 +104,9 @@ public class VCombat implements IVDoc<CCombat> {
//========= 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);

View File

@@ -135,7 +135,7 @@ public class VLog implements IVDoc<CLog> {
}
private boolean isGameLogConsoleVisible() {
return parentCell.getSelected().equals(this);
return parentCell != null && parentCell.getSelected().equals(this);
}
private void resetDisplayIfNewGame(final GameView model) {

View File

@@ -123,7 +123,7 @@ public class VStack implements IVDoc<CStack> {
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();

View File

@@ -278,7 +278,7 @@ public abstract class CardPanelContainer extends SkinnedPanel {
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;
}
}