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.util.Expressions;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.ArrayUtils;
import com.google.common.collect.Sets;
/**
* <p>
* 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
// 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>
@@ -67,7 +70,9 @@ public class TriggerChangesZone extends Trigger {
if (this.mapParams.get("Origin") == null) {
return false;
}
if (!this.mapParams.get("Origin").equals(runParams2.get("Origin"))) {
if (!ArrayUtils.contains(
this.mapParams.get("Origin").split(","), runParams2.get("Origin")
)) {
return false;
}
}
@@ -75,26 +80,21 @@ public class TriggerChangesZone extends Trigger {
if (this.mapParams.containsKey("Destination")) {
if (!this.mapParams.get("Destination").equals("Any")) {
boolean validDest = false;
for (final String dest : this.mapParams.get("Destination").split(",")) {
if (dest.equals(runParams2.get("Destination"))) {
validDest = true;
break;
}
}
if (!validDest) {
if (!ArrayUtils.contains(
this.mapParams.get("Destination").split(","), runParams2.get("Destination")
)) {
return false;
}
}
}
if (this.mapParams.containsKey("ExcludedDestinations")) {
for (final String notTo : this.mapParams.get("ExcludedDestinations").split(",")) {
if (notTo.equals(runParams2.get("Destination"))) {
if (!ArrayUtils.contains(
this.mapParams.get("ExcludedDestinations").split(","), runParams2.get("Destination")
)) {
return false;
}
}
}
if (this.mapParams.containsKey("ValidCard")) {
final Card moved = (Card) runParams2.get("Card");