Merge origin/master

This commit is contained in:
fireshoes 2015-08-30 14:48:44 -05:00
commit 83022daabe
6 changed files with 128 additions and 145 deletions

View file

@ -1080,6 +1080,7 @@ public class HumanPlayer extends PlayerImpl {
int remainingDamage = damage; int remainingDamage = damage;
while (remainingDamage > 0 && canRespond()) { while (remainingDamage > 0 && canRespond()) {
Target target = new TargetCreatureOrPlayer(); Target target = new TargetCreatureOrPlayer();
target.setNotTarget(true);
if (singleTargetName != null) { if (singleTargetName != null) {
target.setTargetName(singleTargetName); target.setTargetName(singleTargetName);
} }

View file

@ -73,20 +73,20 @@ public class DiluvianPrimordial extends CardImpl {
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// When Diluvian Primordial enters the battlefield, for each opponent, you may cast up to one target instant or sorcery card from that player's graveyard without paying its mana cost. If a card cast this way would be put into a graveyard this turn, exile it instead. // When Diluvian Primordial enters the battlefield, for each opponent, you may cast up to one target instant or sorcery card from that player's graveyard without paying its mana cost. If a card cast this way would be put into a graveyard this turn, exile it instead.
this.addAbility(new EntersBattlefieldTriggeredAbility(new DiluvianPrimordialEffect(),false)); this.addAbility(new EntersBattlefieldTriggeredAbility(new DiluvianPrimordialEffect(), false));
} }
@Override @Override
public void adjustTargets(Ability ability, Game game) { public void adjustTargets(Ability ability, Game game) {
if (ability instanceof EntersBattlefieldTriggeredAbility) { if (ability instanceof EntersBattlefieldTriggeredAbility) {
ability.getTargets().clear(); ability.getTargets().clear();
for(UUID opponentId : game.getOpponents(ability.getControllerId())) { for (UUID opponentId : game.getOpponents(ability.getControllerId())) {
Player opponent = game.getPlayer(opponentId); Player opponent = game.getPlayer(opponentId);
if (opponent != null) { if (opponent != null) {
FilterCard filter = new FilterCard("instant or sorcery card from " + opponent.getLogName() + "'s graveyard"); FilterCard filter = new FilterCard("instant or sorcery card from " + opponent.getLogName() + "'s graveyard");
filter.add(new OwnerIdPredicate(opponentId)); filter.add(new OwnerIdPredicate(opponentId));
filter.add(Predicates.or(new CardTypePredicate(CardType.INSTANT),new CardTypePredicate(CardType.SORCERY))); filter.add(Predicates.or(new CardTypePredicate(CardType.INSTANT), new CardTypePredicate(CardType.SORCERY)));
TargetCardInOpponentsGraveyard target = new TargetCardInOpponentsGraveyard(0,1, filter); TargetCardInOpponentsGraveyard target = new TargetCardInOpponentsGraveyard(0, 1, filter);
ability.addTarget(target); ability.addTarget(target);
} }
} }
@ -123,17 +123,16 @@ class DiluvianPrimordialEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
for (Target target: source.getTargets()) { for (Target target : source.getTargets()) {
if (target instanceof TargetCardInOpponentsGraveyard) { if (target instanceof TargetCardInOpponentsGraveyard) {
Card targetCard = game.getCard(target.getFirstTarget()); Card targetCard = game.getCard(target.getFirstTarget());
if (targetCard != null) { if (targetCard != null) {
if (controller.chooseUse(outcome, "Cast " + targetCard.getLogName() +"?", source, game)) { if (controller.chooseUse(outcome, "Cast " + targetCard.getLogName() + "?", source, game)) {
// TODO: Handle the case if the cast is not possible, so the replacement effect shouldn't be active if (controller.cast(targetCard.getSpellAbility(), game, true)) {
ContinuousEffect effect = new DiluvianPrimordialReplacementEffect(); ContinuousEffect effect = new DiluvianPrimordialReplacementEffect();
effect.setTargetPointer(new FixedTarget(targetCard.getId())); effect.setTargetPointer(new FixedTarget(targetCard.getId(), game.getState().getZoneChangeCounter(targetCard.getId())));
game.addEffect(effect, source); game.addEffect(effect, source);
}
controller.cast(targetCard.getSpellAbility(), game, true);
} }
} }
} }
@ -169,7 +168,7 @@ class DiluvianPrimordialReplacementEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
Card card = game.getCard(((FixedTarget)getTargetPointer()).getTarget()); Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) { if (card != null) {
controller.moveCards(card, Zone.STACK, Zone.EXILED, source, game); controller.moveCards(card, Zone.STACK, Zone.EXILED, source, game);
return true; return true;

View file

@ -1,37 +1,35 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 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 * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * 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 * 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 * 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 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * 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 * 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 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * 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 * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.sets.magic2010; package mage.sets.magic2010;
import mage.constants.CardType; import java.util.ArrayList;
import mage.constants.Outcome; import java.util.List;
import mage.constants.Rarity; import java.util.UUID;
import mage.constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.OnEventTriggeredAbility; import mage.abilities.common.OnEventTriggeredAbility;
@ -40,6 +38,10 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.CreateTokenEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate;
@ -51,10 +53,6 @@ import mage.game.permanent.token.WolfToken;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -72,7 +70,10 @@ public class MasterOfTheWildHunt extends CardImpl {
this.power = new MageInt(3); this.power = new MageInt(3);
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// At the beginning of your upkeep, put a 2/2 green Wolf creature token onto the battlefield.
this.addAbility(new OnEventTriggeredAbility(EventType.UPKEEP_STEP_PRE, "beginning of your upkeep", new CreateTokenEffect(wolfToken))); this.addAbility(new OnEventTriggeredAbility(EventType.UPKEEP_STEP_PRE, "beginning of your upkeep", new CreateTokenEffect(wolfToken)));
// {T}: Tap all untapped Wolf creatures you control. Each Wolf tapped this way deals damage equal to its power to target creature. That creature deals damage equal to its power divided as its controller chooses among any number of those Wolves.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MasterOfTheWildHuntEffect(), new TapSourceCost()); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MasterOfTheWildHuntEffect(), new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent()); ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability); this.addAbility(ability);
@ -116,7 +117,7 @@ class MasterOfTheWildHuntEffect extends OneShotEffect {
List<UUID> wolves = new ArrayList<>(); List<UUID> wolves = new ArrayList<>();
Permanent target = game.getPermanent(source.getFirstTarget()); Permanent target = game.getPermanent(source.getFirstTarget());
if (target != null && game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0) { if (target != null && game.getBattlefield().countAll(filter, source.getControllerId(), game) > 0) {
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
permanent.tap(game); permanent.tap(game);
target.damage(permanent.getToughness().getValue(), permanent.getId(), game, false, true); target.damage(permanent.getToughness().getValue(), permanent.getId(), game, false, true);
wolves.add(permanent.getId()); wolves.add(permanent.getId());
@ -128,4 +129,4 @@ class MasterOfTheWildHuntEffect extends OneShotEffect {
return false; return false;
} }
} }

View file

@ -28,18 +28,15 @@
package mage.sets.newphyrexia; package mage.sets.newphyrexia;
import java.util.UUID; import java.util.UUID;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer; import mage.filter.common.FilterCreaturePermanent;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.SecondTargetPointer;
/** /**
* *
@ -51,9 +48,16 @@ public class LeechingBite extends CardImpl {
super(ownerId, 113, "Leeching Bite", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{G}"); super(ownerId, 113, "Leeching Bite", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{G}");
this.expansionSetCode = "NPH"; this.expansionSetCode = "NPH";
// Target creature gets +1/+1 until end of turn. Another target creature gets -1/-1 until end of turn.
this.getSpellAbility().addEffect(new LeechingBiteEffect()); Effect effect = new BoostTargetEffect(1, 1, Duration.EndOfTurn);
this.getSpellAbility().addTarget(new TargetCreaturePermanent(2)); effect.setText("Target creature gets +1/+1 until end of turn");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature (getting the +1/+1 counter)")));
effect = new BoostTargetEffect(-1, -1, Duration.EndOfTurn);
effect.setText("Another target creature gets -1/-1 until end of turn");
effect.setTargetPointer(new SecondTargetPointer());
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature (getting the -1/-1 counter)")));
} }
public LeechingBite(final LeechingBite card) { public LeechingBite(final LeechingBite card) {
@ -65,35 +69,3 @@ public class LeechingBite extends CardImpl {
return new LeechingBite(this); return new LeechingBite(this);
} }
} }
class LeechingBiteEffect extends ContinuousEffectImpl {
public LeechingBiteEffect() {
super(Duration.EndOfTurn, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
this.staticText = "Target creature gets +1/+1 until end of turn. Another target creature gets -1/-1 until end of turn";
}
public LeechingBiteEffect(final LeechingBiteEffect effect) {
super(effect);
}
@Override
public LeechingBiteEffect copy() {
return new LeechingBiteEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
permanent.addPower(1);
permanent.addToughness(1);
}
permanent = game.getPermanent(source.getTargets().get(0).getTargets().get(1));
if (permanent != null) {
permanent.addPower(-1);
permanent.addToughness(-1);
}
return true;
}
}

View file

@ -120,33 +120,44 @@ class SpellskiteEffect extends OneShotEffect {
target.addTarget(source.getSourceId(), stackObject.getStackAbility(), game); target.addTarget(source.getSourceId(), stackObject.getStackAbility(), game);
} }
} else { } else {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
for (Target target : targets) { boolean validTargets = false;
for (UUID targetId : target.getTargets()) { do {
MageObject object = game.getObject(targetId); for (Target target : targets) {
String name; for (UUID targetId : target.getTargets()) {
if (object == null) { MageObject object = game.getObject(targetId);
Player targetPlayer = game.getPlayer(targetId); String name;
name = targetPlayer.getLogName(); if (object == null) {
} else { Player targetPlayer = game.getPlayer(targetId);
name = object.getLogName(); name = targetPlayer.getLogName();
} } else {
if (!targetId.equals(source.getSourceId()) && target.getTargets().contains(source.getSourceId())) { name = object.getLogName();
// you can't change this target to Spellskite because Spellskite is already another targetId of that target. }
twoTimesTarget = true; if (!targetId.equals(source.getSourceId()) && target.getTargets().contains(source.getSourceId())) {
continue; // you can't change this target to Spellskite because Spellskite is already another targetId of that target.
} twoTimesTarget = true;
if (name != null && player.chooseUse(Outcome.Neutral, "Change target from " + name + " to " + sourceObject.getLogName() + "?", source, game)) { continue;
}
if (target.canTarget(stackObject.getControllerId(), source.getSourceId(), sourceAbility, game)) { if (target.canTarget(stackObject.getControllerId(), source.getSourceId(), sourceAbility, game)) {
oldTarget = game.getObject(targets.getFirstTarget()); validTargets = true;
target.remove(targetId); if (name != null
// The source is still the spell on the stack && controller.chooseUse(Outcome.Neutral, "Change target from " + name + " to " + sourceObject.getLogName() + "?", source, game)) {
target.addTarget(source.getSourceId(), stackObject.getStackAbility(), game); oldTarget = game.getObject(targetId);
break; target.remove(targetId);
// The source is still the spell on the stack
target.addTarget(source.getSourceId(), stackObject.getStackAbility(), game);
break;
}
} }
} }
if (oldTarget != null) {
break;
}
} }
} if (oldTarget == null) {
game.informPlayer(controller, "You have to select at least one target to change to spellskite!");
}
} while (validTargets && oldTarget == null);
} }
if (oldTarget != null) { if (oldTarget != null) {
game.informPlayers(sourceObject.getLogName() + ": Changed target of " + stackObject.getLogName() + " from " + oldTarget.getLogName() + " to " + sourceObject.getLogName()); game.informPlayers(sourceObject.getLogName() + ": Changed target of " + stackObject.getLogName() + " from " + oldTarget.getLogName() + " to " + sourceObject.getLogName());

View file

@ -1,31 +1,30 @@
/* /*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 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 * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * 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 * 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 * 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 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * 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 * 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 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * 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 * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.abilities.effects.common; package mage.abilities.effects.common;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -49,8 +48,7 @@ public class DestroyAllEffect extends OneShotEffect {
this.noRegen = noRegen; this.noRegen = noRegen;
if (noRegen) { if (noRegen) {
staticText = "destroy all " + filter.getMessage() + ". They can't be regenerated"; staticText = "destroy all " + filter.getMessage() + ". They can't be regenerated";
} } else {
else {
staticText = "destroy all " + filter.getMessage(); staticText = "destroy all " + filter.getMessage();
} }
} }
@ -72,6 +70,7 @@ public class DestroyAllEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
permanent.destroy(source.getSourceId(), game, noRegen); permanent.destroy(source.getSourceId(), game, noRegen);
} }