mirror of
https://github.com/correl/mage.git
synced 2025-01-14 03:00:10 +00:00
[BRO] Implement One with the Multiverse
This commit is contained in:
parent
d2fa0c4075
commit
ccbd45ea3c
3 changed files with 128 additions and 1 deletions
125
Mage.Sets/src/mage/cards/o/OneWithTheMultiverse.java
Normal file
125
Mage.Sets/src/mage/cards/o/OneWithTheMultiverse.java
Normal file
|
@ -0,0 +1,125 @@
|
|||
package mage.cards.o;
|
||||
|
||||
import mage.MageIdentifier;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.common.continuous.LookAtTopCardOfLibraryAnyTimeEffect;
|
||||
import mage.abilities.effects.common.continuous.PlayTheTopCardEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class OneWithTheMultiverse extends CardImpl {
|
||||
|
||||
public OneWithTheMultiverse(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{6}{U}{U}");
|
||||
|
||||
// You may look at the top card of your library any time.
|
||||
this.addAbility(new SimpleStaticAbility(new LookAtTopCardOfLibraryAnyTimeEffect()));
|
||||
|
||||
// You may play lands and cast spells from the top of your library.
|
||||
this.addAbility(new SimpleStaticAbility(new PlayTheTopCardEffect()));
|
||||
|
||||
// Once during each of your turns, you may cast a spell from your hand or the top of your library without paying its mana cost.
|
||||
this.addAbility(new SimpleStaticAbility(new OneWithTheMultiverseEffect())
|
||||
.setIdentifier(MageIdentifier.OneWithTheMultiverseWatcher), new OneWithTheMultiverseWatcher());
|
||||
}
|
||||
|
||||
private OneWithTheMultiverse(final OneWithTheMultiverse card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OneWithTheMultiverse copy() {
|
||||
return new OneWithTheMultiverse(this);
|
||||
}
|
||||
}
|
||||
|
||||
class OneWithTheMultiverseEffect extends AsThoughEffectImpl {
|
||||
|
||||
public OneWithTheMultiverseEffect() {
|
||||
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.WhileOnBattlefield, Outcome.PlayForFree, true);
|
||||
staticText = "once during each of your turns, you may cast a spell from your hand " +
|
||||
"or the top of your library without paying its mana cost.";
|
||||
}
|
||||
|
||||
private OneWithTheMultiverseEffect(final OneWithTheMultiverseEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OneWithTheMultiverseEffect copy() {
|
||||
return new OneWithTheMultiverseEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (!source.isControlledBy(affectedControllerId) || !game.isActivePlayer(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Card card = game.getCard(CardUtil.getMainCardId(game, objectId));
|
||||
OneWithTheMultiverseWatcher watcher = game.getState().getWatcher(OneWithTheMultiverseWatcher.class);
|
||||
if (controller == null
|
||||
|| card == null
|
||||
|| watcher == null
|
||||
|| watcher.isAbilityUsed(new MageObjectReference(source))
|
||||
|| !card.isOwnedBy(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
Zone zone = game.getState().getZone(card.getId());
|
||||
if (!Zone.HAND.match(zone) &&
|
||||
(!Zone.LIBRARY.match(zone) || !controller.getLibrary().getFromTop(game).getId().equals(card.getId()))) {
|
||||
return false;
|
||||
}
|
||||
allowCardToPlayWithoutMana(objectId, source, affectedControllerId, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class OneWithTheMultiverseWatcher extends Watcher {
|
||||
|
||||
private final Set<MageObjectReference> usedFrom = new HashSet<>();
|
||||
|
||||
public OneWithTheMultiverseWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST
|
||||
&& event.hasApprovingIdentifier(MageIdentifier.OneWithTheMultiverseWatcher)) {
|
||||
usedFrom.add(event.getAdditionalReference().getApprovingMageObjectReference());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
usedFrom.clear();
|
||||
}
|
||||
|
||||
public boolean isAbilityUsed(MageObjectReference mor) {
|
||||
return usedFrom.contains(mor);
|
||||
}
|
||||
}
|
|
@ -204,6 +204,7 @@ public final class TheBrothersWar extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("No One Left Behind", 109, Rarity.UNCOMMON, mage.cards.n.NoOneLeftBehind.class));
|
||||
cards.add(new SetCardInfo("Obliterating Bolt", 145, Rarity.UNCOMMON, mage.cards.o.ObliteratingBolt.class));
|
||||
cards.add(new SetCardInfo("Obstinate Baloth", 187, Rarity.UNCOMMON, mage.cards.o.ObstinateBaloth.class));
|
||||
cards.add(new SetCardInfo("One with the Multiverse", 59, Rarity.MYTHIC, mage.cards.o.OneWithTheMultiverse.class));
|
||||
cards.add(new SetCardInfo("Over the Top", 146, Rarity.RARE, mage.cards.o.OverTheTop.class));
|
||||
cards.add(new SetCardInfo("Overwhelming Remorse", 110, Rarity.COMMON, mage.cards.o.OverwhelmingRemorse.class));
|
||||
cards.add(new SetCardInfo("Painful Quandary", 111, Rarity.RARE, mage.cards.p.PainfulQuandary.class));
|
||||
|
|
|
@ -17,5 +17,6 @@ public enum MageIdentifier {
|
|||
ShareTheSpoilsWatcher,
|
||||
WishWatcher,
|
||||
GlimpseTheCosmosWatcher,
|
||||
SerraParagonWatcher
|
||||
SerraParagonWatcher,
|
||||
OneWithTheMultiverseWatcher
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue