mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Implemented Echo Storm
This commit is contained in:
parent
29c5936075
commit
2d23d5c84e
3 changed files with 144 additions and 0 deletions
36
Mage.Sets/src/mage/cards/e/EchoStorm.java
Normal file
36
Mage.Sets/src/mage/cards/e/EchoStorm.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package mage.cards.e;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.common.CreateTokenCopyTargetEffect;
|
||||
import mage.abilities.keyword.CommanderStormAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.target.common.TargetArtifactPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class EchoStorm extends CardImpl {
|
||||
|
||||
public EchoStorm(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}{U}");
|
||||
|
||||
// When you cast this spell, copy it for each time you've cast your commander from the command zone this game. You may choose new targets for the copies.
|
||||
this.addAbility(new CommanderStormAbility());
|
||||
|
||||
// Create a token that's a copy of target artifact.
|
||||
this.getSpellAbility().addEffect(new CreateTokenCopyTargetEffect());
|
||||
this.getSpellAbility().addTarget(new TargetArtifactPermanent());
|
||||
}
|
||||
|
||||
public EchoStorm(final EchoStorm card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EchoStorm copy() {
|
||||
return new EchoStorm(this);
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ public final class Commander2018 extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Centaur Vinecrasher", 135, Rarity.RARE, mage.cards.c.CentaurVinecrasher.class));
|
||||
cards.add(new SetCardInfo("Chain Reaction", 121, Rarity.RARE, mage.cards.c.ChainReaction.class));
|
||||
cards.add(new SetCardInfo("Chaos Warp", 122, Rarity.RARE, mage.cards.c.ChaosWarp.class));
|
||||
cards.add(new SetCardInfo("Echo Storm", 7, Rarity.RARE, mage.cards.e.EchoStorm.class));
|
||||
cards.add(new SetCardInfo("Eidolon of Blossoms", 140, Rarity.RARE, mage.cards.e.EidolonOfBlossoms.class));
|
||||
cards.add(new SetCardInfo("Enchanter's Bane", 21, Rarity.RARE, mage.cards.e.EnchantersBane.class));
|
||||
cards.add(new SetCardInfo("Explosive Vegetation", 144, Rarity.UNCOMMON, mage.cards.e.ExplosiveVegetation.class));
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Plopman
|
||||
*/
|
||||
public class CommanderStormAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public CommanderStormAbility() {
|
||||
super(Zone.STACK, new CommanderStormEffect());
|
||||
this.ruleAtTheTop = true;
|
||||
}
|
||||
|
||||
private CommanderStormAbility(final CommanderStormAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommanderStormAbility copy() {
|
||||
return new CommanderStormAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.SPELL_CAST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getSourceId().equals(getSourceId())) {
|
||||
StackObject spell = game.getStack().getStackObject(getSourceId());
|
||||
if (spell instanceof Spell) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setValue("StormSpell", spell);
|
||||
effect.setValue("StormSpellRef", new MageObjectReference(spell.getId(), game));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "When you cast this spell, copy it for each time you've "
|
||||
+ "cast your commander from the command zone this game. "
|
||||
+ "You may choose new targets for the copies.";
|
||||
}
|
||||
}
|
||||
|
||||
class CommanderStormEffect extends OneShotEffect {
|
||||
|
||||
public CommanderStormEffect() {
|
||||
super(Outcome.Copy);
|
||||
}
|
||||
|
||||
public CommanderStormEffect(final CommanderStormEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MageObjectReference spellRef = (MageObjectReference) this.getValue("StormSpellRef");
|
||||
if (spellRef == null) {
|
||||
return false;
|
||||
}
|
||||
int stormCount = 0;
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
stormCount = player.getCommandersIds().stream().map(
|
||||
(commanderId) -> (Integer) game.getState().getValue(commanderId + "_castCount")
|
||||
).map((castCount) -> castCount).reduce(stormCount, Integer::sum);
|
||||
if (stormCount == 0) {
|
||||
return true;
|
||||
}
|
||||
Spell spell = (Spell) this.getValue("StormSpell");
|
||||
if (spell == null) {
|
||||
return false;
|
||||
}
|
||||
game.informPlayers(spell.getLogName() + " will be copied " + stormCount + " time" + (stormCount > 1 ? "s" : ""));
|
||||
for (int i = 0; i < stormCount; i++) {
|
||||
spell.createCopyOnStack(game, source, source.getControllerId(), true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommanderStormEffect copy() {
|
||||
return new CommanderStormEffect(this);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue