mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
* Fixed CMC calculation for transformed cards (fixes #1826).
This commit is contained in:
parent
1deb4192ba
commit
2b8f73dbcc
132 changed files with 227 additions and 179 deletions
|
|
@ -13,45 +13,63 @@ import mage.game.Game;
|
|||
public interface MageObject extends MageItem, Serializable {
|
||||
|
||||
String getName();
|
||||
|
||||
String getIdName();
|
||||
|
||||
String getLogName();
|
||||
|
||||
String getImageName();
|
||||
|
||||
void setName(String name);
|
||||
|
||||
List<CardType> getCardType();
|
||||
|
||||
List<String> getSubtype();
|
||||
|
||||
boolean hasSubtype(String subtype);
|
||||
|
||||
List<String> getSupertype();
|
||||
|
||||
Abilities<Ability> getAbilities();
|
||||
|
||||
boolean hasAbility(UUID abilityId, Game game);
|
||||
|
||||
ObjectColor getColor(Game game);
|
||||
|
||||
ManaCosts<ManaCost> getManaCost();
|
||||
|
||||
int getConvertedManaCost();
|
||||
|
||||
MageInt getPower();
|
||||
|
||||
MageInt getToughness();
|
||||
|
||||
void adjustChoices(Ability ability, Game game);
|
||||
|
||||
void adjustCosts(Ability ability, Game game);
|
||||
|
||||
void adjustTargets(Ability ability, Game game);
|
||||
|
||||
MageObject copy();
|
||||
|
||||
/**
|
||||
* Defines that MageObject is a copy of another object
|
||||
*
|
||||
* @param isCopy
|
||||
*/
|
||||
void setCopy(boolean isCopy);
|
||||
|
||||
/**
|
||||
* Checks if current MageObject is a copy of another object
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isCopy();
|
||||
|
||||
|
||||
int getZoneChangeCounter(Game game);
|
||||
|
||||
void updateZoneChangeCounter(Game game);
|
||||
|
||||
void setZoneChangeCounter(int value, Game game);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,6 +165,14 @@ public abstract class MageObjectImpl implements MageObject {
|
|||
return manaCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConvertedManaCost() {
|
||||
if (manaCost != null) {
|
||||
return manaCost.convertedManaCost();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustChoices(Ability ability, Game game) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public class ExileFromHandCost extends CostImpl {
|
|||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
cmc += card.getManaCost().convertedManaCost();
|
||||
cmc += card.getConvertedManaCost();
|
||||
this.cards.add(card);
|
||||
}
|
||||
Cards cardsToExile = new CardsImpl();
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public class RevealTargetFromHandCost extends CostImpl {
|
|||
for (UUID targetId : targets.get(0).getTargets()) {
|
||||
Card card = player.getHand().get(targetId, game);
|
||||
if (card != null) {
|
||||
convertedManaCosts += card.getManaCost().convertedManaCost();
|
||||
convertedManaCosts += card.getConvertedManaCost();
|
||||
numberCardsRevealed++;
|
||||
cards.add(card);
|
||||
revealedCards.add(card);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class DiscardCostCardConvertedMana implements DynamicValue {
|
|||
DiscardCardCost discardCost = (DiscardCardCost) cost;
|
||||
int cmc = 0;
|
||||
for (Card card : discardCost.getCards()) {
|
||||
cmc += card.getManaCost().convertedManaCost();
|
||||
cmc += card.getConvertedManaCost();
|
||||
}
|
||||
return cmc;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class ExileFromHandCostCardConvertedMana implements DynamicValue {
|
|||
if (cost.isPaid() && cost instanceof ExileFromHandCost) {
|
||||
int xValue = 0;
|
||||
for (Card card : ((ExileFromHandCost) cost).getCards()) {
|
||||
xValue += card.getManaCost().convertedManaCost();
|
||||
xValue += card.getConvertedManaCost();
|
||||
}
|
||||
return xValue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class SacrificeCostConvertedMana implements DynamicValue {
|
|||
SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost;
|
||||
int totalCMC = 0;
|
||||
for(Permanent permanent : sacrificeCost.getPermanents()) {
|
||||
totalCMC += permanent.getManaCost().convertedManaCost();
|
||||
totalCMC += permanent.getConvertedManaCost();
|
||||
}
|
||||
return totalCMC;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class TargetConvertedManaCost implements DynamicValue {
|
|||
public int calculate(Game game, Ability source, Effect effect) {
|
||||
Card card = game.getCard(source.getFirstTarget());
|
||||
if (card != null) {
|
||||
return card.getManaCost().convertedManaCost();
|
||||
return card.getConvertedManaCost();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ public class ClashEffect extends OneShotEffect implements MageSingleton {
|
|||
cardController = controller.getLibrary().getFromTop(game);
|
||||
cards.add(cardController);
|
||||
controller.revealCards(sourceObject.getIdName() + ": Clash card of " + controller.getName(), cards, game);
|
||||
cmcController = cardController.getManaCost().convertedManaCost();
|
||||
cmcController = cardController.getConvertedManaCost();
|
||||
message.append(" (").append(cmcController).append(")");
|
||||
} else {
|
||||
message.append(" no card");
|
||||
|
|
@ -144,7 +144,7 @@ public class ClashEffect extends OneShotEffect implements MageSingleton {
|
|||
cardOpponent = opponent.getLibrary().getFromTop(game);
|
||||
cards.add(cardOpponent);
|
||||
opponent.revealCards(sourceObject.getIdName() + ": Clash card of " + opponent.getName(), cards, game);
|
||||
cmcOpponent = cardOpponent.getManaCost().convertedManaCost();
|
||||
cmcOpponent = cardOpponent.getConvertedManaCost();
|
||||
message.append(" (").append(cmcOpponent).append(")");
|
||||
} else {
|
||||
message.append(" no card");
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class ReturnSourceFromGraveyardToHandEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Card card = controller.getGraveyard().get(source.getSourceId(), game);
|
||||
if (card != null) {
|
||||
return controller.moveCards(card, null, Zone.HAND, source, game);
|
||||
return controller.moveCards(card, Zone.HAND, source, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,14 +112,14 @@ class CascadeEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
ExileZone exile = game.getExile().createZone(source.getSourceId(), player.getName() + " Cascade");
|
||||
int sourceCost = game.getCard(source.getSourceId()).getManaCost().convertedManaCost();
|
||||
int sourceCost = game.getCard(source.getSourceId()).getConvertedManaCost();
|
||||
do {
|
||||
card = player.getLibrary().getFromTop(game);
|
||||
if (card == null) {
|
||||
break;
|
||||
}
|
||||
player.moveCardsToExile(card, source, game, true, exile.getId(), exile.getName());
|
||||
} while (player.isInGame() && card.getCardType().contains(CardType.LAND) || card.getManaCost().convertedManaCost() >= sourceCost);
|
||||
} while (player.isInGame() && card.getCardType().contains(CardType.LAND) || card.getConvertedManaCost() >= sourceCost);
|
||||
player.getLibrary().reset();
|
||||
|
||||
if (card != null) {
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ class TransmuteEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (sourceObject != null && controller != null) {
|
||||
FilterCard filter = new FilterCard("card with converted mana cost " + sourceObject.getManaCost().convertedManaCost());
|
||||
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, sourceObject.getManaCost().convertedManaCost()));
|
||||
FilterCard filter = new FilterCard("card with converted mana cost " + sourceObject.getConvertedManaCost());
|
||||
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, sourceObject.getConvertedManaCost()));
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(1, filter);
|
||||
if (controller.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ public class CardInfo {
|
|||
this.className = card.getClass().getCanonicalName();
|
||||
this.power = card.getPower().toString();
|
||||
this.toughness = card.getToughness().toString();
|
||||
this.convertedManaCost = card.getManaCost().convertedManaCost();
|
||||
this.convertedManaCost = card.getConvertedManaCost();
|
||||
this.rarity = card.getRarity();
|
||||
this.splitCard = card.isSplitCard();
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ package mage.filter.predicate.mageobject;
|
|||
import mage.MageObject;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.predicate.IntComparePredicate;
|
||||
import mage.game.stack.StackObject;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -44,11 +43,7 @@ public class ConvertedManaCostPredicate extends IntComparePredicate<MageObject>
|
|||
|
||||
@Override
|
||||
protected int getInputValue(MageObject input) {
|
||||
if (input instanceof StackObject) {
|
||||
return ((StackObject) input).getConvertedManaCost();
|
||||
} else{
|
||||
return input.getManaCost().convertedManaCost();
|
||||
}
|
||||
return input.getConvertedManaCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -150,6 +150,11 @@ public class Commander implements CommandObject {
|
|||
return card.getManaCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConvertedManaCost() {
|
||||
return card.getConvertedManaCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageInt getPower() {
|
||||
return card.getPower();
|
||||
|
|
|
|||
|
|
@ -159,6 +159,11 @@ public class Emblem implements CommandObject {
|
|||
return emptyCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConvertedManaCost() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageInt getPower() {
|
||||
return MageInt.EmptyMageInt;
|
||||
|
|
|
|||
|
|
@ -263,6 +263,19 @@ public class PermanentCard extends PermanentImpl {
|
|||
return super.getManaCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConvertedManaCost() {
|
||||
if (isTransformed()) {
|
||||
// 711.4b While a double-faced permanent’s back face is up, it has only the characteristics of its back face.
|
||||
// However, its converted mana cost is calculated using the mana cost of its front face. This is a change from previous rules.
|
||||
// If a permanent is copying the back face of a double-faced card (even if the card representing that copy
|
||||
// is itself a double-faced card), the converted mana cost of that permanent is 0.
|
||||
return getCard().getConvertedManaCost();
|
||||
}
|
||||
return super.getConvertedManaCost();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZoneChangeCounter(Game game) {
|
||||
// permanent value of zone change counter stays always the same without exception of update during the process of putting the permanent onto the battlefield
|
||||
|
|
|
|||
|
|
@ -48,8 +48,7 @@ public interface StackObject extends MageObject, Controllable {
|
|||
|
||||
Ability getStackAbility();
|
||||
|
||||
int getConvertedManaCost();
|
||||
|
||||
// int getConvertedManaCost();
|
||||
boolean chooseNewTargets(Game game, UUID playerId, boolean forceChange, boolean onlyOneTarget, FilterPermanent filterNewTarget);
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -598,10 +598,10 @@ public class CardUtil {
|
|||
Card card = (Card) object;
|
||||
if (card instanceof SplitCard) {
|
||||
SplitCard splitCard = (SplitCard) card;
|
||||
cmcObject.add(splitCard.getLeftHalfCard().getManaCost().convertedManaCost());
|
||||
cmcObject.add(splitCard.getRightHalfCard().getManaCost().convertedManaCost());
|
||||
cmcObject.add(splitCard.getLeftHalfCard().getConvertedManaCost());
|
||||
cmcObject.add(splitCard.getRightHalfCard().getConvertedManaCost());
|
||||
} else {
|
||||
cmcObject.add(card.getManaCost().convertedManaCost());
|
||||
cmcObject.add(card.getConvertedManaCost());
|
||||
}
|
||||
}
|
||||
return cmcObject;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue