Merge pull request #5098 from NoahGleason/swift-silence

Implement Swift Silence
This commit is contained in:
LevelX2 2018-07-14 10:27:19 +02:00 committed by GitHub
commit 1e2d269086
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 81 additions and 1 deletions

View file

@ -0,0 +1,79 @@
package mage.cards.s;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
/**
*
* @author noahg
*/
public final class SwiftSilence extends CardImpl {
public SwiftSilence(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{W}{U}{U}");
// Counter all other spells. Draw a card for each spell countered this way.
this.getSpellAbility().addEffect(new SwiftSilenceEffect());
}
public SwiftSilence(final SwiftSilence card) {
super(card);
}
@Override
public SwiftSilence copy() {
return new SwiftSilence(this);
}
}
class SwiftSilenceEffect extends OneShotEffect {
public SwiftSilenceEffect() {
super(Outcome.Detriment);
staticText = "Counter all other spells. Draw a card for each spell countered this way.";
}
public SwiftSilenceEffect(final SwiftSilenceEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
List<Spell> spellsToCounter = new LinkedList<>();
for (StackObject stackObject : game.getStack()) {
if (stackObject instanceof Spell && !stackObject.getId().equals(source.getSourceObject(game).getId())) {
spellsToCounter.add((Spell) stackObject);
}
}
int toDraw = 0;
for (Spell spell : spellsToCounter) {
if (game.getStack().counter(spell.getId(), source.getSourceId(), game)){
toDraw++;
}
}
Player controller = game.getPlayer(source.getControllerId());
if (toDraw > 0 && controller != null){
controller.drawCards(toDraw, game);
}
return true;
}
@Override
public SwiftSilenceEffect copy() {
return new SwiftSilenceEffect(this);
}
}

View file

@ -179,6 +179,7 @@ public final class Dissension extends ExpansionSet {
cards.add(new SetCardInfo("Stormscale Anarch", 74, Rarity.RARE, mage.cards.s.StormscaleAnarch.class));
cards.add(new SetCardInfo("Street Savvy", 97, Rarity.COMMON, mage.cards.s.StreetSavvy.class));
cards.add(new SetCardInfo("Supply // Demand", 157, Rarity.UNCOMMON, mage.cards.s.SupplyDemand.class));
cards.add(new SetCardInfo("Swift Silence", 132, Rarity.RARE, mage.cards.s.SwiftSilence.class));
cards.add(new SetCardInfo("Taste for Mayhem", 75, Rarity.COMMON, mage.cards.t.TasteForMayhem.class));
cards.add(new SetCardInfo("Thrive", 98, Rarity.COMMON, mage.cards.t.Thrive.class));
cards.add(new SetCardInfo("Tidespout Tyrant", 34, Rarity.RARE, mage.cards.t.TidespoutTyrant.class));

View file

@ -89,10 +89,10 @@ public class SpellStack extends ArrayDeque<StackObject> {
game.informPlayers(counteredObjectName + " is countered by " + sourceObject.getLogName());
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, objectId, sourceId, stackObject.getControllerId()));
return true;
} else if (!game.isSimulation()) {
game.informPlayers(counteredObjectName + " could not be countered by " + sourceObject.getLogName());
}
return true;
}
return false;
}