mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
SpellAbilityCondition: extends ConditionDefined to work with SpellAbilities
This commit is contained in:
@@ -133,6 +133,10 @@ public class CardFactory {
|
||||
final Card original = targetSA.getHostCard();
|
||||
final Card c = copyCard(original, true);
|
||||
|
||||
// clear remember/imprint for copied spells
|
||||
c.clearRemembered();
|
||||
c.clearImprintedCards();
|
||||
|
||||
if (sourceSA.hasParam("NonLegendary")) {
|
||||
c.removeType(CardType.Supertype.Legendary);
|
||||
}
|
||||
|
||||
@@ -2481,16 +2481,14 @@ public class CardFactoryUtil {
|
||||
} else if (keyword.equals("Demonstrate")) {
|
||||
final String trigScript = "Mode$ SpellCast | ValidCard$ Card.Self | TriggerDescription$ Demonstrate (" + inst.getReminderText() + ")";
|
||||
final String youCopyStr = "DB$ CopySpellAbility | Defined$ TriggeredSpellAbility | MayChooseTarget$ True | Optional$ True | RememberCopies$ True";
|
||||
final String chooseOppStr = "DB$ ChoosePlayer | Defined$ You | Choices$ Player.Opponent | ConditionCheckSVar$ DemonstrateSVar | ConditionSVarCompare$ GE1";
|
||||
final String oppCopyStr = "DB$ CopySpellAbility | Controller$ ChosenPlayer | Defined$ TriggeredSpellAbility | MayChooseTarget$ True | ConditionCheckSVar$ DemonstrateSVar | ConditionSVarCompare$ GE1";
|
||||
final String cleanupStr = "DB$ Cleanup | ClearRemembered$ True";
|
||||
final String chooseOppStr = "DB$ ChoosePlayer | Defined$ You | Choices$ Player.Opponent | ConditionDefined$ Remembered | ConditionPresent$ Spell";
|
||||
final String oppCopyStr = "DB$ CopySpellAbility | Controller$ ChosenPlayer | Defined$ TriggeredSpellAbility | MayChooseTarget$ True | ConditionDefined$ Remembered | ConditionPresent$ Spell";
|
||||
final String cleanupStr = "DB$ Cleanup | ClearRemembered$ True | ClearChosenPlayer$ True";
|
||||
|
||||
final Trigger trigger = TriggerHandler.parseTrigger(trigScript, card, intrinsic);
|
||||
final SpellAbility youCopy = AbilityFactory.getAbility(youCopyStr, card);
|
||||
final AbilitySub chooseOpp = (AbilitySub) AbilityFactory.getAbility(chooseOppStr, card);
|
||||
chooseOpp.setSVar("DemonstrateSVar", "Count$RememberedSize");
|
||||
final AbilitySub oppCopy = (AbilitySub) AbilityFactory.getAbility(oppCopyStr, card);
|
||||
oppCopy.setSVar("DemonstrateSVar", "Count$RememberedSize");
|
||||
final AbilitySub cleanup = (AbilitySub) AbilityFactory.getAbility(cleanupStr, card);
|
||||
oppCopy.setSubAbility(cleanup);
|
||||
chooseOpp.setSubAbility(oppCopy);
|
||||
|
||||
@@ -30,17 +30,17 @@ import com.google.common.collect.Iterables;
|
||||
import forge.card.ColorSet;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.GameObjectPredicates;
|
||||
import forge.game.GameType;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardCollectionView;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Expressions;
|
||||
import forge.util.collect.FCollection;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -354,21 +354,19 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getIsPresent() != null) {
|
||||
CardCollectionView list;
|
||||
if (this.getPresentDefined() != null) {
|
||||
list = AbilityUtils.getDefinedCards(host, this.getPresentDefined(), sa);
|
||||
if (getIsPresent() != null) {
|
||||
FCollection<GameObject> list;
|
||||
if (getPresentDefined() != null) {
|
||||
list = AbilityUtils.getDefinedObjects(host, getPresentDefined(), sa);
|
||||
} else {
|
||||
list = game.getCardsIn(ZoneType.Battlefield);
|
||||
list = new FCollection<GameObject>(game.getCardsIn(getPresentZone()));
|
||||
}
|
||||
|
||||
list = CardLists.getValidCards(list, this.getIsPresent().split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa);
|
||||
final int left = Iterables.size(Iterables.filter(list, GameObjectPredicates.restriction(getIsPresent().split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa)));
|
||||
|
||||
final String rightString = this.getPresentCompare().substring(2);
|
||||
int right = AbilityUtils.calculateAmount(host, rightString, sa);
|
||||
|
||||
final int left = list.size();
|
||||
|
||||
if (!Expressions.compare(left, this.getPresentCompare(), right)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -20,14 +20,16 @@ package forge.game.spellability;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.GameObjectPredicates;
|
||||
import forge.game.GameType;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.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.CardPlayOption;
|
||||
@@ -39,6 +41,7 @@ import forge.game.staticability.StaticAbilityCastWithFlash;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Expressions;
|
||||
import forge.util.collect.FCollection;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -426,19 +429,17 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
|
||||
}
|
||||
}
|
||||
if (this.getIsPresent() != null) {
|
||||
CardCollectionView list;
|
||||
if (this.getPresentDefined() != null) {
|
||||
list = AbilityUtils.getDefinedCards(sa.getHostCard(), this.getPresentDefined(), sa);
|
||||
FCollection<GameObject> list;
|
||||
if (getPresentDefined() != null) {
|
||||
list = AbilityUtils.getDefinedObjects(sa.getHostCard(), getPresentDefined(), sa);
|
||||
} else {
|
||||
list = game.getCardsIn(this.getPresentZone());
|
||||
list = new FCollection<GameObject>(game.getCardsIn(getPresentZone()));
|
||||
}
|
||||
|
||||
list = CardLists.getValidCards(list, this.getIsPresent().split(","), activator, c, sa);
|
||||
final int left = Iterables.size(Iterables.filter(list, GameObjectPredicates.restriction(getIsPresent().split(","), activator, c, sa)));
|
||||
|
||||
int right = 1;
|
||||
final String rightString = this.getPresentCompare().substring(2);
|
||||
right = AbilityUtils.calculateAmount(c, rightString, sa);
|
||||
final int left = list.size();
|
||||
int right = AbilityUtils.calculateAmount(c, rightString, sa);
|
||||
|
||||
if (!Expressions.compare(left, this.getPresentCompare(), right)) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user