use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class ScrapTrawlerTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD && ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
if (permanent != null && permanent.isControlledBy(this.getControllerId()) && permanent.isArtifact(game)) {
FilterCard filter = new FilterArtifactCard("artifact card in your graveyard with mana value less than " + permanent.getManaCost().manaValue());
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, permanent.getManaCost().manaValue()));
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filter);
getTargets().clear();
addTarget(target);
return true;
}
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class TianaShipsCaretakerEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getTarget() == null) {
return false;
}
Permanent permanent = game.getPermanentOrLKIBattlefield(zEvent.getTarget().getId());
if (permanent != null && zEvent.isDiesEvent() && (permanent.isArtifact(game) && permanent.hasSubtype(SubType.EQUIPMENT, game) || permanent.isEnchantment(game) && permanent.hasSubtype(SubType.AURA, game)) && permanent.isControlledBy(this.controllerId)) {
this.getEffects().setTargetPointer(new FixedTarget(zEvent.getTargetId()));
return true;
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class VileRedeemerNonTokenCreaturesDiedWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.isDiesEvent() && zEvent.getTarget() != null && zEvent.getTarget().isCreature(game) && !(zEvent.getTarget() instanceof PermanentToken)) {
int count = getAmountOfNontokenCreatureDiedThisTurn(zEvent.getTargetId());
amountOfCreaturesThatDied.put(zEvent.getTarget().getControllerId(), ++count);
}
}
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class WarBargeDelayedTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(this.getSourceId())) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
Effect effect = this.getEffects().get(0);
effect.setTargetPointer(new FixedTarget(this.getFirstTarget()));
return true;
}
}
return false;
}
use of mage.game.events.ZoneChangeEvent in project mage by magefree.
the class AttackingCreaturePutIntoGraveyardTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
switch(event.getType()) {
case ATTACKER_DECLARED:
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent != null && !filterPermanent.match(permanent, game)) {
return false;
}
List<UUID> attackersList = new ArrayList<>();
List<UUID> attackersListCopy = (List<UUID>) game.getState().getValue(this.getSourceId() + "Attackers");
if (attackersListCopy == null) {
attackersListCopy = attackersList;
}
// add the filtered creature to the list
attackersListCopy.add(event.getSourceId());
game.getState().setValue(this.getSourceId() + "Attackers", attackersListCopy);
return false;
case END_COMBAT_STEP_POST:
game.getState().setValue(this.getSourceId() + "Attackers", null);
return false;
case ZONE_CHANGE:
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) {
if (onlyToControllerGraveyard && !this.isControlledBy(game.getOwnerId(zEvent.getTargetId()))) {
return false;
}
if (itDies && !zEvent.isDiesEvent()) {
return false;
}
List<UUID> attackers = (List<UUID>) game.getState().getValue(this.getSourceId() + "Attackers");
return attackers != null && attackers.contains(zEvent.getTargetId());
}
case REMOVED_FROM_COMBAT:
// a card removed from combat is no longer an attacker or blocker so remove it from the list
List<UUID> attackersListRFC = (List<UUID>) game.getState().getValue(this.getSourceId() + "Attackers");
if (attackersListRFC != null && attackersListRFC.contains(event.getTargetId())) {
attackersListRFC.remove(event.getTargetId());
game.getState().setValue(this.getSourceId() + "Attackers", attackersListRFC);
}
default:
return false;
}
}
Aggregations