Add additional copy test to check copy of effects/abilities (#10754)

* add further copy test

* add more missing copy constructors/methods
This commit is contained in:
Susucre 2023-08-05 02:10:23 +02:00 committed by GitHub
parent 4ebfd79005
commit 894d557952
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 78 additions and 8 deletions

View file

@ -1,7 +1,6 @@
package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -18,14 +17,15 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author North
*/
public final class GoreVassal extends CardImpl {
public GoreVassal(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}");
this.subtype.add(SubType.PHYREXIAN);
this.subtype.add(SubType.DOG);
@ -58,6 +58,15 @@ class GoreVassalEffect extends RegenerateTargetEffect {
staticText = "Then if that creature's toughness is 1 or greater, regenerate it";
}
protected GoreVassalEffect(final GoreVassalEffect effect) {
super(effect);
}
@Override
public GoreVassalEffect copy() {
return new GoreVassalEffect(this);
}
@Override
public void init(Ability source, Game game) {
Permanent creature = game.getPermanent(source.getFirstTarget());

View file

@ -52,6 +52,15 @@ class SoldeviSentryEffect extends RegenerateSourceEffect {
this.staticText = "Choose target opponent. Regenerate {this}. When it regenerates this way, that player may draw a card";
}
protected SoldeviSentryEffect(final SoldeviSentryEffect effect) {
super(effect);
}
@Override
public SoldeviSentryEffect copy() {
return new SoldeviSentryEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
//20110204 - 701.11

View file

@ -76,6 +76,15 @@ class TravelersCloakGainAbilityAttachedEffect extends GainAbilityAttachedEffect
super(new LandwalkAbility(filter), AttachmentType.AURA);
}
protected TravelersCloakGainAbilityAttachedEffect(final TravelersCloakGainAbilityAttachedEffect effect) {
super(effect);
}
@Override
public TravelersCloakGainAbilityAttachedEffect copy() {
return new TravelersCloakGainAbilityAttachedEffect(this);
}
@Override
public void afterGain(Game game, Ability source, Permanent permanent, Ability addedAbility) {
super.afterGain(game, source, permanent, addedAbility);

View file

@ -51,11 +51,19 @@ public final class UrzasMiter extends CardImpl {
class UrzasMiterDoIfCostPaid extends DoIfCostPaid {
public UrzasMiterDoIfCostPaid(Effect effect, Cost cost) {
super(effect, cost);
}
protected UrzasMiterDoIfCostPaid(final UrzasMiterDoIfCostPaid effect) {
super(effect);
}
@Override
public UrzasMiterDoIfCostPaid copy() {
return new UrzasMiterDoIfCostPaid(this);
}
@Override
public boolean apply(Game game, Ability source) {
UrzasMiterWatcher watcher = game.getState().getWatcher(UrzasMiterWatcher.class);

View file

@ -1636,11 +1636,29 @@ public class VerifyCardDataTest {
}
}
private void checkCardCanBeCopied(Card card) {
private void checkCardCanBeCopied(Card card1) {
Card card2;
try {
Card card2 = card.copy();
card2 = card1.copy();
} catch (Error err) {
fail(card, "copy", "throws on copy : " + err.getClass() + " : " + err.getMessage() + " : ");
fail(card1, "copy", "throws on copy : " + err.getClass() + " : " + err.getMessage() + " : ");
return;
}
// Checks that ability and effect are of the same class when copied.
for (int i = 0; i < card1.getAbilities().size(); i++) {
Ability ability1 = card1.getAbilities().get(i);
Ability ability2 = card2.getAbilities().get(i);
if (!ability1.getClass().equals(ability2.getClass())) {
fail(card1, "copy", " miss copy in ability " + ability1.getClass().getName());
}
for (int j = 0; j < ability1.getEffects().size(); j++) {
Effect effect1 = ability1.getEffects().get(j);
Effect effect2 = ability2.getEffects().get(j);
if (!effect1.getClass().equals(effect2.getClass())) {
fail(card1, "copy", "miss copy in effect " + effect1.getClass().getName());
}
}
}
}

View file

@ -16,7 +16,6 @@ import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.ColorPredicate;
/**
*
* @author TheElk801
*/
public class SanctuaryInterveningIfTriggeredAbility extends ConditionalInterveningIfTriggeredAbility {
@ -51,4 +50,13 @@ public class SanctuaryInterveningIfTriggeredAbility extends ConditionalInterveni
public SanctuaryInterveningIfTriggeredAbility(OneShotEffect effect1, OneShotEffect effect2, ObjectColor color1, ObjectColor color2, String text) {
super(makeTrigger(effect1, effect2, color1, color2), makeOrCondition(color1, color2), text);
}
protected SanctuaryInterveningIfTriggeredAbility(final SanctuaryInterveningIfTriggeredAbility ability) {
super(ability);
}
@Override
public SanctuaryInterveningIfTriggeredAbility copy() {
return new SanctuaryInterveningIfTriggeredAbility(this);
}
}

View file

@ -9,4 +9,13 @@ public class RummageEffect extends DoIfCostPaid {
public RummageEffect() {
super(new DrawCardSourceControllerEffect(1), new DiscardCardCost());
}
protected RummageEffect(final RummageEffect effect) {
super(effect);
}
@Override
public RummageEffect copy() {
return new RummageEffect(this);
}
}