1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-09 01:01:06 -09:00

[SNC] Implemented Grisly Sigil

This commit is contained in:
Evan Kranzler 2022-04-09 19:46:24 -04:00
parent df5cddf157
commit c471ed0ef9
2 changed files with 115 additions and 0 deletions
Mage.Sets/src/mage

View file

@ -0,0 +1,114 @@
package mage.cards.g;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.CasualtyAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.DamagedEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreatureOrPlaneswalker;
import mage.watchers.Watcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class GrislySigil extends CardImpl {
public GrislySigil(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{B}");
// Casualty 1
this.addAbility(new CasualtyAbility(this, 1));
// Choose target creature or planeswalker. If it was dealt noncombat damage this turn, Grisly Sigil deals 3 damage to it and you gain 3 life. Otherwise, Grisly Sigil deals 1 damage to it and you gain 1 life.
this.getSpellAbility().addEffect(new GrislySigilEffect());
this.getSpellAbility().addTarget(new TargetCreatureOrPlaneswalker());
this.getSpellAbility().addWatcher(new GrislySigilWatcher());
}
private GrislySigil(final GrislySigil card) {
super(card);
}
@Override
public GrislySigil copy() {
return new GrislySigil(this);
}
}
class GrislySigilEffect extends OneShotEffect {
GrislySigilEffect() {
super(Outcome.Benefit);
staticText = "choose target creature or planeswalker. If it was dealt noncombat damage this turn, {this} " +
"deals 3 damage to it and you gain 3 life. Otherwise, {this} deals 1 damage to it and you gain 1 life";
}
private GrislySigilEffect(final GrislySigilEffect effect) {
super(effect);
}
@Override
public GrislySigilEffect copy() {
return new GrislySigilEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent == null) {
return false;
}
int amount = GrislySigilWatcher.checkPermanent(permanent, game) ? 3 : 1;
permanent.damage(amount, source, game);
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.gainLife(amount, game, source);
}
return true;
}
}
class GrislySigilWatcher extends Watcher {
private final Set<MageObjectReference> morSet = new HashSet<>();
GrislySigilWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DAMAGED_PERMANENT
&& !((DamagedEvent) event).isCombatDamage()) {
morSet.add(new MageObjectReference(event.getTargetId(), game));
}
}
@Override
public void reset() {
super.reset();
morSet.clear();
}
static boolean checkPermanent(Permanent permanent, Game game) {
return game
.getState()
.getWatcher(GrislySigilWatcher.class)
.morSet
.stream()
.anyMatch(mor -> mor.refersTo(permanent, game));
}
}

View file

@ -45,6 +45,7 @@ public final class StreetsOfNewCapenna extends ExpansionSet {
cards.add(new SetCardInfo("Forest", 270, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Gala Greeters", 148, Rarity.RARE, mage.cards.g.GalaGreeters.class));
cards.add(new SetCardInfo("Getaway Car", 237, Rarity.RARE, mage.cards.g.GetawayCar.class));
cards.add(new SetCardInfo("Grisly Sigil", 82, Rarity.UNCOMMON, mage.cards.g.GrislySigil.class));
cards.add(new SetCardInfo("Halo Fountain", 15, Rarity.MYTHIC, mage.cards.h.HaloFountain.class));
cards.add(new SetCardInfo("Incriminate", 84, Rarity.COMMON, mage.cards.i.Incriminate.class));
cards.add(new SetCardInfo("Island", 264, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS));