tests: added additional tests for Dryad Militant card and Madness abilities, added docs;

This commit is contained in:
Oleg Agafonov 2024-05-12 12:33:48 +04:00
parent 8c0ed8a749
commit d28b9e6d05
6 changed files with 283 additions and 43 deletions

View file

@ -131,13 +131,16 @@ class MadnessReplacementEffect extends ReplacementEffectImpl {
return false;
}
// TODO, deal with deprecated call
if (controller.moveCards(card, Zone.EXILED, source, game)) {
game.applyEffects(); // needed to add Madness ability to cards (e.g. by Falkenrath Gorger)
GameEvent gameEvent = new MadnessCardExiledEvent(card.getId(), source, controller.getId());
game.fireEvent(gameEvent);
if (!controller.moveCards(card, Zone.EXILED, source, game)) {
return false;
}
// needed to add Madness ability to cards (e.g. by Falkenrath Gorger)
game.getState().processAction(game);
GameEvent gameEvent = new MadnessCardExiledEvent(card.getId(), source, controller.getId());
game.fireEvent(gameEvent);
return true;
}

View file

@ -1,5 +1,6 @@
package mage.watchers.common;
import mage.cards.Card;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
@ -7,12 +8,22 @@ import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.watchers.Watcher;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* @author Susucr
* Counts cards that was moved to exile zone by any way
* <p>
* Can contain multiple instances of the same card (if it was moved multiple times per turn)
*
* @author Susucr, JayDi85
*/
public class CardsExiledThisTurnWatcher extends Watcher {
private int countExiled = 0;
private final List<UUID> exiledCards = new ArrayList<>();
public CardsExiledThisTurnWatcher() {
super(WatcherScope.GAME);
@ -22,17 +33,24 @@ public class CardsExiledThisTurnWatcher extends Watcher {
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE
&& ((ZoneChangeEvent) event).getToZone() == Zone.EXILED) {
countExiled++;
this.exiledCards.add(event.getTargetId());
}
}
public int getCountCardsExiledThisTurn() {
return countExiled;
return this.exiledCards.size();
}
public List<Card> getCardsExiledThisTurn(Game game) {
return this.exiledCards.stream()
.map(game::getCard)
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
@Override
public void reset() {
super.reset();
countExiled = 0;
this.exiledCards.clear();
}
}

View file

@ -16,6 +16,8 @@ import java.util.stream.Collectors;
* Counts how many cards are put into each player's graveyard this turn.
* Keeps track of the UUIDs of the cards that went to graveyard this turn.
* from the battlefield, from anywhere other both from anywhere and from only the battlefield.
* <p>
* Can contain multiple instances of the same card (if it was moved multiple times per turn)
*
* @author LevelX2
*/
@ -40,7 +42,8 @@ public class CardsPutIntoGraveyardWatcher extends Watcher {
}
UUID playerId = event.getPlayerId();
if (playerId == null || game.getCard(event.getTargetId()) == null) {
Card card = game.getCard(event.getTargetId());
if (playerId == null || card == null) {
return;
}