mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Merge branch 'master' of https://github.com/magefree/mage
This commit is contained in:
commit
52c7e7ee19
6 changed files with 196 additions and 81 deletions
|
@ -40,6 +40,7 @@ import mage.filter.common.FilterCreaturePermanent;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
|
@ -54,8 +55,10 @@ public class Bioshift extends CardImpl {
|
|||
|
||||
// Move any number of +1/+1 counters from target creature onto another target creature with the same controller.
|
||||
getSpellAbility().addEffect(new MoveCounterFromTargetToTargetEffect());
|
||||
getSpellAbility().addTarget(new TargetCreaturePermanentSameController(2,2,new FilterCreaturePermanent(),false));
|
||||
getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterCreaturePermanent("creature (you take counters from)")));
|
||||
getSpellAbility().addTarget(new BioshiftSecondTargetPermanent());
|
||||
}
|
||||
|
||||
|
||||
public Bioshift(final Bioshift card) {
|
||||
super(card);
|
||||
|
@ -67,37 +70,6 @@ public class Bioshift extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class TargetCreaturePermanentSameController extends TargetCreaturePermanent {
|
||||
|
||||
public TargetCreaturePermanentSameController(int minNumTargets, int maxNumTargets, FilterCreaturePermanent filter, boolean notTarget) {
|
||||
super(minNumTargets, maxNumTargets, filter, notTarget);
|
||||
this.targetName = filter.getMessage();
|
||||
}
|
||||
|
||||
public TargetCreaturePermanentSameController(final TargetCreaturePermanentSameController target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
UUID firstTarget = this.getFirstTarget();
|
||||
if (firstTarget != null) {
|
||||
Permanent permanent = game.getPermanent(firstTarget);
|
||||
Permanent targetPermanent = game.getPermanent(id);
|
||||
if (permanent == null || targetPermanent == null
|
||||
|| !permanent.getControllerId().equals(targetPermanent.getOwnerId())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.canTarget(id, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetCreaturePermanentSameController copy() {
|
||||
return new TargetCreaturePermanentSameController(this);
|
||||
}
|
||||
}
|
||||
|
||||
class MoveCounterFromTargetToTargetEffect extends OneShotEffect {
|
||||
|
||||
public MoveCounterFromTargetToTargetEffect() {
|
||||
|
@ -116,22 +88,56 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent fromPermanent = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
Permanent toPermanent = null;
|
||||
if (targetPointer.getTargets(game, source).size() > 1) {
|
||||
toPermanent = game.getPermanent(targetPointer.getTargets(game, source).get(1));
|
||||
}
|
||||
if (fromPermanent == null || toPermanent == null || !fromPermanent.getControllerId().equals(toPermanent.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
int amountCounters = fromPermanent.getCounters().getCount(CounterType.P1P1);
|
||||
if (amountCounters > 0) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller.getAmount(0, amountCounters, "How many counters do you want to move?", game) > 0){
|
||||
fromPermanent.getCounters().removeCounter(CounterType.P1P1, amountCounters);
|
||||
toPermanent.addCounters(CounterType.P1P1.createInstance(amountCounters), game);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Permanent fromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
Permanent toPermanent = null;
|
||||
if (source.getTargets().size() > 1) {
|
||||
toPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
}
|
||||
if (fromPermanent == null || toPermanent == null || !fromPermanent.getControllerId().equals(toPermanent.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
int amountCounters = fromPermanent.getCounters().getCount(CounterType.P1P1);
|
||||
if (amountCounters > 0) {
|
||||
int amountToMove = controller.getAmount(0, amountCounters, "How many counters do you want to move?", game);
|
||||
if (amountToMove > 0) {
|
||||
fromPermanent.removeCounters(CounterType.P1P1.createInstance(amountToMove), game);
|
||||
toPermanent.addCounters(CounterType.P1P1.createInstance(amountToMove), game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class BioshiftSecondTargetPermanent extends TargetPermanent {
|
||||
|
||||
BioshiftSecondTargetPermanent() {
|
||||
super();
|
||||
this.filter = new FilterCreaturePermanent("another target creature with the same controller (counters go to)");
|
||||
}
|
||||
|
||||
BioshiftSecondTargetPermanent(final BioshiftSecondTargetPermanent target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||
Permanent firstPermanent = game.getPermanent(source.getTargets().getFirstTarget());
|
||||
Permanent secondPermanent = game.getPermanent(id);
|
||||
if (firstPermanent != null && secondPermanent != null) {
|
||||
if (!firstPermanent.getId().equals(id) && firstPermanent.getControllerId().equals(secondPermanent.getControllerId())) {
|
||||
return super.canTarget(controllerId, id, source, game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BioshiftSecondTargetPermanent copy() {
|
||||
return new BioshiftSecondTargetPermanent(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ import mage.game.events.GameEvent.EventType;
|
|||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.PreventionEffectData;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -121,7 +122,7 @@ public class ProteanHydra extends CardImpl {
|
|||
class ProteanHydraEffect2 extends PreventionEffectImpl {
|
||||
|
||||
public ProteanHydraEffect2() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
super(Duration.WhileOnBattlefield, Integer.MAX_VALUE, false, false);
|
||||
staticText = "If damage would be dealt to {this}, prevent that damage and remove that many +1/+1 counters from it";
|
||||
}
|
||||
|
||||
|
@ -141,19 +142,14 @@ public class ProteanHydra extends CardImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
boolean retValue = false;
|
||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
|
||||
int damage = event.getAmount();
|
||||
if (!game.replaceEvent(preventEvent)) {
|
||||
event.setAmount(0);
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), damage));
|
||||
retValue = true;
|
||||
PreventionEffectData preventionEffectData = preventDamageAction(event, source, game);
|
||||
if (preventionEffectData.getPreventedDamage() > 0) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
permanent.removeCounters(CounterType.P1P1.createInstance(preventionEffectData.getPreventedDamage()), game);
|
||||
}
|
||||
}
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
permanent.removeCounters(CounterType.P1P1.createInstance(damage), game);
|
||||
}
|
||||
return retValue;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -183,9 +179,14 @@ public class ProteanHydra extends CardImpl {
|
|||
return new ProteanHydraAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.COUNTER_REMOVED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.COUNTER_REMOVED && event.getData().equals("+1/+1") && event.getTargetId().equals(this.getSourceId())) {
|
||||
if (event.getData().equals("+1/+1") && event.getTargetId().equals(this.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -213,12 +214,14 @@ public class ProteanHydra extends CardImpl {
|
|||
return new ProteanHydraDelayedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.END_TURN_STEP_PRE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.END_TURN_STEP_PRE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,7 +39,6 @@ import mage.abilities.effects.RestrictionEffect;
|
|||
import mage.abilities.keyword.IslandwalkAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterLandPermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
|
@ -58,7 +57,10 @@ public class HarborSerpent extends CardImpl {
|
|||
this.power = new MageInt(5);
|
||||
this.toughness = new MageInt(5);
|
||||
|
||||
// Islandwalk (This creature is unblockable as long as defending player controls an Island.)
|
||||
this.addAbility(new IslandwalkAbility());
|
||||
|
||||
// Harbor Serpent can't attack unless there are five or more Islands on the battlefield.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HarborSerpentEffect()));
|
||||
}
|
||||
|
||||
|
@ -74,11 +76,10 @@ public class HarborSerpent extends CardImpl {
|
|||
|
||||
class HarborSerpentEffect extends RestrictionEffect {
|
||||
|
||||
private final FilterLandPermanent filter = new FilterLandPermanent("Island");
|
||||
private static final FilterLandPermanent filter = new FilterLandPermanent("Island", "Island");
|
||||
|
||||
public HarborSerpentEffect() {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
filter.add(new SubtypePredicate("Island"));
|
||||
staticText = "{this} can't attack unless there are five or more Islands on the battlefield";
|
||||
}
|
||||
|
||||
|
@ -97,10 +98,8 @@ class HarborSerpentEffect extends RestrictionEffect {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 5) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return permanent.getId().equals(source.getSourceId()) &&
|
||||
game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 5;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,10 +111,11 @@ class GlamerSpinnersEffect extends OneShotEffect {
|
|||
5/1/2008 You may target a permanent that has no Auras enchanting it.
|
||||
5/1/2008 When the ability resolves, you choose the permanent that will be receiving the Auras. It can't be the targeted permanent, it must have the same controller as the targeted permanent, and it must be able to be enchanted by all the Auras attached to the targeted permanent. If you can't choose a permanent that meets all those criteria, the Auras won't move.
|
||||
*/
|
||||
Boolean passed = true;
|
||||
Permanent targetPermanent = game.getPermanent(source.getFirstTarget());
|
||||
Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (targetPermanent != null) {
|
||||
Permanent sourcePermanent = (Permanent) source.getSourceObject(game);
|
||||
if (targetPermanent != null && controller != null && sourcePermanent != null) {
|
||||
Boolean passed = true;
|
||||
FilterPermanent filterChoice = new FilterPermanent("a different permanent with the same controller as the target to attach the enchantments to");
|
||||
filterChoice.add(new ControllerIdPredicate(targetPermanent.getControllerId()));
|
||||
filterChoice.add(Predicates.not(new PermanentIdPredicate(targetPermanent.getId())));
|
||||
|
@ -122,11 +123,10 @@ class GlamerSpinnersEffect extends OneShotEffect {
|
|||
Target chosenPermanentToAttachAuras = new TargetPermanent(filterChoice);
|
||||
chosenPermanentToAttachAuras.setNotTarget(true);
|
||||
|
||||
LinkedList<UUID> auras = new LinkedList();
|
||||
LinkedList<UUID> auras = new LinkedList<>();
|
||||
auras.addAll(targetPermanent.getAttachments());
|
||||
|
||||
if (controller != null
|
||||
&& controller.choose(Outcome.Neutral, chosenPermanentToAttachAuras, source.getSourceId(), game)) {
|
||||
if (controller.choose(Outcome.Neutral, chosenPermanentToAttachAuras, source.getSourceId(), game)) {
|
||||
Permanent permanentToAttachAuras = game.getPermanent(chosenPermanentToAttachAuras.getFirstTarget());
|
||||
if (permanentToAttachAuras != null) {
|
||||
for (UUID auraId : auras) {
|
||||
|
@ -148,7 +148,7 @@ class GlamerSpinnersEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
if (passed) {
|
||||
LinkedList<UUID> aurasToAttach = new LinkedList();
|
||||
LinkedList<UUID> aurasToAttach = new LinkedList<>();
|
||||
aurasToAttach.addAll(auras);
|
||||
|
||||
for (UUID auraId : aurasToAttach) {
|
||||
|
@ -158,10 +158,12 @@ class GlamerSpinnersEffect extends OneShotEffect {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
game.informPlayers(sourcePermanent.getLogName() + ": No enchantments were moved from the target permanent.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
game.informPlayers("Glamer Spinners: No enchantments were moved from the target permanent.");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_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 BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package org.mage.test.cards.abilities.oneshot.counter;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class MovingCounterTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* I'm having an issue when using Bioshift to move only a portion of
|
||||
* counters to another creature. When I attempt to do this, it moves all of
|
||||
* the counters (and in some cases with my Simic deck) kills the creature.
|
||||
*/
|
||||
@Test
|
||||
public void testCantBeCounteredNormal() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 6);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
|
||||
|
||||
// Move any number of +1/+1 counters from target creature onto another target creature with the same controller.
|
||||
addCard(Zone.HAND, playerA, "Bioshift", 1);
|
||||
|
||||
// Protean Hydra enters the battlefield with X +1/+1 counters on it.
|
||||
// If damage would be dealt to Protean Hydra, prevent that damage and remove that many +1/+1 counters from it.
|
||||
// Whenever a +1/+1 counter is removed from Protean Hydra, put two +1/+1 counters on it at the beginning of the next end step.
|
||||
addCard(Zone.HAND, playerA, "Protean Hydra", 1);
|
||||
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Protean Hydra");
|
||||
setChoice(playerA, "X=4");
|
||||
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Bioshift", "Protean Hydra^Silvercoat Lion");
|
||||
setChoice(playerA, "X=2");
|
||||
|
||||
setStopAt(2, PhaseStep.UPKEEP);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, "Bioshift", 1);
|
||||
|
||||
assertPermanentCount(playerA, "Silvercoat Lion", 1);
|
||||
assertPowerToughness(playerA, "Silvercoat Lion", 4, 4); // added 2 counters
|
||||
|
||||
assertPermanentCount(playerA, "Protean Hydra", 1);
|
||||
assertPowerToughness(playerA, "Protean Hydra", 6, 6); // started with 4, removed 2, added 4 at end = 6
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -66,6 +66,31 @@ public class CantAttackTest extends CardTestPlayerBase {
|
|||
assertLife(playerB, 14); // 4 + 2
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAttackHarborSerpent() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion"); // 2/2
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Harbor Serpent"); // 5/5
|
||||
addCard(Zone.HAND, playerA, "Island");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); // 2/2
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Harbor Serpent"); // 5/5
|
||||
|
||||
attack(2, playerB, "Harbor Serpent");
|
||||
attack(2, playerB, "Silvercoat Lion");
|
||||
|
||||
playLand(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Island");
|
||||
attack(3, playerA, "Harbor Serpent");
|
||||
attack(3, playerA, "Silvercoat Lion");
|
||||
|
||||
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertLife(playerB, 13);
|
||||
assertLife(playerA, 18);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue