Added new method for discarding cards to handle batch triggers (ready for review) (#6489)

* added new discard method

* started refactoring to use new discard method

* refactored A through I

* fixed some issues

* separated balance effect into its own class

* refactored J through R

* refactored S through Z

* applied requested changes
This commit is contained in:
Evan Kranzler 2020-05-03 14:35:26 -04:00 committed by GitHub
parent 2739391b1d
commit 75577cdbe9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
68 changed files with 1290 additions and 1953 deletions

View file

@ -1,20 +1,21 @@
package mage.abilities.costs.common;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class DiscardTargetCost extends CostImpl {
@ -50,13 +51,11 @@ public class DiscardTargetCost extends CostImpl {
if (randomDiscard) {
this.cards.addAll(player.discard(amount, true, ability, game).getCards(game));
} else if (targets.choose(Outcome.Discard, controllerId, sourceId, game)) {
for (UUID targetId : targets.get(0).getTargets()) {
Card card = player.getHand().get(targetId, game);
if (card == null) {
return false;
}
player.discard(card, ability, game);
this.cards.add(card);
Cards toDiscard = new CardsImpl();
toDiscard.addAll(targets.get(0).getTargets());
Cards discarded = player.discard(toDiscard, ability, game);
if (!discarded.isEmpty()) {
cards.addAll(discarded.getCards(game));
}
}
paid = cards.size() >= amount;