mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
* Delirum - Fixed wrong card type count. Added unit test for delirum (fixes #6704).
This commit is contained in:
parent
29e5230469
commit
4b14eb3724
2 changed files with 175 additions and 3 deletions
|
|
@ -1,12 +1,14 @@
|
|||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.CardType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.PermanentToken;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
|
|
@ -20,9 +22,12 @@ public enum CardTypesInGraveyardCount implements DynamicValue {
|
|||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
Player controller = game.getPlayer(sourceAbility.getControllerId());
|
||||
if (controller != null) {
|
||||
ArrayList<CardType> foundCardTypes = new ArrayList<>();
|
||||
Set<CardType> foundCardTypes = new HashSet<>();
|
||||
for (Card card : controller.getGraveyard().getCards(game)) {
|
||||
foundCardTypes.addAll(card.getCardType());
|
||||
// 4/8/2016 In some rare cases, you can have a token or a copy of a spell in your graveyard at the moment that an object’s delirium ability counts the card types among cards in your graveyard, before that token or copy ceases to exist. Because tokens and copies of spells are not cards, even if they are copies of cards, their types will never be counted.
|
||||
if (!card.isCopy() && !(card instanceof PermanentToken)) {
|
||||
foundCardTypes.addAll(card.getCardType());
|
||||
}
|
||||
}
|
||||
return foundCardTypes.size();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue