mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 04:09:54 -08:00
Fix for Annihilator where NPE was encountered if attacking a planeswalker
Sarkhand the Mad
This commit is contained in:
parent
42f045a7ff
commit
547afe573c
2 changed files with 218 additions and 0 deletions
212
Mage.Sets/src/mage/sets/riseoftheeldrazi/SarkhantheMad.java
Normal file
212
Mage.Sets/src/mage/sets/riseoftheeldrazi/SarkhantheMad.java
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
* 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 mage.sets.riseoftheeldrazi;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.LoyaltyAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.Token;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author maurer.it_at_gmail.com
|
||||
*/
|
||||
public class SarkhantheMad extends CardImpl<SarkhantheMad> {
|
||||
|
||||
public SarkhantheMad(UUID ownerId) {
|
||||
super(ownerId, 214, "Sarkhan the Mad", Rarity.MYTHIC, new CardType[]{CardType.PLANESWALKER}, "{3}{B}{R}");
|
||||
this.expansionSetCode = "ROE";
|
||||
this.subtype.add("Sarkhan");
|
||||
this.loyalty = new MageInt(7);
|
||||
|
||||
this.color.setBlack(true);
|
||||
this.color.setRed(true);
|
||||
|
||||
this.addAbility(new LoyaltyAbility(new SarkhantheMadRevealAndDrawEffect(), 0));
|
||||
Target targetCreature = new TargetCreaturePermanent();
|
||||
Ability sacAbility = new LoyaltyAbility(new SarkhantheMadSacEffect(), -2);
|
||||
sacAbility.addTarget(targetCreature);
|
||||
this.addAbility(sacAbility);
|
||||
Ability damageAbility = new LoyaltyAbility(new SarkhantheMadDragonDamageEffect(), -4);
|
||||
damageAbility.addTarget(new TargetPlayer());
|
||||
this.addAbility(damageAbility);
|
||||
}
|
||||
|
||||
public SarkhantheMad(final SarkhantheMad card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SarkhantheMad copy() {
|
||||
return new SarkhantheMad(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SarkhantheMadRevealAndDrawEffect extends OneShotEffect<SarkhantheMadRevealAndDrawEffect> {
|
||||
|
||||
private static final String effectText = "Reveal the top card of your library and put it into your hand. Sarkhan the Mad deals damage to himself equal to that card's converted mana cost";
|
||||
|
||||
SarkhantheMadRevealAndDrawEffect ( ) {
|
||||
super(Outcome.DrawCard);
|
||||
}
|
||||
|
||||
SarkhantheMadRevealAndDrawEffect ( SarkhantheMadRevealAndDrawEffect effect ) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||
permanent.damage(card.getManaCost().convertedManaCost(), this.getId(), game, false, false);
|
||||
Cards cards = new CardsImpl();
|
||||
cards.add(card);
|
||||
player.revealCards(cards, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SarkhantheMadRevealAndDrawEffect copy() {
|
||||
return new SarkhantheMadRevealAndDrawEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Ability source) {
|
||||
return effectText;
|
||||
}
|
||||
}
|
||||
|
||||
class SarkhantheMadSacEffect extends OneShotEffect<SarkhantheMadSacEffect> {
|
||||
|
||||
private static final String effectText = "Target creature's controller sacrifices it, then that player puts a 5/5 red Dragon creature token with flying onto the battlefield";
|
||||
|
||||
SarkhantheMadSacEffect ( ) {
|
||||
super(Outcome.Sacrifice);
|
||||
}
|
||||
|
||||
SarkhantheMadSacEffect ( SarkhantheMadSacEffect effect ) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getTargets().getFirstTarget());
|
||||
if ( permanent != null ) {
|
||||
Player player = game.getPlayer(permanent.getControllerId());
|
||||
permanent.sacrifice(this.getId(), game);
|
||||
Token dragonToken = new DragonToken();
|
||||
dragonToken.putOntoBattlefield(game, this.getId(), player.getId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SarkhantheMadSacEffect copy() {
|
||||
return new SarkhantheMadSacEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Ability source) {
|
||||
return effectText;
|
||||
}
|
||||
}
|
||||
|
||||
class SarkhantheMadDragonDamageEffect extends OneShotEffect<SarkhantheMadDragonDamageEffect> {
|
||||
|
||||
private static final String effectText = "Each Dragon creature you control deals damage equal to its power to target player";
|
||||
private static final FilterControlledPermanent filter;
|
||||
|
||||
static {
|
||||
filter = new FilterControlledPermanent();
|
||||
filter.getCardType().add(CardType.CREATURE);
|
||||
filter.getSubtype().add("Dragon");
|
||||
}
|
||||
|
||||
SarkhantheMadDragonDamageEffect ( ) {
|
||||
super(Outcome.Damage);
|
||||
}
|
||||
|
||||
SarkhantheMadDragonDamageEffect ( SarkhantheMadDragonDamageEffect effect ) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
List<Permanent> dragons = game.getBattlefield().getAllActivePermanents(filter);
|
||||
Player player = game.getPlayer(source.getTargets().getFirstTarget());
|
||||
if ( player != null && dragons != null && !dragons.isEmpty() ) {
|
||||
for ( Permanent dragon : dragons ) {
|
||||
player.damage(dragon.getPower().getValue(), dragon.getId(), game, true, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SarkhantheMadDragonDamageEffect copy() {
|
||||
return new SarkhantheMadDragonDamageEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Ability source) {
|
||||
return effectText;
|
||||
}
|
||||
}
|
||||
|
||||
class DragonToken extends mage.game.permanent.token.DragonToken {
|
||||
DragonToken ( ) {
|
||||
super();
|
||||
this.power = new MageInt(5);
|
||||
this.toughness = new MageInt(5);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue