mirror of
https://github.com/magefree/mage.git
synced 2025-12-30 07:22:03 -08:00
Changed ability handling of modal spells to be able to select the same mode multiple times with different targets.
This commit is contained in:
parent
b18cae5100
commit
4711e0cf99
40 changed files with 488 additions and 421 deletions
|
|
@ -30,6 +30,7 @@ package mage.sets.battleforzendikar;
|
|||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
|
@ -102,9 +103,8 @@ class ZadaHedronGrinderTriggeredAbility extends TriggeredAbilityImpl {
|
|||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (isControlledInstantOrSorcery(spell)) {
|
||||
boolean targetsSource = false;
|
||||
for (UUID modeId : spell.getSpellAbility().getModes().getSelectedModes()) {
|
||||
spell.getSpellAbility().getModes().setActiveMode(modeId);
|
||||
for (Target target : spell.getSpellAbility().getTargets()) {
|
||||
for (Mode mode : spell.getSpellAbility().getModes().getSelectedModes()) {
|
||||
for (Target target : mode.getTargets()) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
if (targetId.equals(getSourceId())) {
|
||||
targetsSource = true;
|
||||
|
|
@ -161,9 +161,8 @@ class ZadaHedronGrinderEffect extends OneShotEffect {
|
|||
if (spell != null && controller != null) {
|
||||
Target usedTarget = null;
|
||||
setUsedTarget:
|
||||
for (UUID modeId : spell.getSpellAbility().getModes().getSelectedModes()) {
|
||||
spell.getSpellAbility().getModes().setActiveMode(modeId);
|
||||
for (Target target : spell.getSpellAbility().getTargets()) {
|
||||
for (Mode mode : spell.getSpellAbility().getModes().getSelectedModes()) {
|
||||
for (Target target : mode.getTargets()) {
|
||||
if (target.getFirstTarget().equals(source.getSourceId())) {
|
||||
usedTarget = target.copy();
|
||||
usedTarget.clearChosen();
|
||||
|
|
@ -178,9 +177,8 @@ class ZadaHedronGrinderEffect extends OneShotEffect {
|
|||
if (!creature.getId().equals(source.getSourceId()) && usedTarget.canTarget(source.getControllerId(), creature.getId(), source, game)) {
|
||||
Spell copy = spell.copySpell();
|
||||
setTarget:
|
||||
for (UUID modeId : spell.getSpellAbility().getModes().getSelectedModes()) {
|
||||
copy.getSpellAbility().getModes().setActiveMode(modeId);
|
||||
for (Target target : copy.getSpellAbility().getTargets()) {
|
||||
for (Mode mode : spell.getSpellAbility().getModes().getSelectedModes()) {
|
||||
for (Target target : mode.getTargets()) {
|
||||
if (target.getClass().equals(usedTarget.getClass()) && target.getMessage().equals(usedTarget.getMessage())) {
|
||||
target.clearChosen();
|
||||
target.add(creature.getId(), game);
|
||||
|
|
|
|||
|
|
@ -74,9 +74,9 @@ public class MogisGodOfSlaughter extends CardImpl {
|
|||
// As long as your devotion to black and red is less than seven, Mogis isn't a creature.
|
||||
Effect effect = new LoseCreatureTypeSourceEffect(new DevotionCount(ColoredManaSymbol.B, ColoredManaSymbol.R), 7);
|
||||
effect.setText("As long as your devotion to black and red is less than seven, Mogis isn't a creature");
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
||||
|
||||
// At the beginning of each opponent's upkeep, Mogis deals 2 damage to that player unless he or she sacrifices a creature.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
||||
|
||||
// At the beginning of each opponent's upkeep, Mogis deals 2 damage to that player unless he or she sacrifices a creature.
|
||||
effect = new DoUnlessTargetPaysCost(new DamageTargetEffect(2, false, "that player"), new SacrificeTargetCost(new TargetControlledCreaturePermanent()),
|
||||
"Sacrifice a creature? (otherwise you get 2 damage)");
|
||||
effect.setText("Mogis deals 2 damage to that player unless he or she sacrifices a creature");
|
||||
|
|
@ -95,6 +95,7 @@ public class MogisGodOfSlaughter extends CardImpl {
|
|||
}
|
||||
|
||||
class DoUnlessTargetPaysCost extends OneShotEffect {
|
||||
|
||||
private final OneShotEffect executingEffect;
|
||||
private final Cost cost;
|
||||
private final String userMessage;
|
||||
|
|
@ -102,6 +103,7 @@ class DoUnlessTargetPaysCost extends OneShotEffect {
|
|||
public DoUnlessTargetPaysCost(OneShotEffect effect, Cost cost) {
|
||||
this(effect, cost, null);
|
||||
}
|
||||
|
||||
public DoUnlessTargetPaysCost(OneShotEffect effect, Cost cost, String userMessage) {
|
||||
super(Outcome.Benefit);
|
||||
this.executingEffect = effect;
|
||||
|
|
@ -123,7 +125,7 @@ class DoUnlessTargetPaysCost extends OneShotEffect {
|
|||
if (player != null && mageObject != null) {
|
||||
String message = userMessage;
|
||||
if (message == null) {
|
||||
message = new StringBuilder(getCostText()).append(" to prevent ").append(executingEffect.getText(source.getModes().getMode())).append("?").toString();
|
||||
message = getCostText() + " to prevent " + executingEffect.getText(source.getModes().getMode()) + "?";
|
||||
}
|
||||
message = CardUtil.replaceSourceName(message, mageObject.getLogName());
|
||||
cost.clearPaid();
|
||||
|
|
@ -132,8 +134,8 @@ class DoUnlessTargetPaysCost extends OneShotEffect {
|
|||
}
|
||||
if (!cost.isPaid()) {
|
||||
executingEffect.setTargetPointer(this.targetPointer);
|
||||
return executingEffect.apply(game, source);
|
||||
}
|
||||
return executingEffect.apply(game, source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -153,8 +155,8 @@ class DoUnlessTargetPaysCost extends OneShotEffect {
|
|||
private String getCostText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String costText = cost.getText();
|
||||
if (costText != null &&
|
||||
!costText.toLowerCase().startsWith("discard")
|
||||
if (costText != null
|
||||
&& !costText.toLowerCase().startsWith("discard")
|
||||
&& !costText.toLowerCase().startsWith("sacrifice")
|
||||
&& !costText.toLowerCase().startsWith("remove")) {
|
||||
sb.append("pay ");
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ class JaceTelepathUnboundEffect extends OneShotEffect {
|
|||
Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
|
||||
if (card != null) {
|
||||
ContinuousEffect effect = new JaceTelepathUnboundCastFromGraveyardEffect();
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
|
||||
game.addEffect(effect, source);
|
||||
effect = new JaceTelepathUnboundReplacementEffect(card.getId());
|
||||
game.addEffect(effect, source);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ package mage.sets.magicorigins;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.condition.common.SpellMasteryCondition;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
|
@ -137,9 +138,8 @@ class PsychicRebuttalPredicate implements ObjectPlayerPredicate<ObjectPlayer<Sta
|
|||
if (controllerId == null) {
|
||||
return false;
|
||||
}
|
||||
for (UUID modeId : input.getObject().getStackAbility().getModes().getSelectedModes()) {
|
||||
input.getObject().getStackAbility().getModes().setActiveMode(modeId);
|
||||
for (Target target : input.getObject().getStackAbility().getTargets()) {
|
||||
for (Mode mode : input.getObject().getStackAbility().getModes().getSelectedModes()) {
|
||||
for (Target target : mode.getTargets()) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
if (controllerId.equals(targetId)) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -28,11 +28,12 @@
|
|||
package mage.sets.shardsofalara;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.common.CounterTargetEffect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.filter.predicate.ObjectPlayer;
|
||||
import mage.filter.predicate.ObjectPlayerPredicate;
|
||||
|
|
@ -58,7 +59,6 @@ public class HinderingLight extends CardImpl {
|
|||
super(ownerId, 173, "Hindering Light", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{W}{U}");
|
||||
this.expansionSetCode = "ALA";
|
||||
|
||||
|
||||
// Counter target spell that targets you or a permanent you control.
|
||||
this.getSpellAbility().addEffect(new CounterTargetEffect());
|
||||
this.getSpellAbility().addTarget(new TargetSpell(filter));
|
||||
|
|
@ -84,9 +84,8 @@ class HinderingLightPredicate implements ObjectPlayerPredicate<ObjectPlayer<Stac
|
|||
if (controllerId == null) {
|
||||
return false;
|
||||
}
|
||||
for (UUID modeId :input.getObject().getStackAbility().getModes().getSelectedModes()) {
|
||||
input.getObject().getStackAbility().getModes().setActiveMode(modeId);
|
||||
for (Target target : input.getObject().getStackAbility().getTargets()) {
|
||||
for (Mode mode : input.getObject().getStackAbility().getModes().getSelectedModes()) {
|
||||
for (Target target : mode.getTargets()) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
if (controllerId.equals(targetId)) {
|
||||
return true;
|
||||
|
|
@ -96,7 +95,7 @@ class HinderingLightPredicate implements ObjectPlayerPredicate<ObjectPlayer<Stac
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ package mage.sets.vintagemasters;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
|
|
@ -44,14 +45,13 @@ import mage.constants.Rarity;
|
|||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.target.Target;
|
||||
import mage.target.Targets;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
|
||||
*
|
||||
*/
|
||||
public class KaerveksTorch extends CardImpl {
|
||||
|
||||
|
|
@ -95,13 +95,11 @@ class KaerveksTorchCostIncreaseEffect extends CostModificationEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if(abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility)
|
||||
{
|
||||
for(UUID modeId: abilityToModify.getModes().getSelectedModes()) {
|
||||
abilityToModify.getModes().setActiveMode(modeId);
|
||||
for(Target target: abilityToModify.getTargets()) {
|
||||
for(UUID id: target.getTargets()) {
|
||||
if(id.equals(source.getSourceObject(game).getId())) {
|
||||
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) {
|
||||
for (Mode mode : abilityToModify.getModes().getSelectedModes()) {
|
||||
for (Target target : mode.getTargets()) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
if (targetId.equals(source.getSourceObject(game).getId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +1,42 @@
|
|||
/*
|
||||
* Copyright 2010 maurer.it_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of maurer.it_at_googlemail.com.
|
||||
*/
|
||||
|
||||
* Copyright 2010 maurer.it_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of maurer.it_at_googlemail.com.
|
||||
*/
|
||||
package mage.sets.zendikar;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
|
||||
import mage.abilities.effects.common.ExileTargetForSourceEffect;
|
||||
import mage.abilities.effects.common.ReturnFromExileForSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.AnotherPredicate;
|
||||
import mage.target.Target;
|
||||
|
|
@ -53,7 +52,6 @@ public class JourneyToNowhere extends CardImpl {
|
|||
super(ownerId, 14, "Journey to Nowhere", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}");
|
||||
this.expansionSetCode = "ZEN";
|
||||
|
||||
|
||||
// When Journey to Nowhere enters the battlefield, exile target creature.
|
||||
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
filter.add(new AnotherPredicate());
|
||||
|
|
@ -61,7 +59,7 @@ public class JourneyToNowhere extends CardImpl {
|
|||
Target target = new TargetPermanent(filter);
|
||||
ability1.addTarget(target);
|
||||
this.addAbility(ability1);
|
||||
|
||||
|
||||
// When Journey to Nowhere leaves the battlefield, return the exiled card to the battlefield under its owner's control.
|
||||
Ability ability2 = new LeavesBattlefieldTriggeredAbility(new ReturnFromExileForSourceEffect(Zone.BATTLEFIELD), false);
|
||||
this.addAbility(ability2);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue