forked from External/mage
* Fixed some cost classes that didn't hadle correctly if a cost concerning card movement is paid or not.
This commit is contained in:
parent
eb0ae55257
commit
0c2abc69de
21 changed files with 141 additions and 112 deletions
|
|
@ -25,17 +25,17 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.costs.common;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.CostImpl;
|
||||
import mage.abilities.costs.mana.VariableManaCost;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
|
@ -47,47 +47,52 @@ import mage.target.common.TargetCardInHand;
|
|||
* @author LevelX2
|
||||
*/
|
||||
public class ExileFromHandCost extends CostImpl {
|
||||
|
||||
|
||||
List<Card> cards = new ArrayList<>();
|
||||
private boolean setXFromCMC;
|
||||
|
||||
|
||||
public ExileFromHandCost(TargetCardInHand target) {
|
||||
this(target, false);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param target
|
||||
* @param setXFromCMC the spells X value on the stack is set to the converted mana costs of the exiled card
|
||||
* @param setXFromCMC the spells X value on the stack is set to the
|
||||
* converted mana costs of the exiled card
|
||||
*/
|
||||
public ExileFromHandCost(TargetCardInHand target, boolean setXFromCMC) {
|
||||
this.addTarget(target);
|
||||
this.text = "exile " + target.getTargetName();
|
||||
this.setXFromCMC = setXFromCMC;
|
||||
}
|
||||
|
||||
|
||||
public ExileFromHandCost(final ExileFromHandCost cost) {
|
||||
super(cost);
|
||||
for (Card card: cost.cards) {
|
||||
for (Card card : cost.cards) {
|
||||
this.cards.add(card.copy());
|
||||
}
|
||||
this.setXFromCMC = cost.setXFromCMC;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
if (targets.choose(Outcome.Exile, controllerId, sourceId, game)) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
int cmc = 0;
|
||||
for (UUID targetId: targets.get(0).getTargets()) {
|
||||
for (UUID targetId : targets.get(0).getTargets()) {
|
||||
Card card = player.getHand().get(targetId, game);
|
||||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
cmc += card.getManaCost().convertedManaCost();
|
||||
this.cards.add(card);
|
||||
paid |= player.moveCardToExileWithInfo(card, null, null, ability.getSourceId(), game, Zone.HAND, true);
|
||||
}
|
||||
if (paid && setXFromCMC) {
|
||||
Cards cardsToExile = new CardsImpl();
|
||||
cardsToExile.addAll(cards);
|
||||
player.moveCards(cardsToExile, Zone.EXILED, ability, game);
|
||||
paid = true;
|
||||
if (setXFromCMC) {
|
||||
VariableManaCost vmc = new VariableManaCost();
|
||||
vmc.setAmount(cmc);
|
||||
vmc.setPaid();
|
||||
|
|
@ -96,18 +101,18 @@ public class ExileFromHandCost extends CostImpl {
|
|||
}
|
||||
return paid;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return targets.canChoose(sourceId, controllerId, game);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ExileFromHandCost copy() {
|
||||
return new ExileFromHandCost(this);
|
||||
}
|
||||
|
||||
public List<Card> getCards() {
|
||||
|
||||
public List<Card> getCards() {
|
||||
return cards;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue