mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
- 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:
@@ -236,7 +236,7 @@ public class GameCopier {
|
||||
|
||||
int setPower = c.getSetPower();
|
||||
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.
|
||||
newCard.addNewPT(setPower, setToughness, newGame.getNextTimestamp());
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ public class CloneEffect extends SpellAbilityEffect {
|
||||
// set power of clone
|
||||
if (sa.hasParam("SetPower")) {
|
||||
String rhs = sa.getParam("SetPower");
|
||||
int power = -1;
|
||||
int power = Integer.MAX_VALUE;
|
||||
try {
|
||||
power = Integer.parseInt(rhs);
|
||||
} catch (final NumberFormatException e) {
|
||||
@@ -305,7 +305,7 @@ public class CloneEffect extends SpellAbilityEffect {
|
||||
// set toughness of clone
|
||||
if (sa.hasParam("SetToughness")) {
|
||||
String rhs = sa.getParam("SetToughness");
|
||||
int toughness = -1;
|
||||
int toughness = Integer.MAX_VALUE;
|
||||
try {
|
||||
toughness = Integer.parseInt(rhs);
|
||||
} catch (final NumberFormatException e) {
|
||||
|
||||
@@ -191,7 +191,7 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
|
||||
// set power of clone
|
||||
if (sa.hasParam("SetPower")) {
|
||||
String rhs = sa.getParam("SetPower");
|
||||
int power = -1;
|
||||
int power = Integer.MAX_VALUE;
|
||||
try {
|
||||
power = Integer.parseInt(rhs);
|
||||
} catch (final NumberFormatException e) {
|
||||
@@ -208,7 +208,7 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
|
||||
// set toughness of clone
|
||||
if (sa.hasParam("SetToughness")) {
|
||||
String rhs = sa.getParam("SetToughness");
|
||||
int toughness = -1;
|
||||
int toughness = Integer.MAX_VALUE;
|
||||
try {
|
||||
toughness = Integer.parseInt(rhs);
|
||||
} catch (final NumberFormatException e) {
|
||||
|
||||
@@ -2700,7 +2700,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* Get the latest set Power and Toughness of this Card.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
private synchronized Pair<Integer, Integer> getLatestPT() {
|
||||
|
||||
@@ -115,9 +115,9 @@ public final class StaticAbilityContinuous {
|
||||
String addT = "";
|
||||
int toughnessBonus = 0;
|
||||
String setP = "";
|
||||
int setPower = -1;
|
||||
int setPower = Integer.MAX_VALUE;
|
||||
String setT = "";
|
||||
int setToughness = -1;
|
||||
int setToughness = Integer.MAX_VALUE;
|
||||
int keywordMultiplier = 1;
|
||||
|
||||
String[] addKeywords = null;
|
||||
@@ -462,13 +462,13 @@ public final class StaticAbilityContinuous {
|
||||
// set P/T
|
||||
if (layer == StaticAbilityLayer.SETPT) {
|
||||
if (params.containsKey("CharacteristicDefining")) {
|
||||
if (setPower != -1) {
|
||||
if (setPower != Integer.MAX_VALUE) {
|
||||
affectedCard.setBasePower(setPower);
|
||||
}
|
||||
if (setToughness != -1) {
|
||||
if (setToughness != Integer.MAX_VALUE) {
|
||||
affectedCard.setBaseToughness(setToughness);
|
||||
}
|
||||
} else if ((setPower != -1) || (setToughness != -1)) {
|
||||
} else if ((setPower != Integer.MAX_VALUE) || (setToughness != Integer.MAX_VALUE)) {
|
||||
// non CharacteristicDefining
|
||||
if (setP.startsWith("AffectedX")) {
|
||||
setPower = CardFactoryUtil.xCount(affectedCard, AbilityUtils.getSVar(stAb, setP));
|
||||
|
||||
@@ -21,7 +21,7 @@ import javax.swing.*;
|
||||
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")
|
||||
public class IntegerRenderer extends ItemCellRenderer {
|
||||
@@ -36,7 +36,7 @@ public class IntegerRenderer extends ItemCellRenderer {
|
||||
public final Component getTableCellRendererComponent(final JTable table, Object value0,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,15 +428,17 @@ public enum ColumnDef {
|
||||
int result = -1;
|
||||
if (i instanceof PaperCard) {
|
||||
result = ((IPaperCard) i).getRules().getIntPower();
|
||||
if (result == -1) {
|
||||
result = ((IPaperCard) i).getRules().getInitialLoyalty();
|
||||
if (result == Integer.MAX_VALUE) {
|
||||
if (((IPaperCard)i).getRules().getType().isPlaneswalker()) {
|
||||
result = ((IPaperCard) i).getRules().getInitialLoyalty();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user