Implemented Strongarm Tactics

This commit is contained in:
Evan Kranzler 2017-09-17 17:07:00 -04:00
parent 1a5350cdf4
commit 493b4ad65c
2 changed files with 125 additions and 0 deletions

View file

@ -0,0 +1,124 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.cards.s;
import java.util.HashMap;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetDiscard;
/**
*
* @author TheElk801
*/
public class StrongarmTactics extends CardImpl {
public StrongarmTactics(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}");
// Each player discards a card. Then each player who didn't discard a creature card this way loses 4 life.
this.getSpellAbility().addEffect(new StrongarmTacticsEffect());
}
public StrongarmTactics(final StrongarmTactics card) {
super(card);
}
@Override
public StrongarmTactics copy() {
return new StrongarmTactics(this);
}
}
class StrongarmTacticsEffect extends OneShotEffect {
StrongarmTacticsEffect() {
super(Outcome.Discard);
this.staticText = "Each player discards a card. Then each player who didn't discard a creature card this way loses 4 life.";
}
StrongarmTacticsEffect(final StrongarmTacticsEffect effect) {
super(effect);
}
@Override
public StrongarmTacticsEffect copy() {
return new StrongarmTacticsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
// Store for each player the cards to discard, that's important because all discard shall happen at the same time
HashMap<UUID, Cards> cardsToDiscard = new HashMap<>();
if (controller != null) {
// choose cards to discard
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int numberOfCardsToDiscard = Math.min(1, player.getHand().size());
Cards cards = new CardsImpl();
Target target = new TargetDiscard(numberOfCardsToDiscard, numberOfCardsToDiscard, new FilterCard(), playerId);
player.chooseTarget(outcome, target, source, game);
cards.addAll(target.getTargets());
cardsToDiscard.put(playerId, cards);
}
}
// discard all choosen cards
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
Cards cardsPlayer = cardsToDiscard.get(playerId);
if (cardsPlayer != null) {
for (UUID cardId : cardsPlayer) {
Card card = game.getCard(cardId);
if (card != null) {
if (!(player.discard(card, source, game) && card.isCreature())) {
player.loseLife(4, game, false);
}
}
}
}
}
}
}
return true;
}
}

View file

@ -276,6 +276,7 @@ public class Onslaught extends ExpansionSet {
cards.add(new SetCardInfo("Starlit Sanctum", 325, Rarity.UNCOMMON, mage.cards.s.StarlitSanctum.class));
cards.add(new SetCardInfo("Starstorm", 238, Rarity.RARE, mage.cards.s.Starstorm.class));
cards.add(new SetCardInfo("Steely Resolve", 286, Rarity.RARE, mage.cards.s.SteelyResolve.class));
cards.add(new SetCardInfo("Strongarm Tactics", 173, Rarity.RARE, mage.cards.s.StrongarmTactics.class));
cards.add(new SetCardInfo("Sunfire Balm", 56, Rarity.UNCOMMON, mage.cards.s.SunfireBalm.class));
cards.add(new SetCardInfo("Supreme Inquisitor", 117, Rarity.RARE, mage.cards.s.SupremeInquisitor.class));
cards.add(new SetCardInfo("Swamp", 339, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS));