Co-authored-by: TRT <>
This commit is contained in:
tool4ever
2024-04-12 17:48:10 +02:00
committed by GitHub
parent 9975d68f04
commit 839d040c8b
7 changed files with 12 additions and 23 deletions

View File

@@ -59,7 +59,7 @@ public class AttachAi extends SpellAbilityAi {
// TODO: improve this so that the AI can use a flash aura buff as a means of killing opposing creatures
// and gaining card advantage
if (source.hasKeyword("MayFlashSac") && !ai.couldCastSorcery(sa)) {
if (source.hasKeyword("MayFlashSac") && !ai.canCastSorcery()) {
return false;
}

View File

@@ -29,7 +29,7 @@ public class PermanentAi extends SpellAbilityAi {
protected boolean checkPhaseRestrictions(final Player ai, final SpellAbility sa, final PhaseHandler ph) {
final Card card = sa.getHostCard();
if (card.hasKeyword("MayFlashSac") && !ai.couldCastSorcery(sa)) {
if (card.hasKeyword("MayFlashSac") && !ai.canCastSorcery()) {
// AiPlayDecision.AnotherTime
return false;
}

View File

@@ -340,7 +340,7 @@ public class ForgeScript {
String unescaped = k[1].replace("~", "+");
boolean found = false;
for (GameObject o : AbilityUtils.getDefinedObjects(source, unescaped, spellAbility)) {
if (sa.isTargeting(o)) {
if (sa.getRootAbility().isTargeting(o)) {
found = true;
break;
}

View File

@@ -111,7 +111,7 @@ public final class GameActionUtil {
for (CardPlayOption o : source.mayPlay(activator)) {
// do not appear if it can be cast with SorcerySpeed
if (o.getAbility().hasParam("MayPlayNotSorcerySpeed") && activator.couldCastSorcery(sa)) {
if (o.getAbility().hasParam("MayPlayNotSorcerySpeed") && activator.canCastSorcery()) {
continue;
}
// non basic are only allowed if PayManaCost is yes

View File

@@ -305,7 +305,7 @@ public class CardProperty {
return false;
}
SpellAbility sp = (SpellAbility)spellAbility;
if (!sp.isTargeting(card)) {
if (!sp.getRootAbility().isTargeting(card)) {
return false;
}
} else if (property.equals("TargetedPlayerCtrl")) {
@@ -607,9 +607,12 @@ public class CardProperty {
}
} else if (property.startsWith("CanBeTargetedBy")) {
final String def = property.substring(15);
final SpellAbility targetingSA = AbilityUtils.getDefinedSpellAbilities(source, def, spellAbility).get(0);
if (!targetingSA.canTarget(card)) {
return false;
SpellAbility targetingSA = AbilityUtils.getDefinedSpellAbilities(source, def, spellAbility).get(0);
while (targetingSA != null) {
if (targetingSA.usesTargeting() && !targetingSA.canTarget(card)) {
return false;
}
targetingSA = targetingSA.getSubAbility();
}
} else if (property.startsWith("HauntedBy")) {
if (!card.isHauntedBy(source)) {

View File

@@ -2519,20 +2519,6 @@ public class Player extends GameEntity implements Comparable<Player> {
return now.isPlayerTurn(this) && now.getPhase().isMain() && game.getStack().isEmpty();
}
//NOTE: for conditions the stack must only have the sa being checked
public boolean couldCastSorcery(final SpellAbility sa) {
final Card source = sa.getRootAbility().getHostCard();
for (final Card card : game.getCardsIn(ZoneType.Stack)) {
if (!card.equals(source)) {
return false;
}
}
PhaseHandler now = game.getPhaseHandler();
return now.isPlayerTurn(this) && now.getPhase().isMain();
}
public final PlayerController getController() {
if (!controlledBy.isEmpty()) {
return controlledBy.lastEntry().getValue().getValue();

View File

@@ -2068,7 +2068,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
if (getTargets().contains(o)) {
return true;
}
SpellAbility p = getParent();
SpellAbility p = getSubAbility();
return p != null && p.isTargeting(o);
}