mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
3 SOM - Psychic Miasma, Cerebral Eruption, Furnace Celebration
This commit is contained in:
parent
f13c81398d
commit
6513202c17
11 changed files with 472 additions and 30 deletions
140
Mage.Sets/src/mage/sets/scarsofmirrodin/CerebralEruption.java
Normal file
140
Mage.Sets/src/mage/sets/scarsofmirrodin/CerebralEruption.java
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2011 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 mage.sets.scarsofmirrodin;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.Constants.CardType;
|
||||||
|
import mage.Constants.Outcome;
|
||||||
|
import mage.Constants.Rarity;
|
||||||
|
import mage.Constants.Zone;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.PostResolveEffect;
|
||||||
|
import mage.cards.Card;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.Cards;
|
||||||
|
import mage.cards.CardsImpl;
|
||||||
|
import mage.filter.FilterPermanent;
|
||||||
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.players.Player;
|
||||||
|
import mage.target.common.TargetOpponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
*/
|
||||||
|
public class CerebralEruption extends CardImpl<CerebralEruption> {
|
||||||
|
|
||||||
|
public CerebralEruption(UUID ownerId) {
|
||||||
|
super(ownerId, 86, "Cerebral Eruption", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{R}{R}");
|
||||||
|
this.expansionSetCode = "SOM";
|
||||||
|
this.color.setRed(true);
|
||||||
|
this.getSpellAbility().addTarget(new TargetOpponent());
|
||||||
|
this.getSpellAbility().addEffect(new CerebralEruptionEffect1());
|
||||||
|
this.getSpellAbility().addEffect(new CerebralEruptionEffect2());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CerebralEruption(final CerebralEruption card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CerebralEruption copy() {
|
||||||
|
return new CerebralEruption(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class CerebralEruptionEffect1 extends OneShotEffect<CerebralEruptionEffect1> {
|
||||||
|
|
||||||
|
private static FilterPermanent filter = new FilterCreaturePermanent();
|
||||||
|
|
||||||
|
public CerebralEruptionEffect1() {
|
||||||
|
super(Outcome.Damage);
|
||||||
|
staticText = "Target opponent reveals the top card of his or her library. {this} deals damage equal to the revealed card's converted mana cost to that player and each creature he or she controls.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public CerebralEruptionEffect1(final CerebralEruptionEffect1 effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Player player = game.getPlayer(source.getFirstTarget());
|
||||||
|
if (player != null && player.getLibrary().size() > 0) {
|
||||||
|
Card card = player.getLibrary().getFromTop(game);
|
||||||
|
Cards cards = new CardsImpl();
|
||||||
|
cards.add(card);
|
||||||
|
player.revealCards("Cerebral Eruption", cards, game);
|
||||||
|
game.getState().setValue(source.getId().toString(), card);
|
||||||
|
int damage = card.getManaCost().convertedManaCost();
|
||||||
|
player.damage(damage, source.getId(), game, false, true);
|
||||||
|
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId())) {
|
||||||
|
perm.damage(damage, source.getId(), game, true, false);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CerebralEruptionEffect1 copy() {
|
||||||
|
return new CerebralEruptionEffect1(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class CerebralEruptionEffect2 extends PostResolveEffect<CerebralEruptionEffect2> {
|
||||||
|
|
||||||
|
public CerebralEruptionEffect2() {
|
||||||
|
staticText = "If a land card is revealed this way, return {this} to its owner's hand";
|
||||||
|
}
|
||||||
|
|
||||||
|
public CerebralEruptionEffect2(final CerebralEruptionEffect2 effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||||
|
Card revealed = (Card) game.getState().getValue(source.getId().toString());
|
||||||
|
if (revealed != null && revealed.getCardType().contains(CardType.LAND)) {
|
||||||
|
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
card.moveToZone(Zone.GRAVEYARD, source.getId(), game, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CerebralEruptionEffect2 copy() {
|
||||||
|
return new CerebralEruptionEffect2(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2011 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 mage.sets.scarsofmirrodin;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.Constants.CardType;
|
||||||
|
import mage.Constants.Rarity;
|
||||||
|
import mage.Constants.Zone;
|
||||||
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
|
import mage.abilities.effects.common.DamageTargetEffect;
|
||||||
|
import mage.abilities.effects.common.DoIfCostPaid;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.target.common.TargetCreatureOrPlayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
*/
|
||||||
|
public class FurnaceCelebration extends CardImpl<FurnaceCelebration> {
|
||||||
|
|
||||||
|
public FurnaceCelebration(UUID ownerId) {
|
||||||
|
super(ownerId, 90, "Furnace Celebration", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}{R}");
|
||||||
|
this.expansionSetCode = "SOM";
|
||||||
|
this.color.setRed(true);
|
||||||
|
this.addAbility(new FurnaceCelebrationAbility());
|
||||||
|
}
|
||||||
|
|
||||||
|
public FurnaceCelebration(final FurnaceCelebration card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FurnaceCelebration copy() {
|
||||||
|
return new FurnaceCelebration(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class FurnaceCelebrationAbility extends TriggeredAbilityImpl<FurnaceCelebrationAbility> {
|
||||||
|
|
||||||
|
public FurnaceCelebrationAbility() {
|
||||||
|
super(Zone.BATTLEFIELD, new DoIfCostPaid(new DamageTargetEffect(2), new ManaCostsImpl("{2}")));
|
||||||
|
this.addTarget(new TargetCreatureOrPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public FurnaceCelebrationAbility(final FurnaceCelebrationAbility ability) {
|
||||||
|
super(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FurnaceCelebrationAbility copy() {
|
||||||
|
return new FurnaceCelebrationAbility(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
|
if (event.getType() == GameEvent.EventType.SACRIFICED_PERMANENT && event.getPlayerId().equals(this.getControllerId()) && !event.getTargetId().equals(sourceId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRule() {
|
||||||
|
return "Whenever you sacrifice another permanent, " + super.getRule();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
132
Mage.Sets/src/mage/sets/scarsofmirrodin/PsychicMiasma.java
Normal file
132
Mage.Sets/src/mage/sets/scarsofmirrodin/PsychicMiasma.java
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2011 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 mage.sets.scarsofmirrodin;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.Constants.CardType;
|
||||||
|
import mage.Constants.Outcome;
|
||||||
|
import mage.Constants.Rarity;
|
||||||
|
import mage.Constants.Zone;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.PostResolveEffect;
|
||||||
|
import mage.cards.Card;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.players.Player;
|
||||||
|
import mage.target.TargetPlayer;
|
||||||
|
import mage.target.common.TargetDiscard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
*/
|
||||||
|
public class PsychicMiasma extends CardImpl<PsychicMiasma> {
|
||||||
|
|
||||||
|
public PsychicMiasma(UUID ownerId) {
|
||||||
|
super(ownerId, 76, "Psychic Miasma", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{1}{B}");
|
||||||
|
this.expansionSetCode = "SOM";
|
||||||
|
this.color.setBlack(true);
|
||||||
|
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||||
|
PsychicMiasmaEffect1 effect1 = new PsychicMiasmaEffect1();
|
||||||
|
this.getSpellAbility().addEffect(effect1);
|
||||||
|
this.getSpellAbility().addEffect(new PsychicMiasmaEffect2());
|
||||||
|
}
|
||||||
|
|
||||||
|
public PsychicMiasma(final PsychicMiasma card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PsychicMiasma copy() {
|
||||||
|
return new PsychicMiasma(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class PsychicMiasmaEffect1 extends OneShotEffect<PsychicMiasmaEffect1> {
|
||||||
|
|
||||||
|
public PsychicMiasmaEffect1() {
|
||||||
|
super(Outcome.Discard);
|
||||||
|
staticText = "Target player discards a card.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public PsychicMiasmaEffect1(final PsychicMiasmaEffect1 effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Player player = game.getPlayer(targetPointer.getFirst(source));
|
||||||
|
if (player != null) {
|
||||||
|
TargetDiscard target = new TargetDiscard(player.getId());
|
||||||
|
player.choose(Outcome.Discard, target, game);
|
||||||
|
Card card = player.getHand().get(target.getFirstTarget(), game);
|
||||||
|
if (card != null) {
|
||||||
|
player.discard(card, source, game);
|
||||||
|
game.getState().setValue(source.getId().toString(), card);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PsychicMiasmaEffect1 copy() {
|
||||||
|
return new PsychicMiasmaEffect1(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class PsychicMiasmaEffect2 extends PostResolveEffect<PsychicMiasmaEffect2> {
|
||||||
|
|
||||||
|
public PsychicMiasmaEffect2() {
|
||||||
|
staticText = "If a land card is discarded this way, return {this} to its owner's hand.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public PsychicMiasmaEffect2(final PsychicMiasmaEffect2 effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PsychicMiasmaEffect2 copy() {
|
||||||
|
return new PsychicMiasmaEffect2(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||||
|
Card discard = (Card) game.getState().getValue(source.getId().toString());
|
||||||
|
if (discard != null && discard.getCardType().contains(CardType.LAND)) {
|
||||||
|
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
card.moveToZone(Zone.GRAVEYARD, source.getId(), game, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -47,6 +47,7 @@ import mage.abilities.effects.ContinuousEffect;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.Effects;
|
import mage.abilities.effects.Effects;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.PostResolveEffect;
|
||||||
import mage.choices.Choice;
|
import mage.choices.Choice;
|
||||||
import mage.choices.Choices;
|
import mage.choices.Choices;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -134,6 +135,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
||||||
if (checkIfClause(game)) {
|
if (checkIfClause(game)) {
|
||||||
for (Effect effect: getEffects()) {
|
for (Effect effect: getEffects()) {
|
||||||
if (effect instanceof OneShotEffect) {
|
if (effect instanceof OneShotEffect) {
|
||||||
|
if (!(effect instanceof PostResolveEffect))
|
||||||
result &= effect.apply(game, this);
|
result &= effect.apply(game, this);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
57
Mage/src/mage/abilities/effects/PostResolveEffect.java
Normal file
57
Mage/src/mage/abilities/effects/PostResolveEffect.java
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2011 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 mage.abilities.effects;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.Constants.Outcome;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.cards.Card;
|
||||||
|
import mage.game.Game;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
*/
|
||||||
|
public abstract class PostResolveEffect<T extends PostResolveEffect<T>> extends OneShotEffect<T> {
|
||||||
|
|
||||||
|
public PostResolveEffect() {
|
||||||
|
super(Outcome.Neutral);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PostResolveEffect(final PostResolveEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void postResolve(Card card, Ability source, UUID controllerId, Game game);
|
||||||
|
|
||||||
|
}
|
|
@ -29,16 +29,19 @@
|
||||||
package mage.abilities.effects.common;
|
package mage.abilities.effects.common;
|
||||||
|
|
||||||
import java.io.ObjectStreamException;
|
import java.io.ObjectStreamException;
|
||||||
|
import java.util.UUID;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.PostResolveEffect;
|
||||||
|
import mage.cards.Card;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class ExileSpellEffect extends OneShotEffect<ExileSpellEffect> {
|
public class ExileSpellEffect extends PostResolveEffect<ExileSpellEffect> {
|
||||||
|
|
||||||
private static final ExileSpellEffect fINSTANCE = new ExileSpellEffect();
|
private static final ExileSpellEffect fINSTANCE = new ExileSpellEffect();
|
||||||
|
|
||||||
|
@ -47,7 +50,6 @@ public class ExileSpellEffect extends OneShotEffect<ExileSpellEffect> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExileSpellEffect() {
|
private ExileSpellEffect() {
|
||||||
super(Outcome.Exile);
|
|
||||||
staticText = "Exile {this}";
|
staticText = "Exile {this}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,14 +57,13 @@ public class ExileSpellEffect extends OneShotEffect<ExileSpellEffect> {
|
||||||
return fINSTANCE;
|
return fINSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
//this effect is applied when a spell resolves - see Spell.java
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExileSpellEffect copy() {
|
public ExileSpellEffect copy() {
|
||||||
return fINSTANCE;
|
return fINSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||||
|
game.getExile().getPermanentExile().add(card);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
package mage.abilities.effects.common;
|
package mage.abilities.effects.common;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.cards.Card;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
||||||
import java.io.ObjectStreamException;
|
import java.io.ObjectStreamException;
|
||||||
|
import mage.Constants.Zone;
|
||||||
|
import mage.abilities.effects.PostResolveEffect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Loki
|
* @author Loki
|
||||||
*/
|
*/
|
||||||
public class ReturnToHandSpellEffect extends OneShotEffect<ReturnToHandSpellEffect> {
|
public class ReturnToHandSpellEffect extends PostResolveEffect<ReturnToHandSpellEffect> {
|
||||||
private static final ReturnToHandSpellEffect fINSTANCE = new ReturnToHandSpellEffect();
|
private static final ReturnToHandSpellEffect fINSTANCE = new ReturnToHandSpellEffect();
|
||||||
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
private Object readResolve() throws ObjectStreamException {
|
||||||
|
@ -19,7 +23,6 @@ public class ReturnToHandSpellEffect extends OneShotEffect<ReturnToHandSpellEffe
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReturnToHandSpellEffect() {
|
private ReturnToHandSpellEffect() {
|
||||||
super(Constants.Outcome.Exile);
|
|
||||||
staticText = "Return {this} into its owner's hand";
|
staticText = "Return {this} into its owner's hand";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +32,6 @@ public class ReturnToHandSpellEffect extends OneShotEffect<ReturnToHandSpellEffe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
//this effect is applied when a spell resolves - see Spell.java
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,5 +39,10 @@ public class ReturnToHandSpellEffect extends OneShotEffect<ReturnToHandSpellEffe
|
||||||
public ReturnToHandSpellEffect copy() {
|
public ReturnToHandSpellEffect copy() {
|
||||||
return fINSTANCE;
|
return fINSTANCE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||||
|
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,15 +31,20 @@ package mage.abilities.effects.common;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.cards.Card;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
||||||
import java.io.ObjectStreamException;
|
import java.io.ObjectStreamException;
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.Constants.Zone;
|
||||||
|
import mage.abilities.effects.PostResolveEffect;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
*/
|
*/
|
||||||
public class ShuffleSpellEffect extends OneShotEffect<ShuffleSpellEffect> {
|
public class ShuffleSpellEffect extends PostResolveEffect<ShuffleSpellEffect> {
|
||||||
|
|
||||||
private static final ShuffleSpellEffect fINSTANCE = new ShuffleSpellEffect();
|
private static final ShuffleSpellEffect fINSTANCE = new ShuffleSpellEffect();
|
||||||
|
|
||||||
|
@ -48,7 +53,6 @@ public class ShuffleSpellEffect extends OneShotEffect<ShuffleSpellEffect> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ShuffleSpellEffect() {
|
private ShuffleSpellEffect() {
|
||||||
super(Outcome.Exile);
|
|
||||||
staticText = "Shuffle {this} into its owner's library";
|
staticText = "Shuffle {this} into its owner's library";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +62,6 @@ public class ShuffleSpellEffect extends OneShotEffect<ShuffleSpellEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
//this effect is applied when a spell resolves - see Spell.java
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,4 +69,11 @@ public class ShuffleSpellEffect extends OneShotEffect<ShuffleSpellEffect> {
|
||||||
public ShuffleSpellEffect copy() {
|
public ShuffleSpellEffect copy() {
|
||||||
return fINSTANCE;
|
return fINSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||||
|
card.moveToZone(Zone.LIBRARY, source.getId(), game, false);
|
||||||
|
Player player = game.getPlayer(card.getOwnerId());
|
||||||
|
if (player != null) player.shuffleLibrary(game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,6 @@ package mage.game.stack;
|
||||||
|
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.effects.common.ReturnToHandSpellEffect;
|
|
||||||
import mage.abilities.effects.common.ShuffleSpellEffect;
|
|
||||||
import mage.game.*;
|
import mage.game.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -45,7 +43,8 @@ import mage.abilities.Abilities;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.costs.mana.ManaCost;
|
import mage.abilities.costs.mana.ManaCost;
|
||||||
import mage.abilities.costs.mana.ManaCosts;
|
import mage.abilities.costs.mana.ManaCosts;
|
||||||
import mage.abilities.effects.common.ExileSpellEffect;
|
import mage.abilities.effects.Effect;
|
||||||
|
import mage.abilities.effects.PostResolveEffect;
|
||||||
import mage.abilities.keyword.KickerAbility;
|
import mage.abilities.keyword.KickerAbility;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
@ -88,18 +87,14 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
||||||
result = true;
|
result = true;
|
||||||
|
|
||||||
if (!copiedSpell) {
|
if (!copiedSpell) {
|
||||||
if (ability.getEffects().contains(ExileSpellEffect.getInstance()))
|
for (Effect effect: ability.getEffects()) {
|
||||||
game.getExile().getPermanentExile().add(card);
|
if (effect instanceof PostResolveEffect) {
|
||||||
else if (ability.getEffects().contains(ShuffleSpellEffect.getInstance())) {
|
((PostResolveEffect)effect).postResolve(card, ability, controllerId, game);
|
||||||
card.moveToZone(Zone.LIBRARY, ability.getId(), game, false);
|
return result;
|
||||||
Player player = game.getPlayer(controllerId);
|
|
||||||
if (player != null) player.shuffleLibrary(game);
|
|
||||||
} else if (ability.getEffects().contains(ReturnToHandSpellEffect.getInstance())) {
|
|
||||||
card.moveToZone(Zone.HAND, ability.getId(), game, false);
|
|
||||||
} else {
|
|
||||||
card.moveToZone(Zone.GRAVEYARD, ability.getId(), game, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
card.moveToZone(Zone.GRAVEYARD, ability.getId(), game, false);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,6 +343,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
//20100716 - 701.7
|
//20100716 - 701.7
|
||||||
removeFromHand(card, game);
|
removeFromHand(card, game);
|
||||||
card.moveToZone(Zone.GRAVEYARD, source==null?null:source.getId(), game, false);
|
card.moveToZone(Zone.GRAVEYARD, source==null?null:source.getId(), game, false);
|
||||||
|
|
||||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DISCARDED_CARD, card.getId(), source==null?null:source.getId(), playerId));
|
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.DISCARDED_CARD, card.getId(), source==null?null:source.getId(), playerId));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue