use of mage.MageObjectReference in project mage by magefree.
the class KethisTheHiddenHandGraveyardEffect method init.
@Override
public void init(Ability source, Game game) {
super.init(source, game);
if (!this.affectedObjectsSet) {
return;
}
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return;
}
player.getGraveyard().stream().map(game::getCard).filter(Objects::nonNull).filter(Card::isLegendary).forEach(card -> affectedObjectList.add(new MageObjectReference(card, game)));
}
use of mage.MageObjectReference in project mage by magefree.
the class MarshCasualtiesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
Permanent permanent = it.next().getPermanent(game);
if (permanent != null) {
permanent.addPower(power);
permanent.addToughness(toughness);
} else {
it.remove();
}
}
return true;
}
use of mage.MageObjectReference in project mage by magefree.
the class MindlinkMechApplier method watch.
@Override
public void watch(GameEvent event, Game game) {
Permanent vehicle;
Permanent crewer;
switch(event.getType()) {
case VEHICLE_CREWED:
vehicle = game.getPermanent(event.getTargetId());
crewer = null;
break;
case CREWED_VEHICLE:
vehicle = game.getPermanent(event.getSourceId());
crewer = game.getPermanent(event.getTargetId());
break;
default:
return;
}
if (vehicle == null) {
return;
}
if (crewer == null) {
crewCount.compute(new MageObjectReference(vehicle, game), (m, i) -> i == null ? 1 : Integer.sum(i, 1));
return;
}
crewMap.computeIfAbsent(new MageObjectReference(vehicle, game), x -> new HashSet<>()).add(new MageObjectReference(crewer, game));
}
use of mage.MageObjectReference in project mage by magefree.
the class OtherworldlyJourneyEntersBattlefieldEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
if (permanent.moveToExile(source.getSourceId(), "Otherworldly Journey", source, game)) {
ExileZone exile = game.getExile().getExileZone(source.getSourceId());
// only if permanent is in exile (tokens would be stop to exist)
if (exile != null && !exile.isEmpty()) {
Card card = game.getCard(permanent.getId());
if (card != null) {
// create delayed triggered ability
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new OtherworldlyJourneyReturnFromExileEffect(new MageObjectReference(card, game)));
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
return true;
}
}
return false;
}
use of mage.MageObjectReference in project mage by magefree.
the class SerpentsSoulJarWatcher method addPlayable.
static void addPlayable(Ability source, Game game) {
MageObjectReference mor = new MageObjectReference(source);
game.getState().getWatcher(SerpentsSoulJarWatcher.class).morMap.computeIfAbsent(mor, m -> new HashMap<>()).compute(source.getControllerId(), CardUtil::setOrIncrementValue);
}
Aggregations