mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
Added test for Sepulchral Primordial.
This commit is contained in:
parent
f4718deae4
commit
e82ee26136
3 changed files with 99 additions and 24 deletions
|
|
@ -122,21 +122,26 @@ class DiluvianPrimordialEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (Target target: source.getTargets()) {
|
||||
if (target instanceof TargetCardInOpponentsGraveyard) {
|
||||
Card targetCard = game.getCard(target.getFirstTarget());
|
||||
if (controller != null && targetCard != null) {
|
||||
if (controller.chooseUse(outcome, "Cast " + targetCard.getName() +"?", game)) {
|
||||
controller.cast(targetCard.getSpellAbility(), game, true);
|
||||
if (targetCard != null) {
|
||||
if (controller.chooseUse(outcome, "Cast " + targetCard.getLogName() +"?", game)) {
|
||||
// TODO: Handle the case if the cast is not possible, so the replacement effect shouldn't be active
|
||||
ContinuousEffect effect = new DiluvianPrimordialReplacementEffect();
|
||||
effect.setTargetPointer(new FixedTarget(targetCard.getId()));
|
||||
game.addEffect(effect, source);
|
||||
|
||||
controller.cast(targetCard.getSpellAbility(), game, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class DiluvianPrimordialReplacementEffect extends ReplacementEffectImpl {
|
||||
|
|
@ -164,9 +169,9 @@ class DiluvianPrimordialReplacementEffect extends ReplacementEffectImpl {
|
|||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Card card = game.getCard(getTargetPointer().getFirst(game, source));
|
||||
Card card = game.getCard(((FixedTarget)getTargetPointer()).getTarget());
|
||||
if (card != null) {
|
||||
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.STACK, true);
|
||||
controller.moveCards(card, Zone.STACK, Zone.EXILED, source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -181,10 +186,7 @@ class DiluvianPrimordialReplacementEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getToZone() == Zone.GRAVEYARD
|
||||
&& ((ZoneChangeEvent) event).getTargetId().equals(getTargetPointer().getFirst(game, source))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return zEvent.getToZone() == Zone.GRAVEYARD
|
||||
&& ((ZoneChangeEvent) event).getTargetId().equals(getTargetPointer().getFirst(game, source));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,15 +113,18 @@ class SepulchralPrimordialEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (Target target: source.getTargets()) {
|
||||
if (target instanceof TargetCardInOpponentsGraveyard) {
|
||||
Card targetCard = game.getCard(target.getFirstTarget());
|
||||
if (player != null && targetCard != null) {
|
||||
if (targetCard != null) {
|
||||
targetCard.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* 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.multiplayer;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestMultiPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class PrimordialTest extends CardTestMultiPlayerBase {
|
||||
|
||||
/**
|
||||
* Tests Primordial cards with multiplayer effects
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void SepulchralPrimordialTest() {
|
||||
// When Sepulchral Primordial enters the battlefield, for each opponent, you may put up to one
|
||||
// target creature card from that player's graveyard onto the battlefield under your control.
|
||||
addCard(Zone.HAND, playerA, "Sepulchral Primordial");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp",7);
|
||||
|
||||
addCard(Zone.GRAVEYARD, playerB, "Silvercoat Lion");
|
||||
addCard(Zone.GRAVEYARD, playerC, "Walking Corpse");
|
||||
addCard(Zone.GRAVEYARD, playerD, "Pillarfield Ox");
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sepulchral Primordial");
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Sepulchral Primordial", 1);
|
||||
assertPermanentCount(playerA, "Silvercoat Lion", 1);
|
||||
assertPermanentCount(playerA, "Walking Corpse", 0);
|
||||
assertPermanentCount(playerA, "Pillarfield Ox", 1);
|
||||
assertGraveyardCount(playerC, "Walking Corpse", 1);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue