- More changes related to supporting negative power and toughness, please test to see this doesn't break anything.

- Fixed some visualization issues in the deck editor related to supporting negative P/T (e.g. non-creatures showing up as P/T 2 billion+ / 2 billion+).
This commit is contained in:
Agetian
2016-10-09 12:05:55 +00:00
parent 401dba1596
commit 2cd7016703
7 changed files with 18 additions and 16 deletions

View File

@@ -236,7 +236,7 @@ public class GameCopier {
int setPower = c.getSetPower(); int setPower = c.getSetPower();
int setToughness = c.getSetToughness(); int setToughness = c.getSetToughness();
if (setPower != -1 || setToughness != -1) { if (setPower != Integer.MAX_VALUE || setToughness != Integer.MAX_VALUE) {
// TODO: Copy the full list with timestamps. // TODO: Copy the full list with timestamps.
newCard.addNewPT(setPower, setToughness, newGame.getNextTimestamp()); newCard.addNewPT(setPower, setToughness, newGame.getNextTimestamp());
} }

View File

@@ -288,7 +288,7 @@ public class CloneEffect extends SpellAbilityEffect {
// set power of clone // set power of clone
if (sa.hasParam("SetPower")) { if (sa.hasParam("SetPower")) {
String rhs = sa.getParam("SetPower"); String rhs = sa.getParam("SetPower");
int power = -1; int power = Integer.MAX_VALUE;
try { try {
power = Integer.parseInt(rhs); power = Integer.parseInt(rhs);
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
@@ -305,7 +305,7 @@ public class CloneEffect extends SpellAbilityEffect {
// set toughness of clone // set toughness of clone
if (sa.hasParam("SetToughness")) { if (sa.hasParam("SetToughness")) {
String rhs = sa.getParam("SetToughness"); String rhs = sa.getParam("SetToughness");
int toughness = -1; int toughness = Integer.MAX_VALUE;
try { try {
toughness = Integer.parseInt(rhs); toughness = Integer.parseInt(rhs);
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {

View File

@@ -191,7 +191,7 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
// set power of clone // set power of clone
if (sa.hasParam("SetPower")) { if (sa.hasParam("SetPower")) {
String rhs = sa.getParam("SetPower"); String rhs = sa.getParam("SetPower");
int power = -1; int power = Integer.MAX_VALUE;
try { try {
power = Integer.parseInt(rhs); power = Integer.parseInt(rhs);
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
@@ -208,7 +208,7 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
// set toughness of clone // set toughness of clone
if (sa.hasParam("SetToughness")) { if (sa.hasParam("SetToughness")) {
String rhs = sa.getParam("SetToughness"); String rhs = sa.getParam("SetToughness");
int toughness = -1; int toughness = Integer.MAX_VALUE;
try { try {
toughness = Integer.parseInt(rhs); toughness = Integer.parseInt(rhs);
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {

View File

@@ -2700,7 +2700,7 @@ public class Card extends GameEntity implements Comparable<Card> {
* Get the latest set Power and Toughness of this Card. * Get the latest set Power and Toughness of this Card.
* *
* @return the latest set Power and Toughness of this {@link Card} as the * @return the latest set Power and Toughness of this {@link Card} as the
* left and right values of a {@link Pair}, respectively. A value of -1 * left and right values of a {@link Pair}, respectively. A value of Integer.MAX_VALUE
* means that particular property has not been set. * means that particular property has not been set.
*/ */
private synchronized Pair<Integer, Integer> getLatestPT() { private synchronized Pair<Integer, Integer> getLatestPT() {

View File

@@ -115,9 +115,9 @@ public final class StaticAbilityContinuous {
String addT = ""; String addT = "";
int toughnessBonus = 0; int toughnessBonus = 0;
String setP = ""; String setP = "";
int setPower = -1; int setPower = Integer.MAX_VALUE;
String setT = ""; String setT = "";
int setToughness = -1; int setToughness = Integer.MAX_VALUE;
int keywordMultiplier = 1; int keywordMultiplier = 1;
String[] addKeywords = null; String[] addKeywords = null;
@@ -462,13 +462,13 @@ public final class StaticAbilityContinuous {
// set P/T // set P/T
if (layer == StaticAbilityLayer.SETPT) { if (layer == StaticAbilityLayer.SETPT) {
if (params.containsKey("CharacteristicDefining")) { if (params.containsKey("CharacteristicDefining")) {
if (setPower != -1) { if (setPower != Integer.MAX_VALUE) {
affectedCard.setBasePower(setPower); affectedCard.setBasePower(setPower);
} }
if (setToughness != -1) { if (setToughness != Integer.MAX_VALUE) {
affectedCard.setBaseToughness(setToughness); affectedCard.setBaseToughness(setToughness);
} }
} else if ((setPower != -1) || (setToughness != -1)) { } else if ((setPower != Integer.MAX_VALUE) || (setToughness != Integer.MAX_VALUE)) {
// non CharacteristicDefining // non CharacteristicDefining
if (setP.startsWith("AffectedX")) { if (setP.startsWith("AffectedX")) {
setPower = CardFactoryUtil.xCount(affectedCard, AbilityUtils.getSVar(stAb, setP)); setPower = CardFactoryUtil.xCount(affectedCard, AbilityUtils.getSVar(stAb, setP));

View File

@@ -21,7 +21,7 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
/** /**
* A quick converter to avoid -1 being displayed for unapplicable values. * A quick converter to avoid Integer.MAX_VALUE being displayed for unapplicable values.
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class IntegerRenderer extends ItemCellRenderer { public class IntegerRenderer extends ItemCellRenderer {
@@ -36,7 +36,7 @@ public class IntegerRenderer extends ItemCellRenderer {
public final Component getTableCellRendererComponent(final JTable table, Object value0, public final Component getTableCellRendererComponent(final JTable table, Object value0,
final boolean isSelected, final boolean hasFocus, final int row, final int column) { final boolean isSelected, final boolean hasFocus, final int row, final int column) {
if (value0 == null || (int)value0 == -1) { value0 = "-"; } if (value0 == null || (int)value0 == Integer.MAX_VALUE) { value0 = "-"; }
return super.getTableCellRendererComponent(table, value0, isSelected, hasFocus, row, column); return super.getTableCellRendererComponent(table, value0, isSelected, hasFocus, row, column);
} }
} }

View File

@@ -428,15 +428,17 @@ public enum ColumnDef {
int result = -1; int result = -1;
if (i instanceof PaperCard) { if (i instanceof PaperCard) {
result = ((IPaperCard) i).getRules().getIntPower(); result = ((IPaperCard) i).getRules().getIntPower();
if (result == -1) { if (result == Integer.MAX_VALUE) {
result = ((IPaperCard) i).getRules().getInitialLoyalty(); if (((IPaperCard)i).getRules().getType().isPlaneswalker()) {
result = ((IPaperCard) i).getRules().getInitialLoyalty();
}
} }
} }
return result; return result;
} }
private static Integer toToughness(final InventoryItem i) { private static Integer toToughness(final InventoryItem i) {
return i instanceof PaperCard ? ((IPaperCard) i).getRules().getIntToughness() : -1; return i instanceof PaperCard ? ((IPaperCard) i).getRules().getIntToughness() : Integer.MAX_VALUE;
} }
private static Integer toCMC(final InventoryItem i) { private static Integer toCMC(final InventoryItem i) {