mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- CostAdjustment: check subabilities for valid targets (fixes Skulduggery targeting opponent's Kopala).
This commit is contained in:
@@ -1,14 +1,7 @@
|
|||||||
package forge.game.cost;
|
package forge.game.cost;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import forge.card.CardStateName;
|
import forge.card.CardStateName;
|
||||||
import forge.card.mana.ManaAtom;
|
import forge.card.mana.ManaAtom;
|
||||||
import forge.card.mana.ManaCost;
|
import forge.card.mana.ManaCost;
|
||||||
@@ -16,12 +9,7 @@ import forge.card.mana.ManaCostShard;
|
|||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
import forge.game.GameObject;
|
import forge.game.GameObject;
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.*;
|
||||||
import forge.game.card.CardCollection;
|
|
||||||
import forge.game.card.CardCollectionView;
|
|
||||||
import forge.game.card.CardFactoryUtil;
|
|
||||||
import forge.game.card.CardLists;
|
|
||||||
import forge.game.card.CardPredicates;
|
|
||||||
import forge.game.mana.ManaCostBeingPaid;
|
import forge.game.mana.ManaCostBeingPaid;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.AbilityActivated;
|
import forge.game.spellability.AbilityActivated;
|
||||||
@@ -31,6 +19,11 @@ import forge.game.spellability.TargetChoices;
|
|||||||
import forge.game.staticability.StaticAbility;
|
import forge.game.staticability.StaticAbility;
|
||||||
import forge.game.trigger.TriggerType;
|
import forge.game.trigger.TriggerType;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public class CostAdjustment {
|
public class CostAdjustment {
|
||||||
|
|
||||||
@@ -520,12 +513,16 @@ public class CostAdjustment {
|
|||||||
if (!sa.usesTargeting()) {
|
if (!sa.usesTargeting()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
SpellAbility curSa = sa;
|
||||||
boolean targetValid = false;
|
boolean targetValid = false;
|
||||||
for (GameObject target : sa.getTargets().getTargets()) {
|
outer: while (curSa != null) {
|
||||||
if (target.isValid(params.get("ValidTarget").split(","), hostCard.getController(), hostCard, sa)) {
|
for (GameObject target : curSa.getTargets().getTargets()) {
|
||||||
|
if (target.isValid(params.get("ValidTarget").split(","), hostCard.getController(), hostCard, curSa)) {
|
||||||
targetValid = true;
|
targetValid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
curSa = curSa.getSubAbility();
|
||||||
|
}
|
||||||
if (!targetValid) {
|
if (!targetValid) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -534,14 +531,18 @@ public class CostAdjustment {
|
|||||||
if (!sa.usesTargeting()) {
|
if (!sa.usesTargeting()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
SpellAbility curSa = sa;
|
||||||
boolean targetValid = false;
|
boolean targetValid = false;
|
||||||
for (SpellAbility target : sa.getTargets().getTargetSpells()) {
|
outer: while (curSa != null) {
|
||||||
|
for (SpellAbility target : curSa.getTargets().getTargetSpells()) {
|
||||||
Card targetCard = target.getHostCard();
|
Card targetCard = target.getHostCard();
|
||||||
if (targetCard.isValid(params.get("ValidSpellTarget").split(","), hostCard.getController(), hostCard, sa)) {
|
if (targetCard.isValid(params.get("ValidSpellTarget").split(","), hostCard.getController(), hostCard, curSa)) {
|
||||||
targetValid = true;
|
targetValid = true;
|
||||||
break;
|
break outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
curSa = curSa.getSubAbility();
|
||||||
|
}
|
||||||
if (!targetValid) {
|
if (!targetValid) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user