Merge pull request #5631 from ketsuban/benevolent-unicorn

Implement Benevolent Unicorn
This commit is contained in:
Oleg Agafonov 2019-03-14 16:47:24 +01:00 committed by GitHub
commit a969fc8470
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 92 additions and 0 deletions

View file

@ -0,0 +1,91 @@
package mage.cards.b;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
/**
*
* @author LoneFox, Ketsuban
*/
public final class BenevolentUnicorn extends CardImpl {
public BenevolentUnicorn(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}");
this.subtype.add(SubType.UNICORN);
this.power = new MageInt(1);
this.toughness = new MageInt(2);
// If a spell would deal damage to a permanent or player, it deals that much damage minus 1 to that permanent or player instead.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BenevolentUnicornEffect()));
}
public BenevolentUnicorn(final BenevolentUnicorn card) {
super(card);
}
@Override
public BenevolentUnicorn copy() {
return new BenevolentUnicorn(this);
}
}
class BenevolentUnicornEffect extends ReplacementEffectImpl {
public BenevolentUnicornEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "If a spell would deal damage to a permanent or player, it deals that much damage minus 1 to that permanent or player instead.";
}
public BenevolentUnicornEffect(final BenevolentUnicornEffect effect) {
super(effect);
}
@Override
public BenevolentUnicornEffect copy() {
return new BenevolentUnicornEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
event.setAmount(event.getAmount() - 1);
return false;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.DAMAGE_CREATURE || event.getType() == EventType.DAMAGE_PLANESWALKER || event.getType() == EventType.DAMAGE_PLAYER;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
if (stackObject == null) {
stackObject = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK);
}
return stackObject instanceof Spell;
}
}

View file

@ -45,6 +45,7 @@ public final class Mirage extends ExpansionSet {
cards.add(new SetCardInfo("Barbed-Back Wurm", 105, Rarity.UNCOMMON, mage.cards.b.BarbedBackWurm.class));
cards.add(new SetCardInfo("Bay Falcon", 54, Rarity.COMMON, mage.cards.b.BayFalcon.class));
cards.add(new SetCardInfo("Bazaar of Wonders", 55, Rarity.RARE, mage.cards.b.BazaarOfWonders.class));
cards.add(new SetCardInfo("Benevolent Unicorn", 4, Rarity.COMMON, mage.cards.b.BenevolentUnicorn.class));
cards.add(new SetCardInfo("Benthic Djinn", 257, Rarity.RARE, mage.cards.b.BenthicDjinn.class));
cards.add(new SetCardInfo("Binding Agony", 106, Rarity.COMMON, mage.cards.b.BindingAgony.class));
cards.add(new SetCardInfo("Blighted Shaman", 107, Rarity.UNCOMMON, mage.cards.b.BlightedShaman.class));