mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
- Improved the way the number of targets is detected for the sake of copying spells that require only one target.
- Fixed one-target Profane Command not working with Precursor Golem, as well as other similar cases. - Remaining issue: Radiate cannot copy one-target Profane Command for some reason (the user doesn't even get to the input prompt).
This commit is contained in:
@@ -9,6 +9,7 @@ import forge.game.card.Card;
|
|||||||
import forge.game.card.CardFactory;
|
import forge.game.card.CardFactory;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
|
import forge.game.spellability.AbilitySub;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
|
|
||||||
@@ -106,6 +107,11 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
|||||||
for (GameEntity o : candidates) {
|
for (GameEntity o : candidates) {
|
||||||
SpellAbility copy = CardFactory.copySpellAbilityAndSrcCard(card, chosenSA.getHostCard(), chosenSA, true);
|
SpellAbility copy = CardFactory.copySpellAbilityAndSrcCard(card, chosenSA.getHostCard(), chosenSA, true);
|
||||||
copy.resetFirstTarget(o, targetedSA);
|
copy.resetFirstTarget(o, targetedSA);
|
||||||
|
AbilitySub subAb = copy.getSubAbility();
|
||||||
|
while (subAb != null) {
|
||||||
|
subAb.resetFirstTarget(o, targetedSA);
|
||||||
|
subAb = subAb.getSubAbility();
|
||||||
|
}
|
||||||
copies.add(copy);
|
copies.add(copy);
|
||||||
}
|
}
|
||||||
} else {// Precursor Golem, Ink-Treader Nephilim
|
} else {// Precursor Golem, Ink-Treader Nephilim
|
||||||
@@ -123,6 +129,11 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
|||||||
for (Card c : valid) {
|
for (Card c : valid) {
|
||||||
SpellAbility copy = CardFactory.copySpellAbilityAndSrcCard(card, chosenSA.getHostCard(), chosenSA, true);
|
SpellAbility copy = CardFactory.copySpellAbilityAndSrcCard(card, chosenSA.getHostCard(), chosenSA, true);
|
||||||
copy.resetFirstTarget(c, targetedSA);
|
copy.resetFirstTarget(c, targetedSA);
|
||||||
|
AbilitySub subAb = copy.getSubAbility();
|
||||||
|
while (subAb != null) {
|
||||||
|
subAb.resetFirstTarget(c, targetedSA);
|
||||||
|
subAb = subAb.getSubAbility();
|
||||||
|
}
|
||||||
copies.add(copy);
|
copies.add(copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1115,15 +1115,15 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tgt.isSingleTarget()) {
|
if (tgt.isSingleTarget()) {
|
||||||
int totalTargets = 0;
|
Set<GameObject> targets = new HashSet<>();
|
||||||
for(TargetChoices tc : topSA.getAllTargetChoices()) {
|
for (TargetChoices tc : topSA.getAllTargetChoices()) {
|
||||||
totalTargets += tc.getNumTargeted();
|
targets.addAll(tc.getTargets());
|
||||||
if (totalTargets > 1) {
|
if (targets.size() > 1) {
|
||||||
// As soon as we get more than one, bail out
|
// As soon as we get more than one, bail out
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (totalTargets != 1) {
|
if (targets.size() != 1) {
|
||||||
// Make sure that there actually is one target
|
// Make sure that there actually is one target
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -385,8 +387,19 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
|
|||||||
if (this.targetsSingleTarget()) {
|
if (this.targetsSingleTarget()) {
|
||||||
final TargetChoices matchTgt = sa.getTargets();
|
final TargetChoices matchTgt = sa.getTargets();
|
||||||
if (matchTgt == null || matchTgt.getFirstTargetedSpell() == null
|
if (matchTgt == null || matchTgt.getFirstTargetedSpell() == null
|
||||||
|| matchTgt.getFirstTargetedSpell().getTargets() == null
|
|| matchTgt.getFirstTargetedSpell().getTargets() == null) {
|
||||||
|| matchTgt.getFirstTargetedSpell().getTargets().getNumTargeted() != 1) {
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<GameObject> targets = new HashSet<>();
|
||||||
|
for (TargetChoices tc : sa.getAllTargetChoices()) {
|
||||||
|
targets.addAll(tc.getTargets());
|
||||||
|
if (targets.size() > 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (targets.size() != 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ package forge.game.trigger;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
|
import forge.game.GameObject;
|
||||||
|
import forge.game.ability.ApiType;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardLists;
|
import forge.game.card.CardLists;
|
||||||
import forge.game.card.CardUtil;
|
import forge.game.card.CardUtil;
|
||||||
@@ -31,6 +33,8 @@ import forge.game.spellability.SpellAbilityStackInstance;
|
|||||||
import forge.game.spellability.TargetChoices;
|
import forge.game.spellability.TargetChoices;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.Expressions;
|
import forge.util.Expressions;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -68,7 +72,7 @@ public class TriggerSpellAbilityCast extends Trigger {
|
|||||||
}
|
}
|
||||||
final Card cast = spellAbility.getHostCard();
|
final Card cast = spellAbility.getHostCard();
|
||||||
final Game game = cast.getGame();
|
final Game game = cast.getGame();
|
||||||
final SpellAbilityStackInstance si = game.getStack().getInstanceFromSpellAbility(spellAbility);
|
SpellAbilityStackInstance si = game.getStack().getInstanceFromSpellAbility(spellAbility);
|
||||||
|
|
||||||
if (this.getMode() == TriggerType.SpellCast) {
|
if (this.getMode() == TriggerType.SpellCast) {
|
||||||
if (!spellAbility.isSpell()) {
|
if (!spellAbility.isSpell()) {
|
||||||
@@ -174,11 +178,14 @@ public class TriggerSpellAbilityCast extends Trigger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.mapParams.containsKey("IsSingleTarget")) {
|
if (this.mapParams.containsKey("IsSingleTarget")) {
|
||||||
int numTargeted = 0;
|
Set<GameObject> targets = new HashSet<>();
|
||||||
for (TargetChoices tc : spellAbility.getAllTargetChoices()) {
|
for (TargetChoices tc : spellAbility.getAllTargetChoices()) {
|
||||||
numTargeted += tc.getNumTargeted();
|
targets.addAll(tc.getTargets());
|
||||||
|
if (targets.size() > 1) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (numTargeted != 1) {
|
}
|
||||||
|
if (targets.size() != 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user