mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Cleanup PlayEffect a bit
This commit is contained in:
@@ -17,7 +17,6 @@ import com.google.common.collect.Lists;
|
|||||||
import forge.GameCommand;
|
import forge.GameCommand;
|
||||||
import forge.StaticData;
|
import forge.StaticData;
|
||||||
import forge.card.CardRulesPredicates;
|
import forge.card.CardRulesPredicates;
|
||||||
import forge.card.CardStateName;
|
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
import forge.game.ability.AbilityFactory;
|
import forge.game.ability.AbilityFactory;
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
@@ -169,13 +168,15 @@ public class PlayEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
if (sa.hasParam("ValidSA")) {
|
if (sa.hasParam("ValidSA")) {
|
||||||
final String valid[] = {sa.getParam("ValidSA")};
|
final String valid[] = {sa.getParam("ValidSA")};
|
||||||
List<Card> toRemove = Lists.newArrayList();
|
Iterator<Card> it = tgtCards.iterator();
|
||||||
for (Card c : tgtCards) {
|
while (it.hasNext()) {
|
||||||
|
Card c = it.next();
|
||||||
if (!Iterables.any(AbilityUtils.getBasicSpellsFromPlayEffect(c, controller), SpellAbilityPredicates.isValid(valid, controller , c, sa))) {
|
if (!Iterables.any(AbilityUtils.getBasicSpellsFromPlayEffect(c, controller), SpellAbilityPredicates.isValid(valid, controller , c, sa))) {
|
||||||
toRemove.add(c);
|
// it.remove will only remove item from the list part of CardCollection
|
||||||
|
tgtCards.asSet().remove(c);
|
||||||
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tgtCards.removeAll(toRemove);
|
|
||||||
if (tgtCards.isEmpty()) {
|
if (tgtCards.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -198,21 +199,12 @@ public class PlayEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
while (!tgtCards.isEmpty() && amount > 0 && totalCMCLimit >= 0) {
|
while (!tgtCards.isEmpty() && amount > 0 && totalCMCLimit >= 0) {
|
||||||
if (hasTotalCMCLimit) {
|
if (hasTotalCMCLimit) {
|
||||||
// filter out cars with mana value greater than limit
|
// filter out cards with mana value greater than limit
|
||||||
Iterator<Card> it = tgtCards.iterator();
|
Iterator<Card> it = tgtCards.iterator();
|
||||||
|
final String [] valid = {"Spell.cmcLE"+totalCMCLimit};
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Card c = it.next();
|
Card c = it.next();
|
||||||
if (c.isSplitCard()) {
|
if (!Iterables.any(AbilityUtils.getBasicSpellsFromPlayEffect(c, controller), SpellAbilityPredicates.isValid(valid, controller , c, sa))) {
|
||||||
if (c.getState(CardStateName.LeftSplit).getManaCost().getCMC() <= totalCMCLimit)
|
|
||||||
continue;
|
|
||||||
if (c.getState(CardStateName.RightSplit).getManaCost().getCMC() <= totalCMCLimit)
|
|
||||||
continue;
|
|
||||||
it.remove();
|
|
||||||
} else {
|
|
||||||
if (c.getState(CardStateName.Original).getManaCost().getCMC() <= totalCMCLimit)
|
|
||||||
continue;
|
|
||||||
if (c.hasAlternateState() && c.getAlternateState().getManaCost().getCMC() <= totalCMCLimit)
|
|
||||||
continue;
|
|
||||||
// it.remove will only remove item from the list part of CardCollection
|
// it.remove will only remove item from the list part of CardCollection
|
||||||
tgtCards.asSet().remove(c);
|
tgtCards.asSet().remove(c);
|
||||||
it.remove();
|
it.remove();
|
||||||
|
|||||||
Reference in New Issue
Block a user