use of mage.MageObjectReference in project mage by magefree.
the class RaziaBorosArchangelEffect method init.
@Override
public void init(Ability source, Game game) {
super.init(source, game);
redirectToObject = new MageObjectReference(source.getTargets().get(1).getFirstTarget(), game);
}
use of mage.MageObjectReference in project mage by magefree.
the class SuspendEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (controller == null || permanent == null) {
return false;
}
Card card = permanent.getMainCard();
if (!controller.moveCards(permanent, Zone.EXILED, source, game) || game.getState().getZone(card.getId()) != Zone.EXILED) {
return true;
}
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
if (!controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getLogName(), source, game, Zone.HAND, true)) {
return true;
}
card.addCounters(CounterType.TIME.createInstance(2), source.getControllerId(), source, game);
if (!card.getAbilities(game).containsClass(SuspendAbility.class)) {
game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
}
game.informPlayers(controller.getLogName() + " suspends 2 - " + card.getName());
return true;
}
use of mage.MageObjectReference in project mage by magefree.
the class TheUpsideDownLeavesAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Set<MageObjectReference> morSet = (Set<MageObjectReference>) game.getState().getValue(TheUpsideDown.makeKey(this, game));
return morSet != null && !morSet.isEmpty() && morSet.stream().anyMatch(mor -> mor.refersTo(zEvent.getTarget(), game));
}
use of mage.MageObjectReference in project mage by magefree.
the class ViviensInvocationDamageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7));
if (cards.isEmpty()) {
return true;
}
TargetCard target = new TargetCard(Zone.LIBRARY, filter);
target.setNotTarget(true);
controller.choose(Outcome.PutCreatureInPlay, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card == null) {
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
cards.remove(card);
}
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new ViviensInvocationDamageEffect(new MageObjectReference(permanent, game)), false, "it deals damage equals to its power to target creature an opponent controls");
ability.addTarget(new TargetOpponentsCreaturePermanent());
game.fireReflexiveTriggeredAbility(ability, source);
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
use of mage.MageObjectReference in project mage by magefree.
the class VisionCharmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
Permanent land = it.next().getPermanent(game);
if (land == null) {
it.remove();
continue;
}
land.removeAllSubTypes(game, SubTypeSet.NonBasicLandType);
land.addSubType(game, targetBasicLandType);
land.removeAllAbilities(source.getSourceId(), game);
switch(targetBasicLandType) {
case FOREST:
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
break;
case PLAINS:
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
break;
case MOUNTAIN:
land.addAbility(new RedManaAbility(), source.getSourceId(), game);
break;
case ISLAND:
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
break;
case SWAMP:
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
break;
}
}
return true;
}
Aggregations