mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Fixed results of FindBugs.
This commit is contained in:
@@ -376,9 +376,12 @@ public class GameAction {
|
||||
public final void controllerChangeZoneCorrection(final Card c) {
|
||||
System.out.println("Correcting zone for " + c.toString());
|
||||
final PlayerZone oldBattlefield = AllZone.getZoneOf(c);
|
||||
if (oldBattlefield == null) {
|
||||
return;
|
||||
}
|
||||
final PlayerZone newBattlefield = c.getController().getZone(oldBattlefield.getZoneType());
|
||||
|
||||
if ((oldBattlefield == null) || (newBattlefield == null) || oldBattlefield.equals(newBattlefield)) {
|
||||
if (newBattlefield == null || oldBattlefield.equals(newBattlefield)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -671,9 +674,11 @@ public class GameAction {
|
||||
runParams.put("Destination", ZoneType.Library.name());
|
||||
AllZone.getTriggerHandler().runTrigger(TriggerType.ChangesZone, runParams);
|
||||
|
||||
Player owner = p.getPlayer();
|
||||
if (owner != null) {
|
||||
owner.updateLabelObservers();
|
||||
if (p != null) {
|
||||
Player owner = p.getPlayer();
|
||||
if (owner != null) {
|
||||
owner.updateLabelObservers();
|
||||
}
|
||||
}
|
||||
|
||||
// Soulbond unpairing
|
||||
|
||||
@@ -199,7 +199,7 @@ public final class MtgDataParser implements Iterator<CardRules> {
|
||||
"([A-Z0-9][A-Z0-9][A-Z0-9] [CURM], )*[A-Z0-9][A-Z0-9][A-Z0-9] [CURM]", nextline)) {
|
||||
rules.add(nextline);
|
||||
}
|
||||
ret.setCardRules((String[]) rules.toArray());
|
||||
ret.setCardRules(rules.toArray(new String[rules.size()]));
|
||||
|
||||
return nextline;
|
||||
}
|
||||
|
||||
@@ -2491,7 +2491,7 @@ public final class AbilityFactoryChangeZone {
|
||||
final Cost abCost = af.getAbCost();
|
||||
final Card source = sa.getSourceCard();
|
||||
final HashMap<String, String> params = af.getMapParams();
|
||||
final String destination = params.get("Destination");
|
||||
final ZoneType destination = ZoneType.smartValueOf(params.get("Destination"));
|
||||
final ZoneType origin = ZoneType.smartValueOf(params.get("Origin"));
|
||||
|
||||
if (abCost != null) {
|
||||
@@ -2679,7 +2679,7 @@ public final class AbilityFactoryChangeZone {
|
||||
public static boolean changeZoneAllTriggerAINoCost(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) {
|
||||
// Change Zone All, can be any type moving from one zone to another
|
||||
final HashMap<String, String> params = af.getMapParams();
|
||||
final String destination = params.get("Destination");
|
||||
final ZoneType destination = ZoneType.smartValueOf(params.get("Destination"));
|
||||
final ZoneType origin = ZoneType.smartValueOf(params.get("Origin"));
|
||||
|
||||
CardList humanType = AllZone.getHumanPlayer().getCardsIn(origin);
|
||||
|
||||
@@ -1650,7 +1650,7 @@ public final class AbilityFactoryChoose {
|
||||
chosen = list.get(0).getName();
|
||||
}
|
||||
}
|
||||
if (chosen == "") {
|
||||
if (chosen.equals("")) {
|
||||
chosen = "Morphling";
|
||||
}
|
||||
GuiUtils.chooseOne("Computer picked: ", chosen);
|
||||
|
||||
@@ -2665,7 +2665,7 @@ public class AbilityFactoryCounters {
|
||||
if (source.getCounters(cType) >= amount) {
|
||||
if (!dest.hasKeyword("CARDNAME can't have counters placed on it.")
|
||||
&& !(dest.hasKeyword("CARDNAME can't have -1/-1 counters placed on it.") && cType
|
||||
.equals("M1M1"))) {
|
||||
.equals(Counters.M1M1))) {
|
||||
dest.addCounter(cType, amount);
|
||||
source.subtractCounter(cType, amount);
|
||||
}
|
||||
|
||||
@@ -863,8 +863,8 @@ public final class AbilityFactoryReveal {
|
||||
}
|
||||
sb.append(". Put ");
|
||||
|
||||
final String found = params.get("FoundDestination");
|
||||
final String revealed = params.get("RevealedDestination");
|
||||
final ZoneType found = ZoneType.smartValueOf(params.get("FoundDestination"));
|
||||
final ZoneType revealed = ZoneType.smartValueOf(params.get("RevealedDestination"));
|
||||
if (found != null) {
|
||||
|
||||
sb.append(untilAmount > 1 ? "those cards" : "that card");
|
||||
|
||||
@@ -492,10 +492,7 @@ public class AbilityFactorySetState {
|
||||
if (list.get(i).isDoubleFaced()) {
|
||||
if (list.get(i).getCurState() == CardCharactersticName.Original) {
|
||||
if (list.get(i).changeToState(CardCharactersticName.Transformed) && remChanged) {
|
||||
if (remChanged) {
|
||||
abilityFactory.getHostCard().addRemembered(list.get(i));
|
||||
}
|
||||
|
||||
abilityFactory.getHostCard().addRemembered(list.get(i));
|
||||
}
|
||||
} else if (list.get(i).getCurState() == CardCharactersticName.Transformed) {
|
||||
if (list.get(i).changeToState(CardCharactersticName.Original)) {
|
||||
|
||||
@@ -47,7 +47,7 @@ public class AbilityMana extends AbilityActivated implements java.io.Serializabl
|
||||
private String origProduced;
|
||||
private String lastExpressChoice = "";
|
||||
private String manaRestrictions = "";
|
||||
private ArrayList<Mana> lastProduced = new ArrayList<Mana>();;
|
||||
private ArrayList<Mana> lastProduced = new ArrayList<Mana>();
|
||||
private int amount = 1;
|
||||
|
||||
/** The reflected. */
|
||||
|
||||
@@ -111,7 +111,7 @@ public class InputPayManaCostUtil {
|
||||
String colorsNeeded = colorRequired.toString();
|
||||
if ("1".equals(colorsNeeded)) { // only colorless left
|
||||
if (sa.getSourceCard() != null
|
||||
&& sa.getSourceCard().getSVar("ManaNeededToAvoidNegativeEffect") != "") {
|
||||
&& !sa.getSourceCard().getSVar("ManaNeededToAvoidNegativeEffect").equals("")) {
|
||||
colorsNeeded = "";
|
||||
String[] negEffects = sa.getSourceCard().getSVar("ManaNeededToAvoidNegativeEffect").split(",");
|
||||
for (String negColor : negEffects) {
|
||||
|
||||
@@ -782,16 +782,17 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
public final void skipTurn(final Player player) {
|
||||
// skipping turn without having extras is equivalent to giving your
|
||||
// opponent an extra turn
|
||||
if (this.extraTurns.isEmpty()) {
|
||||
this.addExtraTurn(player.getOpponent());
|
||||
} else {
|
||||
final int pos = this.extraTurns.lastIndexOf(player);
|
||||
if (pos == -1) {
|
||||
this.addExtraTurn(player.getOpponent());
|
||||
} else {
|
||||
this.extraTurns.remove(pos);
|
||||
boolean skipped = false;
|
||||
for (ExtraTurn turn : this.extraTurns) {
|
||||
if (turn.getPlayer().equals(player)) {
|
||||
this.extraTurns.remove(turn);
|
||||
skipped = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!skipped) {
|
||||
this.addExtraTurn(player.getOpponent());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -122,22 +122,6 @@ public class AIPlayer extends Player {
|
||||
// /
|
||||
// //////////////////////////////
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final CardList mayDrawCard() {
|
||||
return this.mayDrawCards(1);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final CardList mayDrawCards(final int n) {
|
||||
if (this.getCardsIn(ZoneType.Library).size() > n) {
|
||||
return this.drawCards(n);
|
||||
} else {
|
||||
return new CardList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* dredge.
|
||||
|
||||
@@ -880,7 +880,7 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
// Make mana needed to avoid negative effect a mandatory cost for the AI
|
||||
if (card.getSVar("ManaNeededToAvoidNegativeEffect") != "") {
|
||||
if (!card.getSVar("ManaNeededToAvoidNegativeEffect").equals("")) {
|
||||
final String[] negEffects = card.getSVar("ManaNeededToAvoidNegativeEffect").split(",");
|
||||
int amountAdded = 0;
|
||||
for (int nStr = 0; nStr < negEffects.length; nStr++) {
|
||||
@@ -1018,7 +1018,9 @@ public class ComputerUtil {
|
||||
}
|
||||
|
||||
final Cost cost = m.getPayCosts();
|
||||
needsLimitedResources |= !cost.isReusuableResource();
|
||||
if (cost != null) {
|
||||
needsLimitedResources |= !cost.isReusuableResource();
|
||||
}
|
||||
|
||||
// if the AI can't pay the additional costs skip the mana
|
||||
// ability
|
||||
|
||||
@@ -114,22 +114,6 @@ public class HumanPlayer extends Player {
|
||||
// /
|
||||
// /////////////
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final CardList mayDrawCards(final int n) {
|
||||
if (this.canDraw() && GameActionUtil.showYesNoDialog(null, "Draw " + n + " cards?")) {
|
||||
return this.drawCards(n);
|
||||
} else {
|
||||
return new CardList();
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final CardList mayDrawCard() {
|
||||
return this.mayDrawCards(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* dredge.
|
||||
|
||||
@@ -1145,26 +1145,6 @@ public abstract class Player extends GameEntity {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* mayDrawCard.
|
||||
* </p>
|
||||
*
|
||||
* @return a CardList of cards actually drawn
|
||||
*/
|
||||
public abstract CardList mayDrawCard();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* mayDrawCards.
|
||||
* </p>
|
||||
*
|
||||
* @param numCards
|
||||
* a int.
|
||||
* @return a CardList of cards actually drawn
|
||||
*/
|
||||
public abstract CardList mayDrawCards(int numCards);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* drawCard.
|
||||
|
||||
@@ -164,7 +164,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
||||
|
||||
final boolean faceDown = card.isFaceDown() && (card.getController() != AllZone.getHumanPlayer());
|
||||
if (!faceDown) {
|
||||
if (card.getManaCost().equals("") || card.isLand()) {
|
||||
if (card.getManaCost().toString().equals("") || card.isLand()) {
|
||||
this.nameCostLabel.setText(card.getName());
|
||||
} else {
|
||||
this.nameCostLabel.setText(card.getName() + " - " + card.getManaCost());
|
||||
@@ -328,7 +328,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
||||
}
|
||||
|
||||
// chosen type
|
||||
if (card.getChosenType() != "") {
|
||||
if (!card.getChosenType().equals("")) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
@@ -348,7 +348,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
||||
}
|
||||
|
||||
// named card
|
||||
if (card.getNamedCard() != "") {
|
||||
if (!card.getNamedCard().equals("")) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ public class GuiImportPicture extends JDialog {
|
||||
@Override
|
||||
public void mouseClicked(final java.awt.event.MouseEvent e) {
|
||||
GuiImportPicture.this.jButtonStart.setEnabled(false);
|
||||
if (GuiImportPicture.this.jLabelSource.getText() != "") {
|
||||
if (GuiImportPicture.this.jLabelSource.getText().equals("")) {
|
||||
final FileFinder ff = new FileFinder();
|
||||
try {
|
||||
GuiImportPicture.this.listFiles = ff.findFiles(GuiImportPicture.this.jLabelSource.getText()
|
||||
|
||||
@@ -291,7 +291,7 @@ public final class SColumnUtil {
|
||||
final ACEditorBase<TItem, TModel> ed = (ACEditorBase<TItem, TModel>)
|
||||
CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController();
|
||||
|
||||
final JTable tbl = (id0.toString().substring(0, 4) == "DECK")
|
||||
final JTable tbl = (id0.toString().substring(0, 4).equals("DECK"))
|
||||
? ed.getTableDeck().getTable()
|
||||
: ed.getTableCatalog().getTable();
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ public class TableColumnInfo<T> extends TableColumn {
|
||||
* @return the fnSort
|
||||
*/
|
||||
public Lambda1<Comparable, Entry<T, Integer>> getFnSort() {
|
||||
if (fnSort.equals(null)) {
|
||||
if (fnSort == null) {
|
||||
throw new NullPointerException("A sort function hasn't been set for "
|
||||
+ "Column " + TableColumnInfo.this.getIdentifier());
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class TableColumnInfo<T> extends TableColumn {
|
||||
* @return the fnDisplay
|
||||
*/
|
||||
public Lambda1<Object, Entry<T, Integer>> getFnDisplay() {
|
||||
if (fnSort.equals(null)) {
|
||||
if (fnSort == null) {
|
||||
throw new NullPointerException("A display function hasn't been set for "
|
||||
+ "Column " + TableColumnInfo.this.getIdentifier());
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ public final class DragCell extends JPanel implements ILocalRepaint {
|
||||
temp.priorityDecrease();
|
||||
}
|
||||
|
||||
if (temp.equals(docSelected)) { continue; }
|
||||
if (d.equals(docSelected)) { continue; }
|
||||
if (temp.getPriority() > lowest) { continue; }
|
||||
if (temp.getPriority() <= currentPriority0) { continue; }
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class SDisplayUtil {
|
||||
final int delay = 80; // Milliseconds between steps
|
||||
|
||||
if (remindIsRunning) { return; }
|
||||
if (pnl.equals(null)) { return; }
|
||||
if (pnl == null) { return; }
|
||||
|
||||
remindIsRunning = true;
|
||||
final int oldR = pnl.getBackground().getRed();
|
||||
|
||||
@@ -166,7 +166,7 @@ public final class SRearrangingUtil {
|
||||
&& (cellTarget.getW() / 2) > SResizingUtil.W_MIN) {
|
||||
dropzone = Dropzone.RIGHT;
|
||||
pnlDocument.setCursor(CUR_R);
|
||||
tempW = Math.round(cellTarget.getW() / 2);
|
||||
tempW = cellTarget.getW() / 2;
|
||||
|
||||
pnlPreview.setBounds(
|
||||
cellTarget.getX() + cellTarget.getW() - tempW,
|
||||
@@ -191,7 +191,7 @@ public final class SRearrangingUtil {
|
||||
&& (cellTarget.getH() / 2) > SResizingUtil.H_MIN) {
|
||||
dropzone = Dropzone.BOTTOM;
|
||||
pnlDocument.setCursor(CUR_B);
|
||||
tempH = Math.round(cellTarget.getH() / 2);
|
||||
tempH = cellTarget.getH() / 2;
|
||||
|
||||
pnlPreview.setBounds(
|
||||
cellTarget.getX() + SLayoutConstants.BORDER_T,
|
||||
@@ -244,7 +244,7 @@ public final class SRearrangingUtil {
|
||||
case LEFT:
|
||||
cellNew.setBounds(
|
||||
tempX, tempY,
|
||||
Math.round(tempW / 2), tempH);
|
||||
tempW / 2, tempH);
|
||||
cellTarget.setBounds(
|
||||
tempX + cellNew.getW(), tempY,
|
||||
tempW - cellNew.getW(), tempH);
|
||||
@@ -253,7 +253,7 @@ public final class SRearrangingUtil {
|
||||
case RIGHT:
|
||||
cellTarget.setBounds(
|
||||
tempX, tempY,
|
||||
Math.round(tempW / 2), tempH);
|
||||
tempW / 2, tempH);
|
||||
cellNew.setBounds(
|
||||
cellTarget.getX() + cellTarget.getW(), tempY ,
|
||||
tempW - cellTarget.getW(), tempH);
|
||||
@@ -262,7 +262,7 @@ public final class SRearrangingUtil {
|
||||
case TOP:
|
||||
cellNew.setBounds(
|
||||
tempX, tempY,
|
||||
tempW, tempH - Math.round(tempH / 2));
|
||||
tempW, tempH - (tempH / 2));
|
||||
cellTarget.setBounds(
|
||||
tempX, tempY + cellNew.getH(),
|
||||
tempW, tempH - cellNew.getH());
|
||||
@@ -271,7 +271,7 @@ public final class SRearrangingUtil {
|
||||
case BOTTOM:
|
||||
cellTarget.setBounds(
|
||||
tempX, tempY,
|
||||
tempW, Math.round(tempH / 2));
|
||||
tempW, tempH / 2);
|
||||
|
||||
cellNew.setBounds(
|
||||
tempX, cellTarget.getY() + cellTarget.getH(),
|
||||
|
||||
Reference in New Issue
Block a user