use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class ArchelosLagoonMysticEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent sourceObject = game.getPermanent(source.getSourceId());
if (sourceObject == null) {
return false;
}
Permanent targetObject = ((EntersTheBattlefieldEvent) event).getTarget();
if (targetObject == null) {
return false;
}
return !sourceObject.getId().equals(targetObject.getId()) && sourceObject.isTapped() == this.tapped;
}
use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class ArchfiendsVesselEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (super.checkTrigger(event, game)) {
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
EntersTheBattlefieldEvent entersTheBattlefieldEvent = (EntersTheBattlefieldEvent) event;
if (entersTheBattlefieldEvent.getTargetId().equals(getSourceId()) && entersTheBattlefieldEvent.getFromZone() == Zone.GRAVEYARD) {
return true;
} else {
SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
List<Spell> spellsCastFromGraveyard = watcher.getSpellsCastFromGraveyardThisTurn(getControllerId());
if (spellsCastFromGraveyard != null) {
return spellsCastFromGraveyard.stream().anyMatch(spell -> spell.getMainCard().getId().equals((entersTheBattlefieldEvent.getTarget().getMainCard().getId())));
}
}
}
}
return false;
}
use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class DracoplasmEffect 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, filter, true);
if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
return false;
}
controller.chooseTarget(Outcome.Detriment, target, source, game);
if (!target.getTargets().isEmpty()) {
int power = 0;
int toughness = 0;
for (UUID targetId : target.getTargets()) {
Permanent targetCreature = game.getPermanent(targetId);
if (targetCreature != null && targetCreature.sacrifice(source, game)) {
power = CardUtil.overflowInc(power, targetCreature.getPower().getValue());
toughness = CardUtil.overflowInc(toughness, targetCreature.getToughness().getValue());
}
}
ContinuousEffect effect = new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom, SubLayer.SetPT_7b);
game.addEffect(effect, source);
}
}
return false;
}
use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class RhythmOfTheWildEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
Player player = game.getPlayer(source.getControllerId());
if (creature == null || player == null) {
return false;
}
if (player.chooseUse(outcome, "Have " + creature.getLogName() + " enter the battlefield with a +1/+1 counter on it or with haste?", null, "+1/+1 counter", "Haste", source, game)) {
game.informPlayers(player.getLogName() + " choose to put a +1/+1 counter on " + creature.getName());
creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
} else {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), 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 AmplifyEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent sourceCreature = ((EntersTheBattlefieldEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId());
if (controller == null || sourceCreature == null) {
return false;
}
FilterCreatureCard filter = new FilterCreatureCard("creatures cards to reveal");
filter.add(new AmplifyPredicate(sourceCreature));
// You can’t reveal this card or any other cards that are entering the battlefield at the same time as this card.
filter.add(Predicates.not(new CardIdPredicate(source.getSourceId())));
for (Permanent enteringPermanent : game.getPermanentsEntering().values()) {
filter.add(Predicates.not(new CardIdPredicate(enteringPermanent.getId())));
}
if (controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game) <= 0) {
return false;
}
if (!controller.chooseUse(outcome, "Reveal cards to Amplify?", source, game)) {
return false;
}
TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);
if (controller.chooseTarget(outcome, target, source, game) && !target.getTargets().isEmpty()) {
Cards cards = new CardsImpl();
cards.addAll(target.getTargets());
int amountCounters = cards.size() * amplifyFactor.getFactor();
sourceCreature.addCounters(CounterType.P1P1.createInstance(amountCounters), source.getControllerId(), source, game);
controller.revealCards(sourceCreature.getIdName(), cards, game);
}
return false;
}
Aggregations