Make charm choices for triggers more like other SA

This commit is contained in:
tool4EvEr
2022-05-24 22:36:57 +02:00
parent 9c9cbf5bd3
commit 6f42fcdc26
5 changed files with 17 additions and 36 deletions

View File

@@ -131,10 +131,9 @@ public class ComputerUtil {
sa = GameActionUtil.addExtraKeywordCost(sa);
if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) {
if (!CharmEffect.makeChoices(sa)) {
return false;
}
if (sa.getApi() == ApiType.Charm && !sa.isCopied() && !CharmEffect.makeChoices(sa)) {
// 603.3c If no mode is chosen, the ability is removed from the stack.
return false;
}
if (chooseTargets != null) {
chooseTargets.run();
@@ -295,10 +294,9 @@ public class ComputerUtil {
if (newSA.isSpell() && !source.isCopiedSpell()) {
newSA.setHostCard(game.getAction().moveToStack(source, newSA));
if (newSA.getApi() == ApiType.Charm && !newSA.isWrapper()) {
if (!CharmEffect.makeChoices(newSA)) {
return false;
}
if (newSA.getApi() == ApiType.Charm && !sa.isCopied() && !CharmEffect.makeChoices(newSA)) {
// 603.3c If no mode is chosen, the ability is removed from the stack.
return false;
}
}

View File

@@ -34,6 +34,7 @@ import forge.game.GameObject;
import forge.game.GameType;
import forge.game.ability.AbilityUtils;
import forge.game.ability.ApiType;
import forge.game.ability.effects.CharmEffect;
import forge.game.card.Card;
import forge.game.card.CardCollection;
import forge.game.card.CardCollectionView;
@@ -1064,6 +1065,10 @@ public class PlayerControllerAi extends PlayerController {
}
private boolean prepareSingleSa(final Card host, final SpellAbility sa, boolean isMandatory) {
if (sa.getApi() == ApiType.Charm && !sa.isCopied() && !CharmEffect.makeChoices(sa)) {
// 603.3c If no mode is chosen, the ability is removed from the stack.
return false;
}
if (sa.hasParam("TargetingPlayer")) {
Player targetingPlayer = AbilityUtils.getDefinedPlayers(host, sa.getParam("TargetingPlayer"), sa).get(0);
sa.setTargetingPlayer(targetingPlayer);

View File

@@ -255,15 +255,6 @@ public class CharmAi extends SpellAbilityAi {
return Aggregates.random(opponents);
}
@Override
protected boolean doTriggerAINoCost(final Player aiPlayer, final SpellAbility sa, final boolean mandatory) {
// already done by chooseOrderOfSimultaneousStackEntry
if (sa.getChosenList() != null) {
return true;
}
return super.doTriggerAINoCost(aiPlayer, sa, mandatory);
}
@Override
public boolean chkDrawbackWithSubs(Player aiPlayer, AbilitySub ab) {
// choices were already targeted

View File

@@ -41,7 +41,6 @@ import forge.game.GameObject;
import forge.game.ability.AbilityKey;
import forge.game.ability.AbilityUtils;
import forge.game.ability.ApiType;
import forge.game.ability.effects.CharmEffect;
import forge.game.card.Card;
import forge.game.card.CardCollection;
import forge.game.card.CardUtil;
@@ -826,19 +825,10 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
}
final List<SpellAbility> activePlayerSAs = Lists.newArrayList();
final List<SpellAbility> failedSAs = Lists.newArrayList();
for (int i = 0; i < simultaneousStackEntryList.size(); i++) {
SpellAbility sa = simultaneousStackEntryList.get(i);
Player activator = sa.getActivatingPlayer();
if (sa.getApi() == ApiType.Charm) {
if (!CharmEffect.makeChoices(sa)) {
// 603.3c If no mode is chosen, the ability is removed from the stack.
failedSAs.add(sa);
continue;
}
}
if (activator == null) {
if (sa.getHostCard().getController().equals(activePlayer)) {
activePlayerSAs.add(sa);
@@ -850,7 +840,6 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
}
}
simultaneousStackEntryList.removeAll(activePlayerSAs);
simultaneousStackEntryList.removeAll(failedSAs);
if (activePlayerSAs.isEmpty()) {
return false;

View File

@@ -105,10 +105,9 @@ public class HumanPlay {
source.forceTurnFaceUp();
}
if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) {
if (!CharmEffect.makeChoices(sa)) {
return false;
}
if (sa.getApi() == ApiType.Charm && !sa.isCopied() && !CharmEffect.makeChoices(sa)) {
// 603.3c If no mode is chosen, the ability is removed from the stack.
return false;
}
sa = AbilityUtils.addSpliceEffects(sa);
@@ -169,10 +168,9 @@ public class HumanPlay {
source.setSplitStateToPlayAbility(sa);
if (!sa.isCopied()) {
if (sa.getApi() == ApiType.Charm && !sa.isWrapper()) {
if (!CharmEffect.makeChoices(sa)) {
return;
}
if (sa.getApi() == ApiType.Charm && !CharmEffect.makeChoices(sa)) {
// 603.3c If no mode is chosen, the ability is removed from the stack.
return;
}
sa = AbilityUtils.addSpliceEffects(sa);
}