[DOM] Added Haphazard Bombardment and Jaya Ballard.

This commit is contained in:
LevelX2 2018-04-19 00:30:13 +02:00
parent b69093dfdd
commit da96ee7b05
8 changed files with 814 additions and 384 deletions

View file

@ -0,0 +1,63 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.mana.builder.common;
import java.util.UUID;
import mage.ConditionalMana;
import mage.MageObject;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.condition.Condition;
import mage.abilities.costs.Cost;
import mage.abilities.mana.builder.ConditionalManaBuilder;
import mage.abilities.mana.conditional.ManaCondition;
import mage.game.Game;
/**
*
* @author LevelX2
*/
public class InstantOrSorcerySpellManaBuilder extends ConditionalManaBuilder {
@Override
public ConditionalMana build(Object... options) {
return new InstantOrSorceryCastConditionalMana(this.mana);
}
@Override
public String getRule() {
return "Spend this mana only to cast an instant or sorcery spell";
}
}
class InstantOrSorceryCastConditionalMana extends ConditionalMana {
public InstantOrSorceryCastConditionalMana(Mana mana) {
super(mana);
staticText = "Spend this mana only to cast an instant or sorcery spell";
addCondition(new InstantOrSorceryCastManaCondition());
}
}
class InstantOrSorceryCastManaCondition extends ManaCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
if (source instanceof SpellAbility) {
MageObject object = game.getObject(source.getSourceId());
if (object != null && (object.isInstant() || object.isSorcery())) {
return true;
}
}
return false;
}
@Override
public boolean apply(Game game, Ability source, UUID originalId, Cost costsToPay) {
return apply(game, source);
}
}

View file

@ -177,6 +177,7 @@ public enum SubType {
// J
JACKAL("Jackal", SubTypeSet.CreatureType),
JAWA("Jawa", SubTypeSet.CreatureType, true),
JAYA("Jaya", SubTypeSet.PlaneswalkerType),
JEDI("Jedi", SubTypeSet.CreatureType, true), // Star Wars
JELLYFISH("Jellyfish", SubTypeSet.CreatureType),
JUGGERNAUT("Juggernaut", SubTypeSet.CreatureType),

View file

@ -0,0 +1,126 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.game.command.emblems;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
import mage.constants.AsThoughEffectType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.command.Emblem;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.players.Player;
import mage.watchers.common.CastFromGraveyardWatcher;
/**
*
* @author LevelX2
*/
public class JayaBallardEmblem extends Emblem {
// You get an emblem with "You may cast instant and sorcery cards from your graveyard. If a card cast this way would be put into your graveyard, exile it instead."
public JayaBallardEmblem() {
setName("Emblem Jaya Ballard");
this.setExpansionSetCodeForImage("DOM");
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new JayaBallardCastFromGraveyardEffect());
ability.addEffect(new JayaBallardReplacementEffect());
this.getAbilities().add(ability);
}
}
class JayaBallardCastFromGraveyardEffect extends AsThoughEffectImpl {
JayaBallardCastFromGraveyardEffect() {
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfGame, Outcome.Benefit);
staticText = "You may cast instant and sorcery cards from your graveyard";
}
JayaBallardCastFromGraveyardEffect(final JayaBallardCastFromGraveyardEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public JayaBallardCastFromGraveyardEffect copy() {
return new JayaBallardCastFromGraveyardEffect(this);
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
Card card = game.getCard(objectId);
if (card != null) {
return (affectedControllerId.equals(source.getControllerId())
&& StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY.match(card, game)
&& Zone.GRAVEYARD.equals(game.getState().getZone(card.getId())));
}
return false;
}
}
class JayaBallardReplacementEffect extends ReplacementEffectImpl {
public JayaBallardReplacementEffect() {
super(Duration.EndOfGame, Outcome.Exile);
staticText = "If a card cast this way would be put into a graveyard this turn, exile it instead";
}
public JayaBallardReplacementEffect(final JayaBallardReplacementEffect effect) {
super(effect);
}
@Override
public JayaBallardReplacementEffect copy() {
return new JayaBallardReplacementEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.STACK, true);
return true;
}
}
return false;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.ZONE_CHANGE;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Card card = game.getCard(event.getSourceId());
if (card.isInstant() || card.isSorcery()) {
// TODO: Find a way to check, that the spell from graveyard was really cast by the ability of the emblem.
// currently every spell cast from graveyard will be exiled.
CastFromGraveyardWatcher watcher = (CastFromGraveyardWatcher) game.getState().getWatchers().get(CastFromGraveyardWatcher.class.getSimpleName());
return watcher != null && watcher.spellWasCastFromGraveyard(event.getTargetId(), game.getState().getZoneChangeCounter(event.getTargetId()));
}
return false;
}
}