Merge branch 'master' into auriok-steelshaper

This commit is contained in:
Jason Wall 2015-04-19 16:23:24 -06:00
commit d5215e3e6d
17 changed files with 1356 additions and 1201 deletions

View file

@ -72,6 +72,7 @@ public class SiftThroughSands extends CardImpl {
Effect effect = new DiscardControllerEffect(1);
effect.setText(", then discard a card");
this.getSpellAbility().addEffect(effect);
// If you've cast a spell named Peer Through Depths and a spell named Reach Through Mists this turn, you may search your library for a card named The Unspeakable, put it onto the battlefield, then shuffle your library.
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), false, true), new SiftThroughSandsCondition(), rule));
this.getSpellAbility().addWatcher(new SiftThroughSandsWatcher());

View file

@ -70,7 +70,6 @@ public class DungeonGeists extends CardImpl {
this.expansionSetCode = "DKA";
this.subtype.add("Spirit");
this.color.setBlue(true);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
@ -112,40 +111,52 @@ class DungeonGeistsEffect extends ContinuousRuleModifyingEffectImpl {
}
@Override
public boolean apply(Game game, Ability source) {
return false;
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.UNTAP || event.getType() == GameEvent.EventType.ZONE_CHANGE || event.getType() == GameEvent.EventType.LOST_CONTROL;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
// Source must be on the battlefield (it's neccessary to check here because if as response to the enter
// the battlefield triggered ability the source dies (or will be exiled), then the ZONE_CHANGE or LOST_CONTROL
// event will happen before this effect is applied ever)
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Permanent sourcePermanent = (Permanent) source.getSourceObjectIfItStillExists(game);
if (sourcePermanent == null || !sourcePermanent.getControllerId().equals(source.getControllerId())) {
this.used = true;
discard();
return false;
}
if (event.getType() == GameEvent.EventType.LOST_CONTROL) {
if (event.getTargetId().equals(source.getSourceId())) {
discard();
return false;
}
switch(event.getType()) {
case ZONE_CHANGE:
// end effect if source does a zone move
if (event.getTargetId().equals(source.getSourceId())) {
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
discard();
return false;
}
}
break;
case UNTAP:
// prevent to untap the target creature
if (game.getTurn().getStepType() == PhaseStep.UNTAP && event.getTargetId().equals(targetPointer.getFirst(game, source))) {
Permanent targetCreature = game.getPermanent(targetPointer.getFirst(game, source));
if (targetCreature != null) {
return targetCreature.getControllerId().equals(game.getActivePlayerId());
} else {
discard();
return false;
}
}
break;
case LOST_CONTROL:
// end effect if source control is changed
if (event.getTargetId().equals(source.getSourceId())) {
discard();
return false;
}
break;
}
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(source.getSourceId())) {
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
discard();
return false;
}
}
if (game.getTurn().getStepType() == PhaseStep.UNTAP && event.getType() == GameEvent.EventType.UNTAP) {
if (event.getTargetId().equals(targetPointer.getFirst(game, source))) {
return true;
}
}
return false;
}
}

View file

@ -52,8 +52,6 @@ public class MimingSlime extends CardImpl {
super(ownerId, 126, "Miming Slime", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{2}{G}");
this.expansionSetCode = "GTC";
this.color.setGreen(true);
// Put an X/X green Ooze creature token onto the battlefield, where X is the greatest power among creatures you control.
this.getSpellAbility().addEffect(new MimingSlimeEffect());
}

View file

@ -54,8 +54,6 @@ public class OozeFlux extends CardImpl {
super(ownerId, 128, "Ooze Flux", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}");
this.expansionSetCode = "GTC";
this.color.setGreen(true);
// {1}{G}, Remove one or more +1/+1 counters from among creatures you control: Put an X/X green Ooze creature token onto the battlefield, where X is the number of +1/+1 counters removed this way.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new OozeFluxCreateTokenEffect(new OozeToken()),new ManaCostsImpl("{1}{G}"));
ability.addCost(new RemoveVariableCountersTargetCost(new FilterControlledCreaturePermanent("creatures you control"), CounterType.P1P1, "one or more", 1));
@ -74,7 +72,7 @@ public class OozeFlux extends CardImpl {
class OozeFluxCreateTokenEffect extends OneShotEffect {
private Token token;
private final Token token;
public OozeFluxCreateTokenEffect(Token token) {
super(Outcome.PutCreatureInPlay);

View file

@ -30,10 +30,12 @@ package mage.sets.limitedalpha;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
@ -81,11 +83,20 @@ class TimetwisterEffect extends OneShotEffect {
for (UUID playerId: sourcePlayer.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.getLibrary().addAll(player.getHand().getCards(game), game);
player.getLibrary().addAll(player.getGraveyard().getCards(game), game);
for (Card card: player.getHand().getCards(game)) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
for (Card card: player.getGraveyard().getCards(game)) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
player.shuffleLibrary(game);
player.getHand().clear();
player.getGraveyard().clear();
}
}
game.getState().handleSimultaneousEvent(game); // needed here so state based triggered effects
for (UUID playerId: sourcePlayer.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.drawCards(7, game);
}
}

View file

@ -106,30 +106,24 @@ class GrandAbolisherEffect extends ContinuousRuleModifyingEffectImpl {
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
boolean spell = event.getType() == GameEvent.EventType.CAST_SPELL;
boolean activated = event.getType() == GameEvent.EventType.ACTIVATE_ABILITY;
if ((spell || activated) && game.getActivePlayerId().equals(source.getControllerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
if (spell) {
return true;
}
// check source of activated ability
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent != null) {
return permanent.getCardType().contains(CardType.ARTIFACT) || permanent.getCardType().contains(CardType.CREATURE)
|| permanent.getCardType().contains(CardType.ENCHANTMENT);
} else {
MageObject object = game.getObject(event.getSourceId());
if (object != null) {
return object.getCardType().contains(CardType.ARTIFACT) || object.getCardType().contains(CardType.CREATURE)
|| object.getCardType().contains(CardType.ENCHANTMENT);
}
}
}
return false;
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL || event.getType() == GameEvent.EventType.ACTIVATE_ABILITY;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getActivePlayerId().equals(source.getControllerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
switch(event.getType()) {
case CAST_SPELL:
return true;
case ACTIVATE_ABILITY:
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent != null) {
return permanent.getCardType().contains(CardType.ARTIFACT) || permanent.getCardType().contains(CardType.CREATURE)
|| permanent.getCardType().contains(CardType.ENCHANTMENT);
}
}
}
return false;
}
}

View file

@ -37,6 +37,9 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SetTargetPointer;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
@ -52,7 +55,7 @@ public class PainfulQuandary extends CardImpl {
this.expansionSetCode = "SOM";
// Whenever an opponent casts a spell, that player loses 5 life unless he or she discards a card.
this.addAbility(new SpellCastOpponentTriggeredAbility(new PainfulQuandryEffect(), false));
this.addAbility(new SpellCastOpponentTriggeredAbility(Zone.BATTLEFIELD, new PainfulQuandryEffect(), new FilterSpell(), false, SetTargetPointer.PLAYER));
}
public PainfulQuandary(final PainfulQuandary card) {

View file

@ -36,6 +36,7 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ColoredManaCost;
import mage.abilities.effects.common.RegenerateSourceEffect;
import mage.abilities.effects.common.SacrificeControllerEffect;
import mage.abilities.effects.common.SacrificeEffect;
import mage.cards.CardImpl;
import mage.constants.ColoredManaSymbol;
@ -54,7 +55,6 @@ public class SpinedFluke extends CardImpl {
this.subtype.add("Worm");
this.subtype.add("Horror");
this.color.setBlack(true);
this.power = new MageInt(5);
this.toughness = new MageInt(1);
}
@ -62,7 +62,7 @@ public class SpinedFluke extends CardImpl {
@Override
public void build() {
// When Spined Fluke enters the battlefield, sacrifice a creature.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SacrificeEffect(new FilterCreaturePermanent("a creature"), 1, "")));
this.addAbility(new EntersBattlefieldTriggeredAbility(new SacrificeControllerEffect(new FilterCreaturePermanent("a creature"), 1, "")));
// {B}: Regenerate Spined Fluke.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new RegenerateSourceEffect(), new ColoredManaCost(ColoredManaSymbol.B)));
}

View file

@ -0,0 +1,51 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.test.cards.abilities.activated;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.permanent.Permanent;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class PutOntoBattlefieldTest extends CardTestPlayerBase {
/**
* Tests to put a token onto the battlefield
*/
@Test
public void testOozeFlux() {
// Enchantment
// {1}{G}, Remove one or more +1/+1 counters from among creatures you control: Put an X/X green Ooze creature token onto the battlefield, where X is the number of +1/+1 counters removed this way.
addCard(Zone.BATTLEFIELD, playerA, "Ooze Flux");
// Trample
// Kalonian Hydra enters the battlefield with four +1/+1 counters on it.
// Whenever Kalonian Hydra attacks, double the number of +1/+1 counters on each creature you control.
addCard(Zone.BATTLEFIELD, playerA, "Kalonian Hydra");
addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{G},");
setChoice(playerA, "X=2"); // Remove how many
setChoice(playerA,"Kalonian Hydra");
setChoice(playerA, "X=2"); // Remove from Hydra
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPowerToughness(playerA, "Kalonian Hydra", 2, 2);
assertPermanentCount(playerA, "Ooze", 1);
assertPowerToughness(playerA, "Ooze", 2, 2);
}
}

View file

@ -74,16 +74,20 @@ public class DungeonGeistsTest extends CardTestPlayerBase {
public void testWithBlink() {
addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
// When Dungeon Geists enters the battlefield, tap target creature an opponent controls.
// That creature doesn't untap during its controller's untap step for as long as you control Dungeon Geists.
addCard(Zone.HAND, playerA, "Dungeon Geists");
addCard(Zone.HAND, playerA, "Cloudshift");
addCard(Zone.BATTLEFIELD, playerB, "Craw Wurm");
addCard(Zone.BATTLEFIELD, playerB, "Elite Vanguard");
addTarget(playerA, "Craw Wurm"); // first target Craw Wurm
addTarget(playerA, "Elite Vanguard"); // after Cloudshift effect (return back to battlefield) target Elite Vanguard
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Dungeon Geists");
addTarget(playerA, "Craw Wurm"); // first target Craw Wurm
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Cloudshift", "Dungeon Geists");
addTarget(playerA, "Elite Vanguard"); // after Cloudshift effect (return back to battlefield) target Elite Vanguard
setStopAt(2, PhaseStep.DRAW);
execute();

View file

@ -0,0 +1,66 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.test.cards.triggers.state;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class SynodCenturionTest extends CardTestPlayerBase {
/**
* Check that Synod Centurion gets sacrificed if no other artifacts are on the battlefield
*
*/
@Test
public void testAlone() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 6);
addCard(Zone.BATTLEFIELD, playerA, "Demon's Horn");
addCard(Zone.HAND, playerA, "Shatter");
addCard(Zone.HAND, playerA, "Synod Centurion");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Synod Centurion");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Shatter", "Demon's Horn");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerA, "Demon's Horn", 1);
assertGraveyardCount(playerA, "Shatter", 1);
assertGraveyardCount(playerA, "Synod Centurion", 1);
}
/**
* Check that Synod Centurion gets sacrificed if the only other
* artifact left the battlefiled for a short time
*
*/
@Test
public void testWithFlicker() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 6);
addCard(Zone.BATTLEFIELD, playerA, "Bottle Gnomes");
addCard(Zone.HAND, playerA, "Cloudshift");
addCard(Zone.HAND, playerA, "Synod Centurion");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Synod Centurion");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Cloudshift", "Bottle Gnomes");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, "Bottle Gnomes", 1);
assertGraveyardCount(playerA, "Cloudshift", 1);
assertGraveyardCount(playerA, "Synod Centurion", 1);
}
}

View file

@ -502,6 +502,18 @@ public class TestPlayer extends ComputerPlayer {
return super.announceXCost(min, max, message, game, ability, null);
}
@Override
public int getAmount(int min, int max, String message, Game game) {
if (!choices.isEmpty()) {
if (choices.get(0).startsWith("X=")) {
int xValue = Integer.parseInt(choices.get(0).substring(2));
choices.remove(0);
return xValue;
}
}
return super.getAmount(min, max, message, game);
}
protected Permanent findPermanent(FilterPermanent filter, UUID controllerId, Game game) {
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(filter, controllerId, game);
if (permanents.size() > 0) {

View file

@ -215,14 +215,20 @@ public abstract class AbilityImpl implements Ability {
else {
game.addEffect((ContinuousEffect) effect, this);
}
/**
* All restrained trigger events are fired now.
* To restrain the events is mainly neccessary because of the movement of multiple object at once.
* If the event is fired directly as one object moved, other objects are not already in the correct zone
* to check for their effects. (e.g. Valakut, the Molten Pinnacle)
*/
game.getState().handleSimultaneousEvent(game);
game.resetShortLivingLKI();
/**
* game.applyEffects() has to be done at least for every effect that moves cards/permanent between zones,
* so Static effects work as intened if dependant from the moved objects zone it is in
* Otherwise for example were static abilities with replacement effects deactivated to late
* Example: {@link org.mage.test.cards.replacement.DryadMilitantTest#testDiesByDestroy testDiesByDestroy}
*/
// game.applyEffects();
// some effects must be applied before next effect is resolved, because effect is dependend.
if (effect.applyEffectsAfter()) {
game.applyEffects();
}

View file

@ -584,7 +584,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
permanent.entersBattlefield(sourceId, game, event.getFromZone(), true);
game.setScopeRelevant(false);
game.applyEffects();
game.fireEvent(new ZoneChangeEvent(permanent, event.getPlayerId(), fromZone, Zone.BATTLEFIELD));
game.addSimultaneousEvent(new ZoneChangeEvent(permanent, event.getPlayerId(), fromZone, Zone.BATTLEFIELD));
return true;
}
if (facedown) {

View file

@ -108,7 +108,7 @@ public class PermanentToken extends PermanentImpl {
if (!game.replaceEvent(new ZoneChangeEvent(this, sourceId, this.getControllerId(), Zone.BATTLEFIELD, Zone.EXILED))) {
game.rememberLKI(objectId, Zone.BATTLEFIELD, this);
if (game.getPlayer(controllerId).removeFromBattlefield(this, game)) {
game.fireEvent(new ZoneChangeEvent(this, sourceId, this.getControllerId(), Zone.BATTLEFIELD, Zone.EXILED));
game.addSimultaneousEvent(new ZoneChangeEvent(this, sourceId, this.getControllerId(), Zone.BATTLEFIELD, Zone.EXILED));
return true;
}
}

View file

@ -201,8 +201,8 @@ public class Spell implements StackObject, Card {
result |= spellAbility.resolve(game);
}
}
game.getState().handleSimultaneousEvent(game);
game.resetShortLivingLKI();
// game.getState().handleSimultaneousEvent(game);
// game.resetShortLivingLKI();
index++;
}
}

View file

@ -132,7 +132,7 @@ public class CardUtil {
* @param increaseCount
*/
public static void increaseCost(Ability ability, int increaseCount) {
adjustCost(ability, -increaseCount);
adjustAbilityCost(ability, -increaseCount);
adjustAlternativeCosts(ability, -increaseCount);
}
@ -143,7 +143,7 @@ public class CardUtil {
* @param reduceCount
*/
public static void reduceCost(Ability ability, int reduceCount) {
adjustCost(ability, reduceCount);
adjustAbilityCost(ability, reduceCount);
adjustAlternativeCosts(ability, reduceCount);
}
@ -154,7 +154,7 @@ public class CardUtil {
* @param reduceCount
*/
public static void adjustCost(SpellAbility spellAbility, int reduceCount) {
CardUtil.adjustCost((Ability) spellAbility, reduceCount);
CardUtil.adjustAbilityCost((Ability) spellAbility, reduceCount);
adjustAlternativeCosts(spellAbility, reduceCount);
}
@ -208,7 +208,7 @@ public class CardUtil {
* @param ability
* @param reduceCount
*/
private static void adjustCost(Ability ability, int reduceCount) {
public static void adjustAbilityCost(Ability ability, int reduceCount) {
ManaCosts<ManaCost> adjustedCost = adjustCost(ability.getManaCostsToPay(), reduceCount);
ability.getManaCostsToPay().clear();
ability.getManaCostsToPay().addAll(adjustedCost);