mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
[EOE] Implement Weftwalking
This commit is contained in:
parent
06cdd63b10
commit
c0ed0197ad
4 changed files with 157 additions and 62 deletions
|
|
@ -1,29 +1,25 @@
|
||||||
package mage.cards.m;
|
package mage.cards.m;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
|
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
|
||||||
import mage.abilities.effects.common.ExileSourceEffect;
|
import mage.abilities.effects.common.ExileSourceEffect;
|
||||||
|
import mage.abilities.effects.common.ShuffleHandGraveyardIntoLibraryEffect;
|
||||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||||
import mage.abilities.mana.BlueManaAbility;
|
import mage.abilities.mana.BlueManaAbility;
|
||||||
|
import mage.abilities.triggers.BeginningOfUpkeepTriggeredAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.cards.Cards;
|
|
||||||
import mage.cards.CardsImpl;
|
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.TargetController;
|
import mage.constants.TargetController;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -64,7 +60,10 @@ public final class MidnightClock extends CardImpl {
|
||||||
class MidnightClockTriggeredAbility extends TriggeredAbilityImpl {
|
class MidnightClockTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
MidnightClockTriggeredAbility() {
|
MidnightClockTriggeredAbility() {
|
||||||
super(Zone.ALL, new MidnightClockEffect(), false);
|
super(Zone.ALL, new ShuffleHandGraveyardIntoLibraryEffect(), false);
|
||||||
|
this.addEffect(new DrawCardSourceControllerEffect(7).concatBy(", then"));
|
||||||
|
this.addEffect(new ExileSourceEffect());
|
||||||
|
this.setTriggerPhrase("When the twelfth hour counter is put on {this}, ");
|
||||||
}
|
}
|
||||||
|
|
||||||
private MidnightClockTriggeredAbility(final MidnightClockTriggeredAbility ability) {
|
private MidnightClockTriggeredAbility(final MidnightClockTriggeredAbility ability) {
|
||||||
|
|
@ -78,64 +77,24 @@ class MidnightClockTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getTargetId().equals(getSourceId())
|
if (!event.getTargetId().equals(getSourceId()) || !event.getData().equals(CounterType.HOUR.getName())) {
|
||||||
&& event.getData().equals(CounterType.HOUR.getName())) {
|
return false;
|
||||||
int amountAdded = event.getAmount();
|
|
||||||
int hourCounters = amountAdded;
|
|
||||||
Permanent sourcePermanent = game.getPermanent(getSourceId());
|
|
||||||
if (sourcePermanent == null) {
|
|
||||||
sourcePermanent = game.getPermanentEntering(getSourceId());
|
|
||||||
}
|
|
||||||
if (sourcePermanent != null) {
|
|
||||||
hourCounters = sourcePermanent.getCounters(game).getCount(CounterType.HOUR);
|
|
||||||
}
|
|
||||||
return hourCounters - amountAdded < 12
|
|
||||||
&& 12 <= hourCounters;
|
|
||||||
}
|
}
|
||||||
return false;
|
int amountAdded = event.getAmount();
|
||||||
|
Permanent sourcePermanent = Optional
|
||||||
|
.ofNullable(game.getPermanent(getSourceId()))
|
||||||
|
.orElse(game.getPermanentEntering(getSourceId()));
|
||||||
|
int hourCounters;
|
||||||
|
if (sourcePermanent != null) {
|
||||||
|
hourCounters = sourcePermanent.getCounters(game).getCount(CounterType.HOUR);
|
||||||
|
} else {
|
||||||
|
hourCounters = amountAdded;
|
||||||
|
}
|
||||||
|
return hourCounters - amountAdded < 12 && 12 <= hourCounters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MidnightClockTriggeredAbility copy() {
|
public MidnightClockTriggeredAbility copy() {
|
||||||
return new MidnightClockTriggeredAbility(this);
|
return new MidnightClockTriggeredAbility(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
return "When the twelfth hour counter is put on {this}, " +
|
|
||||||
"shuffle your hand and graveyard into your library, " +
|
|
||||||
"then draw seven cards. Exile {this}.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MidnightClockEffect extends OneShotEffect {
|
|
||||||
|
|
||||||
private static final Effect effect = new ExileSourceEffect();
|
|
||||||
|
|
||||||
MidnightClockEffect() {
|
|
||||||
super(Outcome.Benefit);
|
|
||||||
}
|
|
||||||
|
|
||||||
private MidnightClockEffect(final MidnightClockEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MidnightClockEffect copy() {
|
|
||||||
return new MidnightClockEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
|
||||||
if (player == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Cards cards = new CardsImpl(player.getHand());
|
|
||||||
cards.addAll(player.getGraveyard());
|
|
||||||
player.putCardsOnTopOfLibrary(cards, game, source, false);
|
|
||||||
player.shuffleLibrary(source, game);
|
|
||||||
player.drawCards(7, source, game);
|
|
||||||
return effect.apply(game, source);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
95
Mage.Sets/src/mage/cards/w/Weftwalking.java
Normal file
95
Mage.Sets/src/mage/cards/w/Weftwalking.java
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
package mage.cards.w;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||||
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
import mage.abilities.condition.Condition;
|
||||||
|
import mage.abilities.condition.common.CastFromEverywhereSourceCondition;
|
||||||
|
import mage.abilities.costs.AlternativeCostSourceAbility;
|
||||||
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
|
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||||
|
import mage.abilities.effects.common.ShuffleHandGraveyardIntoLibraryEffect;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.*;
|
||||||
|
import mage.filter.StaticFilters;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.players.Player;
|
||||||
|
import mage.watchers.common.SpellsCastWatcher;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public final class Weftwalking extends CardImpl {
|
||||||
|
|
||||||
|
public Weftwalking(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{4}{U}{U}");
|
||||||
|
|
||||||
|
// When this enchantment enters, if you cast it, shuffle your hand and graveyard into your library, then draw seven cards.
|
||||||
|
Ability ability = new EntersBattlefieldTriggeredAbility(new ShuffleHandGraveyardIntoLibraryEffect())
|
||||||
|
.withInterveningIf(CastFromEverywhereSourceCondition.instance);
|
||||||
|
ability.addEffect(new DrawCardSourceControllerEffect(7).concatBy(", then"));
|
||||||
|
this.addAbility(ability);
|
||||||
|
|
||||||
|
// The first spell each player casts during each of their turns may be cast without paying its mana cost.
|
||||||
|
this.addAbility(new SimpleStaticAbility(new WeftwalkingEffect()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Weftwalking(final Weftwalking card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Weftwalking copy() {
|
||||||
|
return new Weftwalking(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class WeftwalkingEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
|
private enum WeftwalkingCondition implements Condition {
|
||||||
|
instance;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
return game
|
||||||
|
.getState()
|
||||||
|
.getWatcher(SpellsCastWatcher.class)
|
||||||
|
.getSpellsCastThisTurn(game.getActivePlayerId())
|
||||||
|
.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final AlternativeCostSourceAbility alternativeCastingCostAbility;
|
||||||
|
|
||||||
|
WeftwalkingEffect() {
|
||||||
|
super(Duration.WhileOnBattlefield, Layer.RulesEffects, SubLayer.NA, Outcome.PlayForFree);
|
||||||
|
this.alternativeCastingCostAbility = new AlternativeCostSourceAbility(
|
||||||
|
null, WeftwalkingCondition.instance, null, StaticFilters.FILTER_CARD_NON_LAND, true
|
||||||
|
);
|
||||||
|
staticText = "the first spell each player casts during each of their turns may be cast without paying its mana cost";
|
||||||
|
}
|
||||||
|
|
||||||
|
private WeftwalkingEffect(final WeftwalkingEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
this.alternativeCastingCostAbility = effect.alternativeCastingCostAbility;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WeftwalkingEffect copy() {
|
||||||
|
return new WeftwalkingEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Player player = game.getPlayer(game.getActivePlayerId());
|
||||||
|
if (player == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
alternativeCastingCostAbility.setSourceId(source.getSourceId());
|
||||||
|
player.getAlternativeSourceCosts().add(alternativeCastingCostAbility);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -243,6 +243,7 @@ public final class EdgeOfEternities extends ExpansionSet {
|
||||||
cards.add(new SetCardInfo("Weapons Manufacturing", 168, Rarity.RARE, mage.cards.w.WeaponsManufacturing.class, NON_FULL_USE_VARIOUS));
|
cards.add(new SetCardInfo("Weapons Manufacturing", 168, Rarity.RARE, mage.cards.w.WeaponsManufacturing.class, NON_FULL_USE_VARIOUS));
|
||||||
cards.add(new SetCardInfo("Weapons Manufacturing", 311, Rarity.RARE, mage.cards.w.WeaponsManufacturing.class, NON_FULL_USE_VARIOUS));
|
cards.add(new SetCardInfo("Weapons Manufacturing", 311, Rarity.RARE, mage.cards.w.WeaponsManufacturing.class, NON_FULL_USE_VARIOUS));
|
||||||
cards.add(new SetCardInfo("Weftstalker Ardent", 169, Rarity.UNCOMMON, mage.cards.w.WeftstalkerArdent.class));
|
cards.add(new SetCardInfo("Weftstalker Ardent", 169, Rarity.UNCOMMON, mage.cards.w.WeftstalkerArdent.class));
|
||||||
|
cards.add(new SetCardInfo("Weftwalking", 86, Rarity.MYTHIC, mage.cards.w.Weftwalking.class));
|
||||||
cards.add(new SetCardInfo("Wurmwall Sweeper", 249, Rarity.COMMON, mage.cards.w.WurmwallSweeper.class));
|
cards.add(new SetCardInfo("Wurmwall Sweeper", 249, Rarity.COMMON, mage.cards.w.WurmwallSweeper.class));
|
||||||
cards.add(new SetCardInfo("Zero Point Ballad", 335, Rarity.RARE, mage.cards.z.ZeroPointBallad.class));
|
cards.add(new SetCardInfo("Zero Point Ballad", 335, Rarity.RARE, mage.cards.z.ZeroPointBallad.class));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package mage.abilities.effects.common;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.cards.Cards;
|
||||||
|
import mage.cards.CardsImpl;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public class ShuffleHandGraveyardIntoLibraryEffect extends OneShotEffect {
|
||||||
|
|
||||||
|
public ShuffleHandGraveyardIntoLibraryEffect() {
|
||||||
|
super(Outcome.Discard);
|
||||||
|
this.staticText = "shuffle your hand and graveyard into your library";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ShuffleHandGraveyardIntoLibraryEffect(final ShuffleHandGraveyardIntoLibraryEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ShuffleHandGraveyardIntoLibraryEffect copy() {
|
||||||
|
return new ShuffleHandGraveyardIntoLibraryEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
|
if (player == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Cards cards = new CardsImpl(player.getHand());
|
||||||
|
cards.addAll(player.getGraveyard());
|
||||||
|
return player.shuffleCardsToLibrary(cards, game, source);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue