mirror of
https://github.com/magefree/mage.git
synced 2026-01-23 19:59:54 -08:00
* Counterbalance, Hisako, Minamp Sensai - Fixed that converted mana comparison of spilt cards did not work correctly.
This commit is contained in:
parent
bff01090b5
commit
821398211b
8 changed files with 177 additions and 9 deletions
|
|
@ -32,7 +32,7 @@ import mage.abilities.condition.Condition;
|
|||
import mage.game.Game;
|
||||
|
||||
public class MyTurnCondition implements Condition {
|
||||
private static MyTurnCondition fInstance = new MyTurnCondition();
|
||||
private final static MyTurnCondition fInstance = new MyTurnCondition();
|
||||
|
||||
public static Condition getInstance() {
|
||||
return fInstance;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,18 @@ import java.util.UUID;
|
|||
import mage.constants.TimingRule;
|
||||
|
||||
/**
|
||||
*
|
||||
* 702.52. Transmute
|
||||
*
|
||||
* 702.52a Transmute is an activated ability that functions only while the card with transmute is
|
||||
* in a player’s hand. “Transmute [cost]” means “[Cost], Discard this card: Search your library for
|
||||
* a card with the same converted mana cost as the discarded card, reveal that card, and put it into
|
||||
* your hand. Then shuffle your library. Play this ability only any time you could play a sorcery.”
|
||||
*
|
||||
* 702.52b Although the transmute ability is playable only if the card is in a player’s hand, it
|
||||
* continues to exist while the object is in play and in all other zones. Therefore objects with
|
||||
* transmute will be affected by effects that depend on objects having one or more activated abilities.
|
||||
*
|
||||
* @author Loki
|
||||
*/
|
||||
public class TransmuteAbility extends SimpleActivatedAbility {
|
||||
|
|
@ -72,7 +84,7 @@ class TransmuteEffect extends OneShotEffect {
|
|||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
|
||||
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||
revealed.add(card);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import mage.game.Game;
|
|||
/**
|
||||
*
|
||||
* @author North
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class IntComparePredicate<T extends MageObject> implements Predicate<T> {
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@
|
|||
|
||||
package mage.util;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
|
||||
|
|
@ -46,9 +48,11 @@ import mage.abilities.costs.mana.ManaCosts;
|
|||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.costs.mana.VariableManaCost;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.constants.CardType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.token.Token;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.util.functions.CopyFunction;
|
||||
import mage.util.functions.CopyTokenFunction;
|
||||
|
||||
|
|
@ -515,4 +519,32 @@ public class CardUtil {
|
|||
public static String addToolTipMarkTags(String text) {
|
||||
return "<font color = 'blue'>" + text + "</font>";
|
||||
}
|
||||
|
||||
public static boolean convertedManaCostsIsEqual(MageObject object1, MageObject object2) {
|
||||
Set<Integer> cmcObject1 = getCMC(object1);
|
||||
Set<Integer> cmcObject2 = getCMC(object2);
|
||||
for (Integer integer :cmcObject1) {
|
||||
if (cmcObject2.contains(integer)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Set<Integer> getCMC(MageObject object) {
|
||||
Set<Integer> cmcObject = new HashSet<>();
|
||||
if (object instanceof Card) {
|
||||
Card card = (Card) object;
|
||||
if (card instanceof SplitCard) {
|
||||
SplitCard splitCard = (SplitCard) card;
|
||||
cmcObject.add(splitCard.getLeftHalfCard().getManaCost().convertedManaCost());
|
||||
cmcObject.add(splitCard.getRightHalfCard().getManaCost().convertedManaCost());
|
||||
} else {
|
||||
cmcObject.add(card.getManaCost().convertedManaCost());
|
||||
}
|
||||
} else if (object instanceof Spell) {
|
||||
cmcObject.add(((Spell)object).getConvertedManaCost());
|
||||
}
|
||||
return cmcObject;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue