use of mage.MageObject in project mage by magefree.
the class DarigaazReincarnatedReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
if (sourceObject instanceof Card) {
Card card = (Card) sourceObject;
new RemoveCounterSourceEffect(CounterType.EGG.createInstance()).apply(game, source);
if (card.getCounters(game).getCount(CounterType.EGG) == 0) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
return true;
}
return false;
}
use of mage.MageObject in project mage by magefree.
the class DarkDecisionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
TargetCardInLibrary target = new TargetCardInLibrary(new FilterNonlandCard());
target.setCardLimit(10);
if (controller.searchLibrary(target, source, game)) {
UUID targetId = target.getFirstTarget();
Card card = game.getCard(targetId);
if (card != null) {
controller.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName());
ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(card.getId(), game));
game.addEffect(effect, source);
}
controller.shuffleLibrary(source, game);
}
return true;
}
return false;
}
use of mage.MageObject in project mage by magefree.
the class MoveCounterFromTargetToTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) {
Permanent fromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (fromPermanent != null && fromPermanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
Permanent toPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (toPermanent != null) {
fromPermanent.removeCounters(CounterType.P1P1.createInstance(), source, game);
toPermanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
game.informPlayers(sourceObject.getLogName() + ": Moved a +1/+1 counter from " + fromPermanent.getLogName() + " to " + toPermanent.getLogName());
}
}
return true;
}
return false;
}
use of mage.MageObject in project mage by magefree.
the class DomriChaosBringerTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!event.getSourceId().equals(spellId)) {
return false;
}
if (game.getTurnNum() != turnNumber) {
return false;
}
MageObject mo = game.getObject(event.getTargetId());
if (mo == null || !mo.isCreature(game)) {
return false;
}
StackObject stackObject = game.getStack().getStackObject(event.getTargetId());
if (stackObject == null) {
return false;
}
this.getEffects().clear();
FilterCard filter = new FilterCard();
filter.add(new CardIdPredicate(stackObject.getSourceId()));
this.addEffect(new GainAbilityControlledSpellsEffect(new RiotAbility(), filter));
return true;
}
use of mage.MageObject in project mage by magefree.
the class DomriRadeEffect1 method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && controller != null && controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
CardsImpl cards = new CardsImpl();
cards.add(card);
controller.lookAtCards(sourceObject.getName(), cards, game);
if (card.isCreature(game)) {
if (controller.chooseUse(outcome, "Reveal " + card.getName() + " and put it into your hand?", source, game)) {
controller.moveCards(card, Zone.HAND, source, game);
controller.revealCards(sourceObject.getIdName(), cards, game);
}
}
return true;
}
}
return false;
}
Aggregations