mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- Fix issue with animation setting -1 to unset PT.
This commit is contained in:
@@ -38,11 +38,11 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
|||||||
final Map<String, String> svars = host.getSVars();
|
final Map<String, String> svars = host.getSVars();
|
||||||
|
|
||||||
// AF specific sa
|
// AF specific sa
|
||||||
int power = -1;
|
Integer power = null;
|
||||||
if (sa.hasParam("Power")) {
|
if (sa.hasParam("Power")) {
|
||||||
power = AbilityUtils.calculateAmount(host, sa.getParam("Power"), sa);
|
power = AbilityUtils.calculateAmount(host, sa.getParam("Power"), sa);
|
||||||
}
|
}
|
||||||
int toughness = -1;
|
Integer toughness = null;
|
||||||
if (sa.hasParam("Toughness")) {
|
if (sa.hasParam("Toughness")) {
|
||||||
toughness = AbilityUtils.calculateAmount(host, sa.getParam("Toughness"), sa);
|
toughness = AbilityUtils.calculateAmount(host, sa.getParam("Toughness"), sa);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,11 +49,11 @@ public class AnimateEffect extends AnimateEffectBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AF specific sa
|
// AF specific sa
|
||||||
int power = -1;
|
Integer power = null;
|
||||||
if (sa.hasParam("Power")) {
|
if (sa.hasParam("Power")) {
|
||||||
power = AbilityUtils.calculateAmount(source, sa.getParam("Power"), sa);
|
power = AbilityUtils.calculateAmount(source, sa.getParam("Power"), sa);
|
||||||
}
|
}
|
||||||
int toughness = -1;
|
Integer toughness = null;
|
||||||
if (sa.hasParam("Toughness")) {
|
if (sa.hasParam("Toughness")) {
|
||||||
toughness = AbilityUtils.calculateAmount(source, sa.getParam("Toughness"), sa);
|
toughness = AbilityUtils.calculateAmount(source, sa.getParam("Toughness"), sa);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class AnimateEffectBase extends SpellAbilityEffect {
|
public abstract class AnimateEffectBase extends SpellAbilityEffect {
|
||||||
void doAnimate(final Card c, final SpellAbility sa, final int power, final int toughness,
|
void doAnimate(final Card c, final SpellAbility sa, final Integer power, final Integer toughness,
|
||||||
final CardType addType, final CardType removeType, final String colors,
|
final CardType addType, final CardType removeType, final String colors,
|
||||||
final List<String> keywords, final List<String> removeKeywords,
|
final List<String> keywords, final List<String> removeKeywords,
|
||||||
final List<String> hiddenKeywords, final long timestamp) {
|
final List<String> hiddenKeywords, final long timestamp) {
|
||||||
@@ -76,7 +76,7 @@ public abstract class AnimateEffectBase extends SpellAbilityEffect {
|
|||||||
removeCreatureTypes = true;
|
removeCreatureTypes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((power != -1) || (toughness != -1)) {
|
if ((power != null) || (toughness != null)) {
|
||||||
c.addNewPT(power, toughness, timestamp);
|
c.addNewPT(power, toughness, timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2708,29 +2708,35 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
*/
|
*/
|
||||||
private synchronized Pair<Integer, Integer> getLatestPT() {
|
private synchronized Pair<Integer, Integer> getLatestPT() {
|
||||||
// Find latest set power
|
// Find latest set power
|
||||||
long maxPowerTimestamp = -2;
|
newPT.sort(new Comparator<CardPowerToughness>() {
|
||||||
int latestPower = Integer.MAX_VALUE;
|
@Override
|
||||||
for (final CardPowerToughness pt : newPT) {
|
public int compare(CardPowerToughness o1, CardPowerToughness o2) {
|
||||||
if (pt.getTimestamp() >= maxPowerTimestamp && pt.getPower() != Integer.MAX_VALUE) {
|
return o1.getTimestamp() < o2.getTimestamp() ? -1 : o1.getTimestamp() == o2.getTimestamp() ? 0 : 1;
|
||||||
maxPowerTimestamp = pt.getTimestamp();
|
|
||||||
latestPower = pt.getPower();
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Integer power = null,
|
||||||
|
toughness = null;
|
||||||
|
|
||||||
|
int size = newPT.size();
|
||||||
|
for(int i = size - 1; i >= 0; i--) {
|
||||||
|
CardPowerToughness pt = newPT.get(i);
|
||||||
|
if (power == null && pt.getPower() != null)
|
||||||
|
power = pt.getPower();
|
||||||
|
if (toughness == null && pt.getToughness() != null)
|
||||||
|
toughness = pt.getToughness();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find latest set toughness
|
if (power == null)
|
||||||
long maxToughnessTimestamp = -2;
|
power = Integer.MAX_VALUE;
|
||||||
int latestToughness = Integer.MAX_VALUE;
|
|
||||||
for (final CardPowerToughness pt : newPT) {
|
|
||||||
if (pt.getTimestamp() >= maxToughnessTimestamp && pt.getToughness() != Integer.MAX_VALUE) {
|
|
||||||
maxToughnessTimestamp = pt.getTimestamp();
|
|
||||||
latestToughness = pt.getToughness();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Pair.of(latestPower, latestToughness);
|
if (toughness == null)
|
||||||
|
toughness = Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
return Pair.of(power, toughness);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addNewPT(final int power, final int toughness, final long timestamp) {
|
public final void addNewPT(final Integer power, final Integer toughness, final long timestamp) {
|
||||||
newPT.add(new CardPowerToughness(power, toughness, timestamp));
|
newPT.add(new CardPowerToughness(power, toughness, timestamp));
|
||||||
currentState.getView().updatePower(this);
|
currentState.getView().updatePower(this);
|
||||||
currentState.getView().updateToughness(this);
|
currentState.getView().updateToughness(this);
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ package forge.game.card;
|
|||||||
*/
|
*/
|
||||||
public class CardPowerToughness {
|
public class CardPowerToughness {
|
||||||
|
|
||||||
private final int power;
|
private final Integer power;
|
||||||
private final int toughness;
|
private final Integer toughness;
|
||||||
private long timeStamp = 0;
|
private long timeStamp = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,7 +54,7 @@ public class CardPowerToughness {
|
|||||||
* @param stamp
|
* @param stamp
|
||||||
* a long.
|
* a long.
|
||||||
*/
|
*/
|
||||||
CardPowerToughness(final int newPower, final int newToughness, final long stamp) {
|
CardPowerToughness(final Integer newPower, final Integer newToughness, final long stamp) {
|
||||||
this.power = newPower;
|
this.power = newPower;
|
||||||
this.toughness = newToughness;
|
this.toughness = newToughness;
|
||||||
this.timeStamp = stamp;
|
this.timeStamp = stamp;
|
||||||
@@ -66,7 +66,7 @@ public class CardPowerToughness {
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public final int getPower() {
|
public final Integer getPower() {
|
||||||
return this.power;
|
return this.power;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ public class CardPowerToughness {
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public final int getToughness() {
|
public final Integer getToughness() {
|
||||||
return this.toughness;
|
return this.toughness;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ public class CardPowerToughness {
|
|||||||
* a long.
|
* a long.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean equals(final int newPower, final int newToughness, final long stamp) {
|
public final boolean equals(final Integer newPower, final Integer newToughness, final long stamp) {
|
||||||
return (this.timeStamp == stamp) && (this.power == newPower) && (this.toughness == newToughness);
|
return (this.timeStamp == stamp) && (this.power == newPower) && (this.toughness == newToughness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user