use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class MysticReflectionGainAbilityEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
MysticReflectionWatcher watcher = game.getState().getWatcher(MysticReflectionWatcher.class);
if (watcher != null) {
if (watcher.getEnteredThisTurn() > this.enteredThisTurn) {
discard();
return false;
}
}
Permanent permanentEnteringTheBattlefield = ((EntersTheBattlefieldEvent) event).getTarget();
Permanent targetedPermanent = (Permanent) game.getState().getValue("MysticReflection" + identifier);
return permanentEnteringTheBattlefield != null && targetedPermanent != null && permanentEnteringTheBattlefield.isCreature(game);
}
use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class FblthpTheLostTargetedTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!super.checkTrigger(event, game)) {
return false;
}
EntersTheBattlefieldEvent entersEvent = (EntersTheBattlefieldEvent) event;
if (entersEvent.getFromZone() == Zone.LIBRARY) {
this.getEffects().clear();
this.addEffect(new DrawCardSourceControllerEffect(2));
return true;
}
FblthpTheLostWatcher watcher = game.getState().getWatcher(FblthpTheLostWatcher.class);
int zcc = entersEvent.getTarget().getZoneChangeCounter(game) - 1;
MageObjectReference mor = new MageObjectReference(entersEvent.getTargetId(), zcc, game);
if (watcher != null && watcher.spellWasCastFromLibrary(mor)) {
this.getEffects().clear();
this.addEffect(new DrawCardSourceControllerEffect(2));
return true;
}
this.getEffects().clear();
this.addEffect(new DrawCardSourceControllerEffect(1));
return true;
}
use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class GuardianProjectEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (!filter.match(permanent, sourceId, controllerId, game)) {
return false;
}
if (checkCondition(permanent, controllerId, game)) {
this.getEffects().clear();
this.addEffect(new GuardianProjectEffect(new MageObjectReference(permanent, game)));
return true;
}
return false;
}
use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class MasterBiomancerEntersBattlefieldEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent sourceCreature = game.getPermanent(source.getSourceId());
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
if (sourceCreature != null && creature != null) {
int power = sourceCreature.getPower().getValue();
if (power > 0) {
creature.addCounters(CounterType.P1P1.createInstance(power), source.getControllerId(), source, game);
}
ContinuousEffect effect = new AddCardSubTypeTargetEffect(SubType.MUTANT, Duration.Custom);
effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game) + 1));
game.addEffect(effect, source);
}
return false;
}
use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class ShimatsuTheBloodcloakedEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId());
if (creature != null && controller != null) {
Target target = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterControlledPermanent(), true);
if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
return false;
}
controller.chooseTarget(Outcome.Detriment, target, source, game);
if (!target.getTargets().isEmpty()) {
int sacrificedCreatures = target.getTargets().size();
game.informPlayers(controller.getLogName() + " sacrifices " + sacrificedCreatures + " creatures for " + creature.getLogName());
for (UUID targetId : target.getTargets()) {
Permanent targetCreature = game.getPermanent(targetId);
if (targetCreature == null || !targetCreature.sacrifice(source, game)) {
return false;
}
}
creature.addCounters(CounterType.P1P1.createInstance(sacrificedCreatures), source.getControllerId(), source, game);
}
}
return false;
}
Aggregations