forked from External/mage
[CMM] Implement Demon of Fate's Design (#10737)
* refactor SacrificeCostManaValue to be an enum. * [CMM] Implement Demon of Fates Design * Add Unit Tests, including one bug on alternative cost. * fix alternativeCosts made from dynamicCost returning that they were not activated when paid. * fix small issues, add hint * cleanup tests and add a couple * Capitalize enum instances * Minor fixes * simplify the ContinuousEffect * use the ConditionPermanentHint made for the Demon * fix text
This commit is contained in:
parent
0ce21d12a5
commit
eef8f508e4
22 changed files with 707 additions and 111 deletions
|
|
@ -0,0 +1,37 @@
|
|||
package mage.abilities.condition.common;
|
||||
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.cards.AdventureCardSpell;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.ModalDoubleFacedCardHalf;
|
||||
import mage.cards.SplitCardHalf;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public enum IsBeingCastFromHandCondition implements Condition {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MageObject object = game.getObject(source);
|
||||
if (object instanceof SplitCardHalf || object instanceof AdventureCardSpell || object instanceof ModalDoubleFacedCardHalf) {
|
||||
UUID mainCardId = ((Card) object).getMainCard().getId();
|
||||
object = game.getObject(mainCardId);
|
||||
}
|
||||
if (object instanceof Spell) { // needed to check if it can be cast by alternate cost
|
||||
Spell spell = (Spell) object;
|
||||
return Zone.HAND.equals(spell.getFromZone());
|
||||
}
|
||||
if (object instanceof Card) { // needed for the check what's playable
|
||||
Card card = (Card) object;
|
||||
return game.getPlayer(card.getOwnerId()).getHand().get(card.getId(), game) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue