use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class OtherworldlyJourneyEntersBattlefieldEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
// use only once
discard();
}
return false;
}
use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class DevourEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(source.getSourceId())) {
Permanent sourcePermanent = ((EntersTheBattlefieldEvent) event).getTarget();
game.getState().setValue(sourcePermanent.getId().toString() + "devoured", null);
return true;
}
return false;
}
use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class ChorusOfTheConclaveReplacementEffect2 method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
Map<String, Integer> spellX = (Map<String, Integer>) game.getState().getValue("spellX" + source.getSourceId());
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null && creature != null && spellX != null) {
String key = event.getSourceId().toString() + (game.getState().getZoneChangeCounter(event.getSourceId()) - 1);
int xValue = spellX.get(key);
if (xValue > 0) {
creature.addCounters(CounterType.P1P1.createInstance(xValue), source.getControllerId(), source, game, event.getAppliedEffects());
game.informPlayers(sourceObject.getLogName() + ": " + creature.getLogName() + " enters the battlefield with " + xValue + " +1/+1 counter" + (xValue > 1 ? "s" : "") + " on it");
}
spellX.remove(key);
}
return false;
}
use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class SuturePriestSecondTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
EntersTheBattlefieldEvent zEvent = (EntersTheBattlefieldEvent) event;
Card card = zEvent.getTarget();
if (card != null && card.isCreature(game)) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
return true;
}
}
return false;
}
use of mage.game.events.EntersTheBattlefieldEvent in project mage by magefree.
the class AquamorphEntityReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent;
if (event instanceof EntersTheBattlefieldEvent) {
permanent = ((EntersTheBattlefieldEvent) event).getTarget();
} else {
permanent = game.getPermanent(event.getTargetId());
}
if (permanent == null) {
return false;
}
Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose what the creature becomes to");
choice.getChoices().add(choice51);
choice.getChoices().add(choice15);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && !controller.choose(Outcome.Neutral, choice, game)) {
discard();
return false;
}
int power = 0;
int toughness = 0;
switch(choice.getChoice()) {
case choice51:
power = 5;
toughness = 1;
break;
case choice15:
power = 1;
toughness = 5;
break;
}
game.addEffect(new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom, SubLayer.SetPT_7b), source);
return true;
}
Aggregations