mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
Added card "A Jedi's Fervor" and its abilities and effects
This commit is contained in:
parent
7dca71997a
commit
32ff6ada7b
3 changed files with 147 additions and 1 deletions
|
@ -1,4 +1,98 @@
|
||||||
package mage.cards.a;
|
package mage.cards.a;
|
||||||
|
|
||||||
public class AJedisFervor {
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
|
||||||
|
import mage.abilities.keyword.IndestructibleAbility;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.filter.StaticFilters;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.game.stack.Spell;
|
||||||
|
import mage.target.TargetPermanent;
|
||||||
|
import mage.watchers.common.SpellsCastWatcher;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Merlingilb
|
||||||
|
*/
|
||||||
|
public final class AJedisFervor extends CardImpl {
|
||||||
|
public AJedisFervor(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}");
|
||||||
|
|
||||||
|
// Creatures you control gain indestructible until end of turn.
|
||||||
|
this.getSpellAbility().addEffect(new GainAbilityControlledEffect(
|
||||||
|
IndestructibleAbility.getInstance(), Duration.EndOfTurn,
|
||||||
|
StaticFilters.FILTER_PERMANENT_CREATURES)
|
||||||
|
);
|
||||||
|
|
||||||
|
// If an opponent cast a black spell this turn, that player sacrifices a creature or planeswalker.
|
||||||
|
this.getSpellAbility().addEffect(new AJedisFervorEffect());
|
||||||
|
this.getSpellAbility().addWatcher(new SpellsCastWatcher());
|
||||||
|
}
|
||||||
|
|
||||||
|
private AJedisFervor(final AJedisFervor card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AJedisFervor copy() {
|
||||||
|
return new AJedisFervor(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AJedisFervorEffect extends OneShotEffect {
|
||||||
|
public AJedisFervorEffect() {
|
||||||
|
super(Outcome.Sacrifice);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AJedisFervorEffect(final AJedisFervorEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
|
||||||
|
Set<UUID> opponents = game.getOpponents(source.getControllerId());
|
||||||
|
Set<UUID> opponentsBlack = new HashSet<>();
|
||||||
|
List<UUID> perms = new ArrayList<>();
|
||||||
|
//get opponents that cast a black spell this turn
|
||||||
|
if (watcher != null) {
|
||||||
|
for (UUID opponentId : opponents) {
|
||||||
|
List<Spell> spells = watcher.getSpellsCastThisTurn(opponentId);
|
||||||
|
if (spells != null) {
|
||||||
|
for (Spell spell : spells) {
|
||||||
|
if (spell.getColor(game).isBlack()) {
|
||||||
|
opponentsBlack.add(opponentId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//get that opponents to pick a creature or planeswalker
|
||||||
|
for (UUID opponentId : opponentsBlack) {
|
||||||
|
TargetPermanent target = new TargetPermanent(1, 1,
|
||||||
|
StaticFilters.FILTER_CONTROLLED_PERMANENT_CREATURE_OR_PLANESWALKER, false);
|
||||||
|
game.getPlayer(opponentId).chooseTarget(Outcome.Sacrifice, target, source, game);
|
||||||
|
perms.addAll(target.getTargets());
|
||||||
|
}
|
||||||
|
//sacrifices the picked cards
|
||||||
|
for (UUID permID : perms) {
|
||||||
|
Permanent permanent = game.getPermanent(permID);
|
||||||
|
if (permanent != null) {
|
||||||
|
permanent.sacrifice(source, game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AJedisFervorEffect copy() {
|
||||||
|
return new AJedisFervorEffect(this);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -442,6 +442,12 @@ public final class StaticFilters {
|
||||||
FILTER_CONTROLLED_PERMANENT_LANDS.setLockedFilter(true);
|
FILTER_CONTROLLED_PERMANENT_LANDS.setLockedFilter(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final FilterPermanent FILTER_CONTROLLED_PERMANENT_CREATURE_OR_PLANESWALKER = new FilterControlledCreatureOrPlaneswalkerPermanent("creature or planeswalker you control");
|
||||||
|
|
||||||
|
static {
|
||||||
|
FILTER_CONTROLLED_PERMANENT_CREATURE_OR_PLANESWALKER.setLockedFilter(true);
|
||||||
|
}
|
||||||
|
|
||||||
public static final FilterControlledPermanent FILTER_CONTROLLED_PERMANENT_PLANESWALKER = new FilterControlledPlaneswalkerPermanent("planeswalker you control");
|
public static final FilterControlledPermanent FILTER_CONTROLLED_PERMANENT_PLANESWALKER = new FilterControlledPlaneswalkerPermanent("planeswalker you control");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package mage.filter.common;
|
||||||
|
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.SubType;
|
||||||
|
import mage.filter.predicate.Predicates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class FilterControlledCreatureOrPlaneswalkerPermanent extends FilterControlledPermanent {
|
||||||
|
|
||||||
|
public FilterControlledCreatureOrPlaneswalkerPermanent() {
|
||||||
|
this("creature or planeswalker you control");
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilterControlledCreatureOrPlaneswalkerPermanent(SubType subType) {
|
||||||
|
this(subType, "a " + subType + " creature or a " + subType + " planeswalker");
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilterControlledCreatureOrPlaneswalkerPermanent(SubType subType, String name) {
|
||||||
|
super(name);
|
||||||
|
this.add(Predicates.or(
|
||||||
|
CardType.CREATURE.getPredicate(),
|
||||||
|
CardType.PLANESWALKER.getPredicate()
|
||||||
|
));
|
||||||
|
this.add(subType.getPredicate());
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilterControlledCreatureOrPlaneswalkerPermanent(String name) {
|
||||||
|
super(name);
|
||||||
|
this.add(Predicates.or(
|
||||||
|
CardType.CREATURE.getPredicate(),
|
||||||
|
CardType.PLANESWALKER.getPredicate()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilterControlledCreatureOrPlaneswalkerPermanent(final FilterControlledCreatureOrPlaneswalkerPermanent filter) {
|
||||||
|
super(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FilterControlledCreatureOrPlaneswalkerPermanent copy() {
|
||||||
|
return new FilterControlledCreatureOrPlaneswalkerPermanent(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue