mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +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;
|
||||
|
||||
@@ -2,7 +2,7 @@ Name:Excavation Technique
|
||||
ManaCost:3 W
|
||||
Types:Sorcery
|
||||
K:Demonstrate
|
||||
A:SP$ Destroy | Cost$ 3 W | ValidTgts$ Permanent.nonLand | TgtPrompt$ Select target nonland permanent | SubAbility$ DBToken | SpellDescription$ Destroy target nonland permanent. Its controller creates two Treasure tokens.
|
||||
SVar:DBToken:DB$ Token | TokenAmount$ 2 | TokenScript$ c_a_treasure_sac | TokenOwner$ TargetedController
|
||||
A:SP$ Destroy | Cost$ 3 W | ValidTgts$ Permanent.nonLand | TgtPrompt$ Select target nonland permanent | SubAbility$ DBToken | SpellDescription$ Destroy target nonland permanent.
|
||||
SVar:DBToken:DB$ Token | TokenAmount$ 2 | TokenScript$ c_a_treasure_sac | TokenOwner$ TargetedController | StackDescription$ SpellDescription | SpellDescription$ Its controller creates two Treasure tokens.
|
||||
DeckHas:Ability$Token
|
||||
Oracle:Demonstrate (When you cast this spell, you may copy it. If you do, choose an opponent to also copy it. Players may choose new targets for their copies.)\nDestroy target nonland permanent. Its controller creates two Treasure tokens.
|
||||
|
||||
Reference in New Issue
Block a user