forked from External/mage
clean MILLED_EVENT to not store Card directly.
This commit is contained in:
parent
98c3c0381b
commit
f24b3d988d
7 changed files with 13 additions and 13 deletions
|
|
@ -84,6 +84,6 @@ class ZellixSanityFlayerTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return ((MilledBatchForOnePlayerEvent) event).getCards().count(StaticFilters.FILTER_CARD_CREATURE, game) > 0;
|
||||
return ((MilledBatchForOnePlayerEvent) event).getCards(game).count(StaticFilters.FILTER_CARD_CREATURE, game) > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class MillTriggeredAbility extends TriggeredAbilityImpl {
|
|||
default:
|
||||
throw new IllegalArgumentException("Wrong code usage. targetController not yet supported: " + targetController);
|
||||
}
|
||||
Card card = ((MilledCardEvent) event).getCard();
|
||||
Card card = ((MilledCardEvent) event).getCard(game);
|
||||
return card != null && filter.match(card, getControllerId(), this, game);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class OneOrMoreMilledTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
int count = ((MilledBatchAllEvent) event).getCards().count(filter, getControllerId(), this, game);
|
||||
int count = ((MilledBatchAllEvent) event).getCards(game).count(filter, getControllerId(), this, game);
|
||||
if (count <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package mage.game.events;
|
|||
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -15,10 +16,10 @@ public class MilledBatchAllEvent extends BatchEvent<MilledCardEvent> {
|
|||
super(EventType.MILLED_CARDS_BATCH_FOR_ALL, false, false, false, event);
|
||||
}
|
||||
|
||||
public Cards getCards() {
|
||||
public Cards getCards(Game game) {
|
||||
return new CardsImpl(getEvents()
|
||||
.stream()
|
||||
.map(MilledCardEvent::getCard)
|
||||
.map(mce -> mce.getCard(game))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet())
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package mage.game.events;
|
|||
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -15,10 +16,10 @@ public class MilledBatchForOnePlayerEvent extends BatchEvent<MilledCardEvent> {
|
|||
super(EventType.MILLED_CARDS_BATCH_FOR_ONE_PLAYER, false, false, true, event);
|
||||
}
|
||||
|
||||
public Cards getCards() {
|
||||
public Cards getCards(Game game) {
|
||||
return new CardsImpl(getEvents()
|
||||
.stream()
|
||||
.map(MilledCardEvent::getCard)
|
||||
.map(mce -> mce.getCard(game))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet())
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package mage.game.events;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -13,14 +14,11 @@ import java.util.UUID;
|
|||
*/
|
||||
public class MilledCardEvent extends GameEvent {
|
||||
|
||||
private final Card card;
|
||||
|
||||
public MilledCardEvent(Card card, UUID playerId, Ability source) {
|
||||
super(EventType.MILLED_CARD, card.getId(), source, playerId);
|
||||
this.card = card;
|
||||
}
|
||||
|
||||
public Card getCard() {
|
||||
return card;
|
||||
public Card getCard(Game game) {
|
||||
return game.getCard(getTargetId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class CardsMilledWatcher extends Watcher {
|
|||
if (event.getType() != GameEvent.EventType.MILLED_CARD) {
|
||||
return;
|
||||
}
|
||||
Card card = ((MilledCardEvent) event).getCard();
|
||||
Card card = ((MilledCardEvent) event).getCard(game);
|
||||
if (card == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue