mirror of
https://github.com/Relintai/mtg-forge-ios.git
synced 2025-03-27 15:16:22 +01:00
- Updated the Protection effects to use the timestamp-based changed keywords mechanism, this fixes interactions like Lignify + Reverent Mantra choosing Protection from green.
git-svn-id: http://svn.slightlymagic.net/forge/trunk@35705 269b9781-a132-4a9b-9d4e-f004f1b56b58
This commit is contained in:
parent
38e4cac24d
commit
1645528ea1
@ -1,5 +1,7 @@
|
|||||||
package forge.game.ability.effects;
|
package forge.game.ability.effects;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import forge.GameCommand;
|
import forge.GameCommand;
|
||||||
import forge.card.ColorSet;
|
import forge.card.ColorSet;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
@ -14,12 +16,11 @@ import forge.game.player.Player;
|
|||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
public class ProtectAllEffect extends SpellAbilityEffect {
|
public class ProtectAllEffect extends SpellAbilityEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -73,6 +74,11 @@ public class ProtectAllEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> gainsKWList = Lists.newArrayList();
|
||||||
|
for (String color : gains) {
|
||||||
|
gainsKWList.add(TextUtil.concatWithSpace("Protection from", color));
|
||||||
|
}
|
||||||
|
|
||||||
// Deal with permanents
|
// Deal with permanents
|
||||||
String valid = "";
|
String valid = "";
|
||||||
if (sa.hasParam("ValidCards")) {
|
if (sa.hasParam("ValidCards")) {
|
||||||
@ -84,10 +90,7 @@ public class ProtectAllEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
for (final Card tgtC : list) {
|
for (final Card tgtC : list) {
|
||||||
if (tgtC.isInPlay()) {
|
if (tgtC.isInPlay()) {
|
||||||
for (final String gain : gains) {
|
tgtC.addChangedCardKeywords(gainsKWList, ImmutableList.<String>of(), false, timestamp, true);
|
||||||
tgtC.addExtrinsicKeyword("Protection from " + gain);
|
|
||||||
tgtC.updateKeywords();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sa.hasParam("Permanent")) {
|
if (!sa.hasParam("Permanent")) {
|
||||||
// If not Permanent, remove protection at EOT
|
// If not Permanent, remove protection at EOT
|
||||||
@ -97,9 +100,7 @@ public class ProtectAllEffect extends SpellAbilityEffect {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (tgtC.isInPlay()) {
|
if (tgtC.isInPlay()) {
|
||||||
for (final String gain : gains) {
|
tgtC.removeChangedCardKeywords(timestamp, true);
|
||||||
tgtC.removeExtrinsicKeyword("Protection from " + gain);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package forge.game.ability.effects;
|
package forge.game.ability.effects;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import forge.GameCommand;
|
import forge.GameCommand;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
@ -10,6 +12,7 @@ import forge.game.player.Player;
|
|||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.spellability.TargetRestrictions;
|
import forge.game.spellability.TargetRestrictions;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -121,6 +124,11 @@ public class ProtectEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> gainsKWList = Lists.newArrayList();
|
||||||
|
for (String color : gains) {
|
||||||
|
gainsKWList.add(TextUtil.concatWithSpace("Protection from", color));
|
||||||
|
}
|
||||||
|
|
||||||
final List<Card> untargetedCards = new ArrayList<Card>();
|
final List<Card> untargetedCards = new ArrayList<Card>();
|
||||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||||
|
|
||||||
@ -132,6 +140,8 @@ public class ProtectEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final long timestamp = game.getNextTimestamp();
|
||||||
|
|
||||||
for (final Card tgtC : tgtCards) {
|
for (final Card tgtC : tgtCards) {
|
||||||
// only pump things in play
|
// only pump things in play
|
||||||
if (!tgtC.isInPlay()) {
|
if (!tgtC.isInPlay()) {
|
||||||
@ -143,10 +153,7 @@ public class ProtectEffect extends SpellAbilityEffect {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final String gain : gains) {
|
tgtC.addChangedCardKeywords(gainsKWList, ImmutableList.<String>of(), false, timestamp, true);
|
||||||
tgtC.addExtrinsicKeyword("Protection from " + gain);
|
|
||||||
tgtC.updateKeywords();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sa.hasParam("Permanent")) {
|
if (!sa.hasParam("Permanent")) {
|
||||||
// If not Permanent, remove protection at EOT
|
// If not Permanent, remove protection at EOT
|
||||||
@ -156,9 +163,7 @@ public class ProtectEffect extends SpellAbilityEffect {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (tgtC.isInPlay()) {
|
if (tgtC.isInPlay()) {
|
||||||
for (final String gain : gains) {
|
tgtC.removeChangedCardKeywords(timestamp, true);
|
||||||
tgtC.removeExtrinsicKeyword("Protection from " + gain);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -176,10 +181,7 @@ public class ProtectEffect extends SpellAbilityEffect {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final String gain : gains) {
|
unTgtC.addChangedCardKeywords(gainsKWList, ImmutableList.<String>of(), false, timestamp, true);
|
||||||
unTgtC.addExtrinsicKeyword("Protection from " + gain);
|
|
||||||
unTgtC.updateKeywords();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sa.hasParam("Permanent")) {
|
if (!sa.hasParam("Permanent")) {
|
||||||
// If not Permanent, remove protection at EOT
|
// If not Permanent, remove protection at EOT
|
||||||
@ -189,9 +191,7 @@ public class ProtectEffect extends SpellAbilityEffect {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (unTgtC.isInPlay()) {
|
if (unTgtC.isInPlay()) {
|
||||||
for (final String gain : gains) {
|
unTgtC.removeChangedCardKeywords(timestamp, true);
|
||||||
unTgtC.removeExtrinsicKeyword("Protection from " + gain);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user