Skip to content

Commit

Permalink
add a verify check
Browse files Browse the repository at this point in the history
  • Loading branch information
xenohedron committed Nov 17, 2024
1 parent d89ec5b commit e7de47a
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import mage.MageObject;
import mage.Mana;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.AbilityImpl;
import mage.abilities.Mode;
import mage.abilities.*;
import mage.abilities.common.*;
import mage.abilities.condition.Condition;
import mage.abilities.costs.Cost;
Expand Down Expand Up @@ -36,6 +34,7 @@
import mage.game.command.Dungeon;
import mage.game.command.Plane;
import mage.game.draft.DraftCube;
import mage.game.events.GameEvent;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.custom.CreatureToken;
Expand Down Expand Up @@ -63,6 +62,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* @author JayDi85
Expand Down Expand Up @@ -1718,6 +1718,10 @@ private void compareClassRecursive(Object obj1, Object obj2, Card originalCard,
}
}

if (obj1 instanceof Ability) {
checkAbility(originalCard, (Ability) obj1, msg);
}

//System.out.println(msg);
Class class1 = obj1.getClass();
Class class2 = obj2.getClass();
Expand Down Expand Up @@ -1852,6 +1856,34 @@ private void compareClassRecursive(Object obj1, Object obj2, Card originalCard,
}
}

// One (fake) event per batch event type
private static final Set<GameEvent> fakeBatchEvents;

static {
fakeBatchEvents = Stream
.of(GameEvent.EventType.values())
.filter(GameEvent.EventType::isBatch)
.map(eventType -> new GameEvent(eventType, null, null, null))
.collect(Collectors.toSet());
}

/**
* Perform checks on abilities
*/
private void checkAbility(Card originalCard, Ability ability, String msg) {
if (ability instanceof TriggeredAbility) {
// Checks that non-batched triggered ability don't accept batch events.
if (!(ability instanceof BatchTriggeredAbility)) {
for (GameEvent event : fakeBatchEvents) {
if (((TriggeredAbility) ability).checkEventType(event, null)) {
fail(originalCard, "checkAbility", "unexpected non-BatchTriggeredAbility accepting "
+ event.getType() + " " + msg + "<" + ability.getClass() + ">");
}
}
}
}
}

private void checkSubtypes(Card card, MtgJsonCard ref) {
if (skipListHaveName(SKIP_LIST_SUBTYPE, card.getExpansionSetCode(), card.getName())) {
return;
Expand Down

0 comments on commit e7de47a

Please sign in to comment.