TriggerChangesZone: use ArrayUtils.contains to check for String in String[]

This commit is contained in:
Hanmac
2016-12-18 21:15:05 +00:00
parent d07a0913ad
commit 875198bed5

View File

@@ -25,10 +25,13 @@ import forge.game.spellability.SpellAbility;
import forge.game.spellability.SpellAbilityStackInstance; import forge.game.spellability.SpellAbilityStackInstance;
import forge.util.Expressions; import forge.util.Expressions;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.ArrayUtils;
import com.google.common.collect.Sets;
/** /**
* <p> * <p>
* Trigger_ChangesZone class. * Trigger_ChangesZone class.
@@ -41,7 +44,7 @@ public class TriggerChangesZone extends Trigger {
// stores the costs when this trigger has already been run (to prevent multiple card draw triggers for single // stores the costs when this trigger has already been run (to prevent multiple card draw triggers for single
// discard event of multiple cards on the Gitrog Moster for instance) // discard event of multiple cards on the Gitrog Moster for instance)
private Set<Integer> processedCostEffects = new HashSet<Integer>(); private Set<Integer> processedCostEffects = Sets.newHashSet();
/** /**
* <p> * <p>
@@ -67,7 +70,9 @@ public class TriggerChangesZone extends Trigger {
if (this.mapParams.get("Origin") == null) { if (this.mapParams.get("Origin") == null) {
return false; return false;
} }
if (!this.mapParams.get("Origin").equals(runParams2.get("Origin"))) { if (!ArrayUtils.contains(
this.mapParams.get("Origin").split(","), runParams2.get("Origin")
)) {
return false; return false;
} }
} }
@@ -75,24 +80,19 @@ public class TriggerChangesZone extends Trigger {
if (this.mapParams.containsKey("Destination")) { if (this.mapParams.containsKey("Destination")) {
if (!this.mapParams.get("Destination").equals("Any")) { if (!this.mapParams.get("Destination").equals("Any")) {
boolean validDest = false; if (!ArrayUtils.contains(
for (final String dest : this.mapParams.get("Destination").split(",")) { this.mapParams.get("Destination").split(","), runParams2.get("Destination")
if (dest.equals(runParams2.get("Destination"))) { )) {
validDest = true;
break;
}
}
if (!validDest) {
return false; return false;
} }
} }
} }
if (this.mapParams.containsKey("ExcludedDestinations")) { if (this.mapParams.containsKey("ExcludedDestinations")) {
for (final String notTo : this.mapParams.get("ExcludedDestinations").split(",")) { if (!ArrayUtils.contains(
if (notTo.equals(runParams2.get("Destination"))) { this.mapParams.get("ExcludedDestinations").split(","), runParams2.get("Destination")
return false; )) {
} return false;
} }
} }