Skip to content

Commit

Permalink
set cardsLeavingGraveyard value in CardsLeaveGraveyardTriggeredAbility
Browse files Browse the repository at this point in the history
  • Loading branch information
jimga150 committed Aug 19, 2024
1 parent f66204c commit 5d43904
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import mage.game.events.ZoneChangeGroupEvent;

import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

/**
* @author TheElk801
Expand Down Expand Up @@ -50,16 +52,18 @@ public boolean checkEventType(GameEvent event, Game game) {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event;
return zEvent != null
&& Zone.GRAVEYARD == zEvent.getFromZone()
&& Zone.GRAVEYARD != zEvent.getToZone()
&& zEvent.getCards() != null
&& zEvent.getCards()
if (zEvent == null || Zone.GRAVEYARD != zEvent.getFromZone()
|| Zone.GRAVEYARD == zEvent.getToZone() || zEvent.getCards() == null){
return false;
}
Set<Card> cards = zEvent.getCards()
.stream()
.filter(Objects::nonNull)
.filter(card -> filter.match(card, getControllerId(), this, game))
.map(Card::getOwnerId)
.anyMatch(this::isControlledBy);
.filter(card -> this.isControlledBy(card.getOwnerId()))
.collect(Collectors.toSet());
this.getAllEffects().setValue("cardsLeavingGraveyard", cards);
return !cards.isEmpty();
}

@Override
Expand Down

0 comments on commit 5d43904

Please sign in to comment.