[GRN] Added Thousand-Year Storm.

This commit is contained in:
LevelX2 2018-09-22 17:26:06 +02:00
parent 4928c52204
commit 883751f30c
2 changed files with 125 additions and 0 deletions

View file

@ -0,0 +1,124 @@
package mage.cards.t;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.WatcherScope;
import mage.filter.common.FilterInstantOrSorcerySpell;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.watchers.Watcher;
/**
*
* @author LevelX2
*/
public final class ThousandYearStorm extends CardImpl {
public ThousandYearStorm(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{4}{U}{R}");
// Whenever you cast an instant or sorcery spell, copy it for each other instant and sorcery spell you've cast before it this turn. You may choose new targets for the copies.
this.addAbility(new SpellCastControllerTriggeredAbility(
new ThousandYearStormEffect(), new FilterInstantOrSorcerySpell(), false, true
), new ThousandYearWatcher());
}
public ThousandYearStorm(final ThousandYearStorm card) {
super(card);
}
@Override
public ThousandYearStorm copy() {
return new ThousandYearStorm(this);
}
}
class ThousandYearStormEffect extends OneShotEffect {
public ThousandYearStormEffect() {
super(Outcome.Benefit);
this.staticText = "copy it for each other instant and sorcery spell you've cast before it this turn. You may choose new targets for the copies";
}
public ThousandYearStormEffect(final ThousandYearStormEffect effect) {
super(effect);
}
@Override
public ThousandYearStormEffect copy() {
return new ThousandYearStormEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getSpellOrLKIStack(getTargetPointer().getFirst(game, source));
if (spell != null) {
ThousandYearWatcher watcher = (ThousandYearWatcher) game.getState().getWatchers().get(ThousandYearWatcher.class.getSimpleName());
if (watcher != null) {
int numberOfCopies = watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) - 1;
if (numberOfCopies > 0) {
for (int i = 0; i < numberOfCopies; i++) {
spell.createCopyOnStack(game, source, source.getControllerId(), true);
}
}
return true;
}
}
return false;
}
}
class ThousandYearWatcher extends Watcher {
private final Map<UUID, Integer> amountOfInstantSorcerySpellsCastOnCurrentTurn = new HashMap<>();
public ThousandYearWatcher() {
super(ThousandYearWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public ThousandYearWatcher(final ThousandYearWatcher watcher) {
super(watcher);
for (Entry<UUID, Integer> entry : watcher.amountOfInstantSorcerySpellsCastOnCurrentTurn.entrySet()) {
amountOfInstantSorcerySpellsCastOnCurrentTurn.put(entry.getKey(), entry.getValue());
}
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
Spell spell = game.getSpellOrLKIStack(event.getTargetId());
if (spell != null && spell.isInstantOrSorcery()) {
UUID playerId = event.getPlayerId();
if (playerId != null) {
amountOfInstantSorcerySpellsCastOnCurrentTurn.putIfAbsent(playerId, 0);
amountOfInstantSorcerySpellsCastOnCurrentTurn.compute(playerId, (k, a) -> a + 1);
}
}
}
}
@Override
public void reset() {
amountOfInstantSorcerySpellsCastOnCurrentTurn.clear();
}
public int getAmountOfSpellsPlayerCastOnCurrentTurn(UUID playerId) {
return amountOfInstantSorcerySpellsCastOnCurrentTurn.getOrDefault(playerId, 0);
}
@Override
public ThousandYearWatcher copy() {
return new ThousandYearWatcher(this);
}
}

View file

@ -262,6 +262,7 @@ public final class GuildsOfRavnica extends ExpansionSet {
cards.add(new SetCardInfo("Thief of Sanity", 205, Rarity.RARE, mage.cards.t.ThiefOfSanity.class));
cards.add(new SetCardInfo("Thought Erasure", 206, Rarity.UNCOMMON, mage.cards.t.ThoughtErasure.class));
cards.add(new SetCardInfo("Thoughtbound Phantasm", 55, Rarity.UNCOMMON, mage.cards.t.ThoughtboundPhantasm.class));
cards.add(new SetCardInfo("Thousand-Year Storm", 207, Rarity.MYTHIC, mage.cards.t.ThousandYearStorm.class));
cards.add(new SetCardInfo("Torch Courier", 119, Rarity.COMMON, mage.cards.t.TorchCourier.class));
cards.add(new SetCardInfo("Trostani Discordant", 208, Rarity.MYTHIC, mage.cards.t.TrostaniDiscordant.class));
cards.add(new SetCardInfo("Truefire Captain", 209, Rarity.UNCOMMON, mage.cards.t.TruefireCaptain.class));