mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Fix AnimateAll / AI check creating unwanted ending commands (#3296)
* Fix AnimateAll / AI check creating unwanted ending commands * Fix crash with PW * Clean up --------- Co-authored-by: tool4EvEr <tool4EvEr@192.168.0.59>
This commit is contained in:
@@ -7,7 +7,6 @@ import java.util.Map;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import forge.GameCommand;
|
||||
import forge.card.CardType;
|
||||
import forge.card.ColorSet;
|
||||
import forge.game.Game;
|
||||
@@ -44,8 +43,6 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
// Every Animate event needs a unique time stamp
|
||||
final long timestamp = game.getNextTimestamp();
|
||||
|
||||
final boolean permanent = "Permanent".equals(sa.getParam("Duration"));
|
||||
|
||||
final CardType types = new CardType(true);
|
||||
if (sa.hasParam("Types")) {
|
||||
types.addAll(Arrays.asList(sa.getParam("Types").split(",")));
|
||||
@@ -146,7 +143,7 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
|
||||
for (final Card c : list) {
|
||||
doAnimate(c, sa, power, toughness, types, removeTypes, finalColors, keywords, removeKeywords,
|
||||
hiddenKeywords, abilities, triggers, replacements, stAbs, timestamp);
|
||||
hiddenKeywords, abilities, triggers, replacements, stAbs, timestamp, sa.getParam("Duration"));
|
||||
|
||||
// give sVars
|
||||
if (!sVarsMap.isEmpty() ) {
|
||||
@@ -154,21 +151,6 @@ public class AnimateAllEffect extends AnimateEffectBase {
|
||||
}
|
||||
|
||||
game.fireEvent(new GameEventCardStatsChanged(c));
|
||||
|
||||
if (!permanent) {
|
||||
final GameCommand unanimate = new GameCommand() {
|
||||
private static final long serialVersionUID = -5861759814760561373L;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
doUnanimate(c, timestamp);
|
||||
|
||||
game.fireEvent(new GameEventCardStatsChanged(c));
|
||||
}
|
||||
};
|
||||
|
||||
addUntilCommand(sa, unanimate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,16 +26,17 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
@Override
|
||||
public void resolve(final SpellAbility sa) {
|
||||
final Card source = sa.getHostCard();
|
||||
String duration = sa.getParam("Duration");
|
||||
|
||||
String animateRemembered = null;
|
||||
String animateImprinted = null;
|
||||
|
||||
//if host is not on the battlefield don't apply
|
||||
if (("UntilHostLeavesPlay".equals(sa.getParam("Duration")) || "UntilLoseControlOfHost".equals(sa.getParam("Duration")))
|
||||
if (("UntilHostLeavesPlay".equals(duration) || "UntilLoseControlOfHost".equals(duration))
|
||||
&& !source.isInPlay()) {
|
||||
return;
|
||||
}
|
||||
if ("UntilLoseControlOfHost".equals(sa.getParam("Duration")) && source.getController() != sa.getActivatingPlayer()) {
|
||||
if ("UntilLoseControlOfHost".equals(duration) && source.getController() != sa.getActivatingPlayer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -175,7 +176,7 @@ public class AnimateEffect extends AnimateEffectBase {
|
||||
|
||||
doAnimate(c, sa, power, toughness, types, removeTypes, finalColors,
|
||||
keywords, removeKeywords, hiddenKeywords,
|
||||
abilities, triggers, replacements, stAbs, timestamp);
|
||||
abilities, triggers, replacements, stAbs, timestamp, duration);
|
||||
|
||||
if (sa.hasParam("Name")) {
|
||||
c.addChangedName(sa.getParam("Name"), false, timestamp, 0);
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class AnimateEffectBase extends SpellAbilityEffect {
|
||||
final CardType addType, final CardType removeType, final ColorSet colors,
|
||||
final List<String> keywords, final List<String> removeKeywords, final List<String> hiddenKeywords,
|
||||
List<String> abilities, final List<String> triggers, final List<String> replacements, final List<String> stAbs,
|
||||
final long timestamp) {
|
||||
final long timestamp, final String duration) {
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = source.getGame();
|
||||
|
||||
@@ -185,8 +185,8 @@ public abstract class AnimateEffectBase extends SpellAbilityEffect {
|
||||
addedStaticAbilities, removeAll, removeNonManaAbilities, timestamp, 0);
|
||||
}
|
||||
|
||||
if (!"Permanent".equals(sa.getParam("Duration"))) {
|
||||
if ("UntilControllerNextUntap".equals(sa.getParam("Duration"))) {
|
||||
if (!"Permanent".equals(duration)) {
|
||||
if ("UntilControllerNextUntap".equals(duration)) {
|
||||
game.getUntap().addUntil(c.getController(), unanimate);
|
||||
} else {
|
||||
addUntilCommand(sa, unanimate);
|
||||
|
||||
@@ -247,6 +247,9 @@ public class CardDamageHistory {
|
||||
* @param player
|
||||
*/
|
||||
public void registerDamage(int damage, boolean isCombat, Card sourceLKI, GameEntity target, Map<Integer, Card> lkiCache) {
|
||||
if (damage <= 0) {
|
||||
return;
|
||||
}
|
||||
damagedThisGame.add(target);
|
||||
hasdealtDamagetoAny = true;
|
||||
if (isCombat && target instanceof Player) {
|
||||
|
||||
@@ -113,6 +113,9 @@ public class CardDamageMap extends ForwardingTable<Card, GameEntity, Integer> {
|
||||
for (Integer i : this.column(damaged.getKey()).values()) {
|
||||
sum += i;
|
||||
}
|
||||
if (sum == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int excess = sum - (damaged.getKey().hasBeenDealtDeathtouchDamage() ? 1 : damaged.getValue());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user