forked from External/mage
* Abstract AdventureCard to SingleFaceSplitCard * Fix AdventureCardSpellImpl * Finish converting adventure card and adventure spell * Update Brightcap Badger change finalize call to adventure card * Update Darksteel Monolith being cast from hand condition referencing AdventureCardSpell * Update Tlincalli Hunter exiled creature condition referencing AdventureCardSpell * Update Twice Upon a Time finalizeAdventure called from Adventure card * Finish abstracting Adventure missed some more references to adventure cards * Implement Omen cards * Implement Dirgur Island Dragon * Missed some adventureSpellName references * OmenCardSpell had wrong comma symbol * Add tests for Omen Cards * Rename two part card components change from SingleFaceSplitCard to CardWithSpellOption * Update comments and variable name
37 lines
1.3 KiB
Java
37 lines
1.3 KiB
Java
package mage.abilities.condition.common;
|
|
|
|
|
|
import mage.MageObject;
|
|
import mage.abilities.Ability;
|
|
import mage.abilities.condition.Condition;
|
|
import mage.cards.SpellOptionCard;
|
|
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 SpellOptionCard || 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;
|
|
}
|
|
}
|